Done, lol. Now on to my next 'small' project. Seriously, setting the simplest goals, I think I might go far with this indie stuff, lol.
Source Code(Comments and suggestions wanted):
Rem Project: Blast Snake
Rem Setup Display
Set Display Mode 800,600,16 : Set Window On
Set Window Layout 3,1,0 : Set Window Title "Blast Snake V1.0"
Sync Rate 0 : Sync On : Sync Rate 30
Hide Mouse : Autocam Off : Backdrop On : Color Backdrop 0
Rem Define Variables
Score#=0
S_dir#=0
S_dly#=10
Tail#=0
Fruit#=RND(2)
Set Text Size 36
Rem Setup Arena
Rem Top Bar
Make Object Box 1,800,20,20 : Color Object 1,RGB(20,200,20)
Position Object 1,0,0,290
Rem Lower Bar
Make Object Box 2,800,20,20 : Color Object 2,RGB(20,200,20)
Position Object 2,0,0,-290
Rem Right Bar
Make Object Box 3,20,20,600 : Color Object 3,RGB(20,200,20)
Position Object 3,390,0,0
Rem Left Bar
Make Object Box 4,20,20,600 : Color Object 4,RGB(20,200,20)
Position Object 4,-390,0,0
Rem Make Starting Snake Object
Make Object Cube 100,20 : Color Object 100,RGB(20,200,20)
Position Object 100,0,0,0
Rem Make rnd fruit and placement
Make Object Cube 5,20 : Position Object 5,100,0,100
If Fruit#=0 then Color Object 5,RGB(200,20,20)
If Fruit#=1 then Color Object 5,RGB(200,20,20)
If Fruit#=2 then COlor Object 5,RGB(200,200,20)
Rem Position Camera
Position Camera 0,650,0 : Point Camera 0,0,0
Rem load sounds
Load Sound "snake.wav",1
Rem Main Loop
Do
Rem Print Score
Center Text 400,20,Str$(Score#)
Rem Snake Collision with Arena
If Object Position z(100)>270 then Death#=1
If Object Position z(100)<-270 then Death#=1
If Object Position x(100)>370 then Death#=1
If Object Position x(100)<-370 then Death#=1
Rem Eat Fruit, update score and fruit
If Object Position x(100) > Object Position x(5)-10
If Object Position x(100) < Object Position x(5)+10
If Object Position z(100) > Object Position z(5)-10
If Object POsition z(100) < Object Position z(5)+10
Play Sound 1
If Fruit#=0 then Score#=Score#+10
If Fruit#=1 then Score#=Score#+10
If Fruit#=2 then Score#=Score#+20
Position Object 5,(RND(36)-18)*20,0,(RND(24)-12)*20
Rem check position and reposition if neccessary
check:
For x = 0 to 100
If Object Exist(x+100)
If Object Position x(5)=Object Position x(x+100)=1
If Object Position z(5)=Object Position z(x+100)=1
Position Object 5,(RND(36)-18)*20,0,(RND(24)-12)*20
Goto check
Endif
Endif
Endif
next x
Fruit#=RND(2)
If Fruit#=0 then Color Object 5,RGB(200,20,20)
If Fruit#=1 then Color Object 5,RGB(200,20,20)
If Fruit#=2 then COlor Object 5,RGB(200,200,20)
Tail#=Tail#+1
If Tail# < 101
Make Object Cube Tail#+100,20
Color Object Tail#+100,RGB(25,200,25)
Position Object Tail#+100,object position x(100),0,object position z(100)
Endif
Endif
Endif
Endif
Endif
Rem Delay Movement
dly#=dly#+1
If dly#=S_dly#
dly#=0
Rem Update Snake Tail
for t = 100 to 1 step -1
If Object Exist(t+100) = 1
Position Object t+100,Object Position x(t+99),0,Object Position z(t+99)
Endif
next t
If S_dir#=1 then Move Object 100,20
If S_dir#=2 then Move Object Right 100,20
If S_dir#=3 then Move Object 100,-20
If S_dir#=4 then Move Object Left 100,20
Rem Snake Collision With Himself
For k = 1 to 100
If Object Exist(k+100)
If Object Position x(100)=Object Position x(k+100)
If Object Position z(100)=Object Position z(k+100)
Death#=1
Endif
Endif
Endif
Next k
Endif
Rem Snake Movement
If Upkey()=1 then S_dir#=1
If Rightkey()=1 then S_dir#=2
If Downkey()=1 then S_dir#=3
If Leftkey()=1 then S_dir#=4
Rem Death Code
Death:
If Death#=1
dk=dk+1
Center Text 400,270,"Your Score Is:"
Center Text 400,330,STR$(Score#)
if dk=50
Score#=0
Death#=0
dk=0
S_dir#=0
Tail#=0
Position Object 100,0,0,0
for v = 1 to 100
if Object Exist(v+100) then Delete Object v+100
next v
Position Object 5,100,0,100 : Fruit#=RND(2)
If Fruit#=0 then Color Object 5,RGB(200,20,20)
If Fruit#=1 then Color Object 5,RGB(200,20,20)
If Fruit#=2 then COlor Object 5,RGB(200,200,20)
else
Sync
Goto Death
endif
Endif
sync
Loop
BWM
"I wish I was a wizard, becuase then I could wave my wand and perfect code would just appear."