Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Snake Wall Collision
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mr. T




PostPosted: Fri Mar 18, 2005 10:10 pm   Post subject: Snake Wall Collision

I am trying to get my program to exit when the snake hits the black wall.
Can someone explain what I'm doing wrong in my whatdotcolour. thanks
--------------------------------------
%variable declaration
View.Set ("graphics:400;300")
var box1 : int := 0
var box2 := maxy
var box3 := maxx
var box4 := 0
var col : int := 31
var countdown : int := 6
var ballx1 : int := 200
var bally1 : int := 150
var ballsize : int := 5
var move, move2, move3, move4 := false
var key : array char of boolean
move3 := true %starting direction of snake

%gives time for user to get ready
loop
locate (9, 20)
put "Starting in...", countdown - 1
delay (300)
countdown := countdown - 1
cls
exit when countdown = 0
end loop

%ball movement
loop
drawbox (box1, box2, box3, box4, 7)
drawfilloval (ballx1, bally1, ballsize, ballsize, col)
if move then
bally1 += 5
elsif move2 then
bally1 -= 5
elsif move3 then
ballx1 += 5
elsif move4 then
ballx1 -= 5
end if
Input.KeyDown (key)
if key (KEY_UP_ARROW) then %if up arrow is pressed
move2 := false
move3 := false
move4 := false
move := true
elsif key (KEY_DOWN_ARROW) then %if down arrow is pressed
move := false
move3 := false
move4 := false
move2 := true
elsif key (KEY_RIGHT_ARROW) then %if right arrow is pressed
move := false
move2 := false
move4 := false
move3 := true
elsif key (KEY_LEFT_ARROW) then %if left arrow is pressed
move := false
move2 := false
move4 := true
move3 := false
end if
drawfilloval (ballx1, bally1, ballsize, ballsize, 12) %deletes the tail
delay (100)
if whatdotcolour (ballx1, bally1) = black then
exit
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: