Rem Project: Slot Machine
Rem Created: 3/18/2006 6:04:45 PM
REM Liberty Sevens
REM by MrBigger         v.1.1
Rem ***** Main Source File *****
 
`          DISCLAIMER
`This code was written for learning
`purposes and in no way condones gambling.
`By using this code you release the author
`of any responsiblity for your gambling
`habits.Your problem`s are your own.
 
`            NOTE
`If this is too loose you can tighten it up by
`unremming a different set of six data lines
`at the bottom of the program,just be sure
`to rem the set you are using now.
`Leave the last data line as is.
`............ENJOY!.............
sync on
sync rate 60
  if check display mode(800,600,32)=1
     SET DISPLAY MODE 800,600,32
     else
     SET DISPLAY MODE 800,600,16
  endif
autocam off:backdrop on:color backdrop 0:position camera (),0,-3,-50:set normalization on
set ambient light 50
randomize timer():oldtime# = timer():oldtime1# = timer()
dim virtual(64,3):dim actual(22):dim pay(3)
GOSUB PAR:GOSUB TEXTURES:GOSUB CREATE
`prep for viewport text
paid = 0:credits = 0:bet = 0:ink rgb(255,10,10),0:set text size 18
`start reels at jackpot
xrotate object 10,66:xrotate object 11,66:xrotate object 12,66
`dim all buttons
set object diffuse 21,rgb(20,20,20):set object diffuse 22,rgb(20,20,20):set object diffuse 23,rgb(20,20,20)
 
DO
  if timer() >= oldtime#+100 and mouseclick() = 0 then GOSUB RANDOM:oldtime# = timer()
GOSUB VIEWPORTS
button=PICK OBJECT(mouseX(), mousey(), 21, 27)
`spin reels
  if mouseclick() > 0 and button = 23 and bet > 0 and credits => bet
    dec credits,bet:go1 = 0:go2 = 0:go3 = 0:paid = 0
    set object diffuse 21,rgb(20,20,20):set object diffuse 22,rgb(20,20,20):set object diffuse 23,rgb(20,20,20)
      sp = 1:GOSUB SPIN:gosub payout:sp = 0
  endif
`bet 1
  if mouseclick() > 0 and button = 22 and timer() >= oldtime1#+150
    if bet < 3 and credits > bet
      inc bet
      else
      bet = 1
        if credits < 2 then set object diffuse 22,rgb(20,20,20)
    endif
   oldtime1# = timer()
  endif
`max bet
  if mouseclick() > 0 and button = 21 and credits > 2
    bet = 3:dec credits,bet:go1 = 0:go2 = 0:go3 = 0:paid = 0
    set object diffuse 21,rgb(20,20,20):set object diffuse 22,rgb(20,20,20):set object diffuse 23,rgb(20,20,20)
    sp = 1:GOSUB SPIN:gosub payout:sp = 0
      if bet > credits then bet = credits
  endif
if bet > credits then bet = credits
if credits > 2 and bet < 4 then set object diffuse 21,rgb(130,130,130):set object diffuse 22,rgb(130,130,130):set object diffuse 23,rgb(130,130,130)
if credits > 1 then set object diffuse 22,rgb(130,130,130):set object diffuse 23,rgb(130,130,130)
if credits = 1 then set object diffuse 23,rgb(130,130,130)
if credits > 0 and bet = 0 then bet = 1
if mouseclick() > 0 and button = 24 then end
if mouseclick() > 0 and button = 27 and credits < 200:credits = 200
  xrotate object 10,66:xrotate object 11,66:xrotate object 12,66
endif
`conrol chart
if mouseclick() > 0 and button = 26
  if scale = 0 then payout = 1
  if scale = 40 then payout = 0
endif
if payout = 1 and scale < 40
inc scale:scale sprite 1,scale:scale sprite 2,scale:scale sprite 3,scale:scale sprite 4,scale
if scale = 40 then payout = 2
endif
if payout = 0 and scale > 0
dec scale:scale sprite 1,scale:scale sprite 2,scale:scale sprite 3,scale:scale sprite 4,scale
if scale = 0 then payout = 2
endif
SYNC
LOOP
viewports:
`text 10,570,str$(screen fps())
text 25,4,"EXIT":text 25,34,"NEW":text 16,64,"CHART"
if credits = 0 and sp = 0
  ink rgb(255,255,255),0:text 214,40,"THANK YOU FOR PLAYING LIBERTY SEVENS":ink rgb(255,0,0),0
