TGC Codebase Backup



Stop and Go by Brux

2nd Jul 2013 9:04
Summary

Aim of the game to reach the sprite smile, using the arrow keys Every time I go wrong direction have to start over



Description

Aim of the game to reach the sprite smile, using the arrow keys
Every time I go wrong direction have to start over
To ease the path to the computer draw 'a black box in step
stored the way for when you have to start
After the fifth level a colored ball will fall 'from a position
random. If you get hit you will have to start over the level

At each end of a level you can decide whether to play again or quit. The level will be 'saved so that it starts at a later time

I created 20 levels and I left at the bottom of listing a routine if you want to create new levels if you will 'pleasure



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem ********** Stop and Go **************
Rem ******** By Ermanno  -ITALY- ********
Sync On
Sync Rate 60
Hide Mouse
Dim zona(30)
Dim lev(1)
Load image "balls/ball1.bmp",1
Load image "balls/ball2.bmp",2
Load Image "balls/ball3.bmp",3
Load Image "balls/ball4.bmp",4
Load image "balls/smile.bmp",10
Rem sounds
Load sound "giusto.wav",1
Load sound "errato.wav",2
Load sound "yes.wav",3
Load Sound "hit.wav",4

For s=1 To 100
 Set Sprite s,1,1
Next s
Rem To create new level remove the rem before the goto
Rem Goto create_new_level

Rem define some colors
bianco=Rgb(255,255,255)
rosso=Rgb(255,0,0)
giallo=Rgb(255,255,0)
arancio=Rgb(255,160,0)
grigio=Rgb(180,180,180)
verde=Rgb(0,208,140)
azzurro=Rgb(167,202,250)
Rem Draw screen
Make_Button(verde,1,1,639,240,verde,verde,1)
Make_Button(arancio,1,240,639,479,arancio,arancio,1)
Intesto(500,80,619,110,"Stop and GO",nero)
Intesto(500,120,619,150,"By Ermanno",bianco)
Intesto(500,160,619,190,"-ITALY-",nero)

Load Array "level",lev(0)
level=lev(1)
Rem Main
main:
Randomize Timer()
mosse=0
ricomincia:
posx=444
posy=358
x=0:y=0
ex=0:s5=0
Rem Draw grid
For a=1 To 5
 For b=1 To 6
  Make_Button(grigio,1+x,1+y,83+x,83+y,bianco,azzurro,1)
  Inc x,82
 Next b
 x=0
 Inc y,82
Next a

Make_Button(verde,1+x,1+y,83+x,83+y,bianco,azzurro,1)
Make_Button(verde,412,1+y,494,83+y,bianco,azzurro,1)

msg("Find The Right Way To Get The Icon Smile",arancio,10,435,484,460,nero,bianco,1,bianco)
Rem Load level
Inc level
If level>20
 Make_Button(arancio,100,200,340,300,bianco,nero,1)
 Intesto(100,185,340,285,"LEVELS COMPLETED!",nero)
 msg("Press Any Key To Exit",arancio,10,435,484,460,nero,bianco,1,nero)
 While Inkey$()="":Sync:Endwhile
 End
EndIf
Load array "levels/level"+Right$(Str$(level+100),2),zona(0)

