fb:porticula NoPaste
Ein Snake Klon (erste schritte)
Uploader: | koruso |
Datum/Zeit: | 20.12.2013 01:34:58 |
'(1)=Escape
'(72)=Up
'(75)=Left
'(77)=Right
'(80)=Down
Declare Sub setPlayer
Declare Sub mainLoop
Declare Sub mainScreen
Declare Sub spawnBeings
Dim Shared playerSize As Integer
Dim Shared appleSize As Integer
Screenres 400,400,16
Setmouse 0,0,0
Type objectType
x As Single
y As Single
speed As Single
End Type
Dim Shared player As objectType
Dim Shared apple As objectType
mainScreen
End
'mainmodule ends here!!!
'*************************
Sub mainLoop
Do
Cls
Screenlock
For appleSize=0 to 1
Line(apple.x,apple.y)-(apple.x+8,apple.y+8),&HFF0000,BF
Next
For playerSize=1 to 9999
Line(player.x,player.y)-(player.x+8,player.y+8),&H00FF00,bf 'how to set this as playerSize? *
Next
Screenunlock
Screensync
setPlayer
Sleep 1
Loop Until Multikey(1)
End Sub
Sub mainScreen
'text goes here later!!!
spawnBeings
mainLoop
End Sub
Sub spawnBeings
Randomize Timer
player.x=Int(Rnd*390)+1
player.y=Int(Rnd*390)+1
player.speed=1
apple.x=Int(Rnd*390)+1
apple.y=Int(Rnd*390)+1
End Sub
Sub setPlayer
If Multikey(77) then
player.x=player.x+player.speed
End if
If Multikey(75) then
player.x=player.x-player.speed
End if
If Multikey(80) then
player.y=player.y+player.speed
End if
If Multikey(72) then
player.y=player.y-player.speed
End if
If(player.x-apple.x)*(player.x-apple.x)+(player.y-apple.y)*(player.y-apple.y)<25 then'accuracy of collision
playerSize=+1 '* so i can calculate that here
apple.x=Int(Rnd*390)+1
apple.y=Int(Rnd*390)+1
End if
If player.x<0 then
Print"GAME OVER!"
player.x=0
sleep
End if
If player.x>391 then
Print"GAME OVER!"
player.x=391
sleep
End if
If player.y<0 then
Print"GAME OVER!"
player.y=0
sleep
End if
If player.y>391 then
Print"GAME OVER!"
player.y=391
sleep
End if
End Sub