endif
text 250,347,"PAID":text 364,347,"CREDITS":text 486,347,"COINS BET"
if paid > 0 then text 230,375,str$(paid)
text 358,375,str$(credits):text 520,375,str$(bet)
return
SPIN:
do
`spin reels
  if go1 = 0 then xrotate object 10,wrapvalue(object angle x(10)-6)
  if go2 = 0 then xrotate object 11,wrapvalue(object angle x(11)-6)
  if go3 = 0 then xrotate object 12,wrapvalue(object angle x(12)-6)
`stop reels
  if timer() >= oldTime#+1200
    go1 = 1:hit = virtual(r1,1):hit1 = actual(hit):pay(1) = hit:xrotate object 10,hit1
  endif
  if timer() >= oldTime#+1800
    go2 = 1:hit = virtual(r2,2):hit1 = actual(hit):pay(2) = hit:xrotate object 11,hit1
  endif
  if timer() >= oldTime#+2300
    go3 = 1:hit = virtual(r3,3):hit1 = actual(hit):pay(3) = hit:xrotate object 12,hit1
    oldTime# = timer()
  endif
gosub viewports
sync
  if go3 = 1 then return
loop
return
payout:
`jackpot
if pay(1) = 11 and pay(2) = 11 and pay(3) = 11 then paid = 5000*bet:inc credits,5000*bet
`3 red sevens
if pay(1) = 1 or pay(1) = 13
  if pay(2) = 1 or pay(2) = 13
     if pay(3) = 1 or pay(3) = 13
        paid = 1000*bet:inc credits,1000*bet:nos = 3
endif:endif:endif
`3 white sevens
if pay(1) = 3 or pay(1) = 15
  if pay(2) = 3 or pay(2) = 15
     if pay(3) = 3 or pay(3) = 15
        paid = 200*bet:inc credits,200*bet
endif:endif:endif
`3 blue sevens
if pay(1) = 5 or pay(1) = 17
  if pay(2) = 5 or pay(2) = 17
     if pay(3) = 5 or pay(3) = 17
        paid = 100*bet:inc credits,100*bet
endif:endif:endif
`3 white bars
if pay(1) = 7 or pay(1) = 19
  if pay(2) = 7 or pay(2) = 19
     if pay(3) = 7 or pay(3) = 19
        paid = 50*bet:inc credits,50*bet
endif:endif:endif
`3 red bars
if pay(1) = 9 or pay(1) = 21
  if pay(2) = 9 or pay(2) = 21
     if pay(3) = 9 or pay(3) = 21
        paid = 25*bet:inc credits,25*bet