Gosub check
frame=1
i=30
Do
 rand=Rnd(1000)
 If rand=10 Or rand=99 And ball=0
  If level>5
   ball=1
  Endif
 EndIf
 If ball=1 And lancio=0 Then lancio=1:zx=Rnd(400)+40:img=Rnd(1)+3
 If ball=1
  If yy<580
   Sprite 50,zx,yy,img
   Inc yy,40
   If Sprite Collision(100,50)
    Play Sound 4
    Sprite 100,posx,posy,2
    msg("Press Space Bar To Restart",arancio,10,435,484,460,nero,bianco,1,nero)
    While Inkey$()="":Sync:Endwhile
    Dec level
    Sprite 50,-100,-100,3
    go=1:Exit
   EndIf
  Endif
 EndIf
 If yy>580 And ball=1 Then yy=0:ball=0:lancio=0
 If Leftkey()>0 And posx>82
  posx=posx-82:Dec i:s1=0:s2=0
  Inc mosse
 EndIf
 Rem arrow keys
 If Rightkey()>0 And posx<444
  posx=posx+82:Inc i:s1=0:s2=0
  Inc mosse
 EndIf
 If Upkey()>0 And posy>82
  posy=posy-82:i=i-6:s1=0:s2=0
  Inc mosse
 EndIf
 If Downkey()>0 And posy<358
  posy=posy+82:i=i+6:s1=0:s2=0
  Inc mosse
 EndIf
 Repeat : sc=Scancode():Until sc=0
 Rem Check
 If zona(i)=0 And s1=0
  Play Sound 1
  frame=1:s1=1
  Make_Button(nero,posx-20,posy-20,posx+40,posy+40,nero,bianco,0)
  Ink verde,0:text posx-20,posy-20,"GO"
 EndIf
 If zona(i)=1 and s2=0
  Play Sound 2
  frame=2:s2=1
  Make_Button(rosso,posx-20,posy-20,posx+40,posy+40,nero,bianco,0)
  Ink bianco,0:text posx-20,posy-20,"STOP!"
 EndIf
 If zona(i)=5 and s5=0
  s5=1: Play Sound 3
  ex=1
 EndIf
 Rem Draw moves-level
 Make_Button(arancio,500,350,630,400,rosso,rosso,1)
 Intesto(500,335,630,385,"Moves:"+Right$(Str$(mosse+10000),4),nero)
 Make_Button(verde,500,420,630,470,rosso,rosso,1)
 Intesto(500,405,630,455,"Level:"+Right$(Str$(level+100),2),nero)
 Sprite 100,posx,posy,frame
 If ex=1 Then Exit
 If frame=2
  Gosub restart
  msg("Press Space Bar To Restart",arancio,10,435,484,460,nero,bianco,1,nero)
  While Inkey$()="":Sync:Endwhile
  msg("Find The Right Way To Get The Icon Smile",arancio,10,435,484,460,nero,bianco,1,nero)
  Exit
 EndIf
 Sync
Loop
If go=1 Then go=0:Goto ricomincia
Rem Next level
msg("Press Bar To Continue - C To End",arancio,10,435,484,460,nero,bianco,1,nero)
a$=""
While a$=""
 a$=Inkey$()
 jasc=Asc(a$)
 Sync
EndWhile
If jasc=99
 lev(1)=level-1
 Save Array "level",lev(0)
 End
EndIf
Goto main
End

restart:
If ball=1 Then Sprite 50,-100,-100,3
ball=0
frame=1
i=30
go=1
Dec level
Return

check:
x=1:y=1
For c=1 to 30
If zona(c)=5
 Sprite 99,20+x,20+y,10
EndIf
Inc x,83
If x>492
 x=1
 Inc y,83
EndIf
Next c
Return

Function msg(stringa$,co1,x,y,x1,y1,co2,co3,shadow,co4)
Make_Button(co1,x,y,x1,y1,co2,co3,shadow)
intesto(x,y-15,x1,y1-15,stringa$,co4)
EndFunction

Function Make_Button(co1,Left,Top,Right,Bottom,co2,co3,shadow)
 Ink 0,0
 If shadow=1 Then Box left,top,right,bottom
 If shadow=2 Then Box left-2,top-2,right+2,bottom+2
 Ink co1,co1
 Box left+1,top+1,right-1,bottom-1
 Ink co2,co2
 Line Left,Bottom,Left,Top : Line Left,Top,Right,Top
 Ink co3,co3
 Line Right,Top,Right,Bottom : Line Right,Bottom,Left,Bottom
EndFunction


Function Intesto(x,y,x1,y1,txt$,ct)
 Ink ct,ct
 c=((x1-x)/2)-((8*Len(txt$))/2)
 Text x+c,y1-((y1-y)/2)+8,txt$
EndFunction


create_new_level:
Rem To create new level you can use this routine
x=0:y=0
Restore
For c=1 to 30
read zona(c)
Inc x,82
If x>492
 x=0
 Inc y,82
EndIf
Next c
Rem Change the level number and save (max 99)
level=20
Save array "levels/level"+Right$(Str$(level+100),2),zona(0)
End

Rem Change data how you like
data 1,0,0,0,0,0
data 0,0,1,1,1,0
data 0,1,5,1,1,0
data 0,1,0,1,1,0
data 0,0,0,1,1,0