Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

Ein Snake Klon (erste schritte)

Uploader:Mitgliedkoruso
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