endif:endif:endif
`any 2 red sevens
  if nos < 3
    if pay(1) = 1 or pay(1) = 13 then inc nos,1
    if pay(2) = 1 or pay(2) = 13 then inc nos,1
    if pay(3) = 1 or pay(3) = 13 then inc nos,1
    if nos = 1 then paid = 2*bet:inc credits,2*bet
    if nos = 2 then paid = 10*bet:inc credits,10*bet
  endif
nos = 0
return
CREATE:
`backdrop
make object plain 8,256,206:texture object 8,2:position object 8,0,0,110
set object light 8,0
`wheel one
make object cylinder 10,10:scale object 10,400,100,400
position object 10,-12,0,16:texture object 10,1:zrotate object 10,90:fix object pivot 10
set object ambience 10,rgb(255,255,255)
`wheel two
make object cylinder 11,10:scale object 11,400,100,400:position object 11,0,0,16:zrotate object 11,90:fix object pivot 11:texture object 11,1
`wheel three
make object cylinder 12,10:scale object 12,400,100,400:position object 12,12,0,16:zrotate object 12,90:fix object pivot 12:texture object 12,1
`payline
make object plain 13,34,.3:color object 13,rgb(255,00,00):position object 13,0,0,-4.9
`left divider
make object box 14,2,30,30:color object 14,rgb(220,220,220):position object 14,-6,-8,10
set object ambience 14,rgb(230,230,230)
`right divider
make object box 15,2,30,30:color object 15,rgb(220,220,220):position object 15,6,-8,10
set object ambience 15,rgb(230,230,230)
`righ side
make object box 16,2,30,30:position object 16,18,0,10:color object 16,rgb(150,0,0)
set object ambience 16,rgb(255,0,0)
`left side
make object box 17,2,30,30:position object 17,-18,0,10:color object 17,rgb(150,0,0)
set object ambience 17,rgb(255,0,0)
`sign top
make object box 18,34,8,1:texture object 18,7:position object 18,0,11,-4.2
set object ambience 18,rgb(255,255,255)
`face bottom
make object box 19,35,8,1:texture object 19,6:position object 19,0,-11,-4
`tray
make object box 20,38,12,10:color object 20,rgb(0,0,120):position object 20,0,-20,-7:xrotate object 20,55
set object ambience 20,rgb(0,0,220)
`bet max button
make object box 21,6,6,1:texture object 21,5:position object 21,0,-16,-11:xrotate object 21,55
`bet one button
make object box 22,6,6,1:texture object 22,3:position object 22,-10,-16,-11:xrotate object 22,55
`spin reels button
make object box 23,6,6,1:texture object 23,4:position object 23,10,-16,-11:xrotate object 23,55
`exit button
make object box 24,7,2,1:color object 24,rgb(220,0,0):position object 24,-36,26,1
set object ambience 24,rgb(200,200,200)
`top
make object cylinder 25,2:color object 25,rgb(150,0,0):zrotate object 25,90:position object 25,0,15,-5:scale object 25,100,1900,100
set object ambience 25,rgb(255,0,0)
`pay chart button
make object box 26,7,2,1:color object 26,rgb(0,0,220):position object 26,-36,20,1
set object ambience 26,rgb(200,200,200)
`credit button
make object box 27,7,2,1:position object 27,-36,23,1
set object ambience 27,rgb(200,200,200)
`pay chart
sprite 1,3,410,8:rotate sprite 1,270:scale sprite 1,40:sprite 2,20,410,9:rotate sprite 2,270:scale sprite 2,40
sprite 3,37,410,10:rotate sprite 3,270:scale sprite 3,40:sprite 4,60,91,11:scale sprite 4,40
scale sprite 1,0:scale sprite 2,0:scale sprite 3,0:scale sprite 4,0
return
TEXTURES:
rem reel texture
create bitmap 1,1100,50
`color reels
ink rgb(170,170,170),0:for i = 0 to 1099:line i,0,i,1100:next i
`blue seven
ink rgb(0,0,220),0:for la=65 to 80:line la,11,la,39:next la:for la=0 to 45:line 64-la,28-la/3,64-la,38-la/4:next la
`1 red bar
ink rgb(220,0,0),0:for la=140 to 160:line la,11,la,39:next la
`white seven
ink rgb(255,255,255),0:for la=265 to 280:line la,11,la,39:next la:for la=0 to 45:line 264-la,28-la/3,264-la,38-la/4:next la
`wild
ink rgb(220,0,0),0:for la=361 to 373:line la,11,la,39:next la:ink rgb(255,255,255),0:for la=343 to 355:line la,11,la,39:next la:ink rgb(0,0,220),0:for la=325 to 337:line la,11,la,39:next la
`red seven
ink rgb(220,0,0),0:for la=465 to 480:line la,11,la,39:next la:for la=0 to 45:line 464-la,28-la/3,464-la,38-la/4:next la
`2 white bars
ink rgb(255,255,255),0:for la=555 to 567:line la,11,la,39:next la:for la=537 to 549:line la,11,la,39:next la
`blue seven
ink rgb(0,0,220),0:for la=665 to 680:line la,11,la,39:next la:for la=0 to 45:line 664-la,28-la/3,664-la,38-la/4:next la
`1 red bar
ink rgb(220,0,0),0:for la=740 to 760:line la,11,la,39:next la
`white seven
ink rgb(255,255,255),0:for la=865 to 880:line la,11,la,39:next la:for la=0 to 45:line 864-la,28-la/3,864-la,38-la/4:next la
`red seven
ink rgb(220,0,0),0:for la=965 to 980:line la,11,la,39:next la:for la=0 to 45:line 964-la,28-la/3,964-la,38-la/4:next la
`2 white bars
ink rgb(255,255,255),0:for la=1055 to 1067:line la,11,la,39:next la:for la=1037 to 1049:line la,11,la,39:next la:get image 1,0,0,1100,50:delete bitmap 1:set current bitmap 0
`backdrop
create bitmap 1,256,256:set current bitmap 1
for i = 0 to 127:ink rgb(255,i*2,i*2),0:line 0,i,256,i:next i
for i = 128 to 256:ink rgb(-i*2,-i*2,255),0:line 0,i,256,i:next i:ink rgb(255,255,255),0:line 0,128,256,128:
get image 2,0,0,256,256:delete bitmap 1:set current bitmap 0:cls
`viewport texture
create bitmap 1,256,256:set current bitmap 1:get image 6,0,0,256,256:delete bitmap 1:set current bitmap 0:cls
`sign texture
create bitmap 1,256,50:set current bitmap 1
ink rgb(230,230,230),0:for la=0 to 256:line la,0,la,50:next la
ink rgb(0,0,255),0:set text size 32:set text to bold:set text font "lucida calligraphy"
text 20,10,"Liberty":ink rgb(255,0,0),0:text 140,10,"Sevens"
get image 7,0,0,256,50:delete bitmap 1:set current bitmap 0:cls
`button textures
create bitmap 1,70,70:set current bitmap 1:set text font "verdana":set text size 14
ink rgb(200,200,200),0:for la=0 to 200:line la,0,la,200:next la:ink rgb(0,0,0),0:text 18,14,"BET":text 18,36,"ONE":get image 3,0,0,62,62:cls
ink rgb(200,200,200),0:for la=0 to 200:line la,0,la,200:next la:ink rgb(0,0,0),0:text 18,14,"MAX":text 18,36,"BET":get image 5,0,0,62,62:cls
ink rgb(200,200,200),0:for la=0 to 200:line la,0,la,200:next la:ink rgb(0,0,0),0:text 12,14,"SPIN":text 9,36,"REELS":get image 4,0,0,62,62:delete bitmap 1:set current bitmap 0
`pay chart
for ditto = 8 to 10
create bitmap 1,800,300
`color chart background
ink rgb(1,1,1),0:for i = 0 to 799:line i,0,i,800:next i
`wild
ink rgb(220,0,0),0:for la=761 to 773:line la,11,la,39:next la:ink rgb(255,255,255),0:for la=743 to 755:line la,11,la,39:next la:ink rgb(0,0,220),0:for la=725 to 737:line la,11,la,39:next la
`red seven
ink rgb(220,0,0),0:for la=665 to 680:line la,11,la,39:next la:for la=0 to 45:line 664-la,28-la/3,664-la,38-la/4:next la
`white seven
ink rgb(255,255,255),0:for la=565 to 580:line la,11,la,39:next la:for la=0 to 45:line 564-la,28-la/3,564-la,38-la/4:next la
`blue seven
ink rgb(0,0,220),0:for la=465 to 480:line la,11,la,39:next la:for la=0 to 45:line 464-la,28-la/3,464-la,38-la/4:next la
`2 white bars
ink rgb(255,255,255),0:for la=355 to 367:line la,11,la,39:next la:for la=337 to 349:line la,11,la,39:next la
`1 red bar
ink rgb(220,0,0),0:for la=240 to 260:line la,11,la,39:next la
if ditto < 10
`red seven
ink rgb(220,0,0),0:for la=165 to 180:line la,11,la,39:next la:for la=0 to 45:line 164-la,28-la/3,164-la,38-la/4:next la
endif
if ditto < 9
`red seven
ink rgb(220,0,0),0:for la=65 to 80:line la,11,la,39:next la:for la=0 to 45:line 64-la,28-la/3,64-la,38-la/4:next la
endif
get image ditto,0,0,800,300:delete bitmap 1:set current bitmap 0
next ditto
`pay chart text
create bitmap 1,305,800
`color chart back ground
ink rgb(1,1,1),0:for i = 0 to 799:line 0,i,800,i:next i
ink rgb(255,255,255),0:set text size 36
text 0,35, "Pays 5000 x Bet":text 0,135, "Pays 1000 x Bet":text 0,235, "Pays 200 x Bet":text 0,335, "Pays 100 x Bet"
text 0,435, "Pays 50 x Bet":text 0,535, "Pays 25 x Bet":text 0,635, "Any Pays 10 x Bet":text 0,735, "Any Pays 2 x Bet"
get image 11,0,0,305,800:delete bitmap 1:set current bitmap 0
return
Random:
ran = rnd(100000000):dom = ran/63:r1 = ran-(dom*63)+1:ran = rnd(100000000):dom = ran/63:r2 = ran-(dom*63)+1:ran = rnd(100000000):dom = ran/63:r3 = ran-(dom*63)+1
return
PAR:
restore PAR_CHART
  for reel = 1 to 3
    for vstop = 1 to 64
      read number:virtual(vstop,reel) = number
    next vstop
  next reel
 for tooth = 1 to 22
   read number:actual(tooth) = number
 next tooth
return
`**************************************************************************************
`first data set weights reels differently  (TIGHT)  Most realistic.
`second data set weights reels the same    (MEDIUM) eh.Win some Lose some.
`third data set weights reels the same     (LOOSE)  It`s fun to win.
`last data line is actual gears
PAR_CHART:
`data 3,11,17,1,19,12,22,4,5,15,10,13,5,3,14,21,19,7,10,16,11,15,1,4,21,12,9,20,10,17,21,7
`data 12,9,6,22,11,2,8,14,8,10,18,13,9,6,16,12,21,17,11,1,9,7,18,10,20,3,15,2,19,7,12,5
`data 12,5,19,10,14,2,11,8,16,18,4,5,12,9,1,17,7,11,20,8,3,17,6,16,10,21,2,9,13,21,6,15
`data 10,4,18,7,12,14,5,20,11,22,1,16,10,22,6,18,9,20,3,14,12,8,15,4,22,12,21,2,13,19,7,10
`data 8,14,2,17,12,7,16,10,20,12,5,4,10,19,12,3,10,21,9,18,6,16,10,1,22,7,12,2,17,8,14,4
`data 21,12,10,6,22,19,10,3,22,12,6,9,15,11,20,2,18,13,10,16,5,12,8,20,7,19,10,18,4,21,9,14
 
`data 7,14,10,3,5,17,8,1,12,10,19,14,5,22,2,12,9,15,4,20,11,13,17,7,1,19,3,21,10,22,6,16
`data 18,8,2,12,15,10,18,13,9,19,12,19,7,16,4,3,21,9,20,1,17,7,22,6,12,21,10,2,21,5,15,9
`data 7,14,10,3,5,17,8,1,12,10,19,14,5,22,2,12,9,15,4,20,11,13,17,7,1,19,3,21,10,22,6,16
`data 18,8,2,12,15,10,18,13,9,19,12,19,7,16,4,3,21,9,20,1,17,7,22,6,12,21,10,2,21,5,15,9
`data 7,14,10,3,5,17,8,1,12,10,19,14,5,22,2,12,9,15,4,20,11,13,17,7,1,19,3,21,10,22,6,16
`data 18,8,2,12,15,10,18,13,9,19,12,19,7,16,4,3,21,9,20,1,17,7,22,6,12,21,10,2,21,5,15,9
 
data 7,14,10,3,5,17,8,1,12,9,19,14,5,21,7,12,9,15,4,20,11,13,17,7,1,19,3,21,10,22,6,16
data 18,8,2,19,15,10,18,13,9,19,12,19,7,16,4,3,21,9,20,1,17,7,22,6,12,21,10,2,21,5,15,9
data 7,14,10,3,5,17,8,1,12,9,19,14,5,21,7,12,9,15,4,20,11,13,17,7,1,19,3,21,10,22,6,16
data 18,8,2,19,15,10,18,13,9,19,12,19,7,16,4,3,21,9,20,1,17,7,22,6,12,21,10,2,21,5,15,9
data 7,14,10,3,5,17,8,1,12,9,19,14,5,21,7,12,9,15,4,20,11,13,17,7,1,19,3,21,10,22,6,16
data 18,8,2,19,15,10,18,13,9,19,12,19,7,16,4,3,21,9,20,1,17,7,22,6,12,21,10,2,21,5,15,9
 
data 230,246,99,115,164,180,196,147,131,82,66,50,34,17,263,344,328,312,0,279,295,213