Tremble

BlitzPlus Forums/BlitzPlus Programming/Tremble

I'm a 2D guru!

Graphics 640,480,0,2 
SetBuffer BackBuffer()

xpos = 100 
ypos = 10 

hero = CreateImage(20,70) 
terra = CreateImage(640,480) 
SeedRnd MilliSecs() 

; make terrain
yline = 300 
For xx = 0 To 31 
y=Rand(-30,30) 
Line xx*20,yline,xx*20+20,yline+y 
Line xx*20,yline+1,xx*20+20,yline+y+1 
Line xx*20,yline+2,xx*20+20,yline+y+2 
yline = yline + y 
Next 
GrabImage terra,0,0 

; make Hero
Oval 50,50,20,20,0 
Rect 50,70,20,50,0 
GrabImage hero,50,50 

Repeat 
Cls 
Text 0,0,"SPACE BAR TO CHANGE COLLISION "+swap
If swap = 0
ypos = ypos + 2
;move up until the hero is out of the terrain
While ImagesCollide(hero,xpos,ypos,0,terra,0,0,0)
ypos = ypos - 1
Wend
EndIf 

If swap = 1
If ImagesCollide(hero,xpos,ypos,0,terra,0,0,0) 
ypos = ypos - 2
Else
ypos = ypos + 2
EndIf
EndIf 

If KeyHit(57)
If swap = 0
swap = 1
Else
swap = 0
EndIf
EndIf 

If KeyDown(205) Then xpos = xpos + 2 
If KeyDown(203) Then xpos = xpos - 2 
DrawImage hero,xpos,ypos 
DrawImage terra,0,0 
Flip 
Until KeyDown(1) 

End