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

Username:   Password: 
 RegisterRegister   
 Turing How to check if a object has moved in a certain area
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Robotkubo




PostPosted: Thu Mar 03, 2016 10:11 am   Post subject: Turing How to check if a object has moved in a certain area

Hey, Been working on a school project, and I need it so if the red box moves inside the long blue box while you press 'P'
"You Win" is put on the screen, I'm just stuck. Please help

var x, y : int
x := 50
y := 200
var chars : array char of boolean
loop

drawfillbox (100, 50, 150, 250, blue)
Input.KeyDown (chars)

if chars (KEY_UP_ARROW) then
y := y + 5
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
end if
if chars (KEY_DOWN_ARROW) then
y := y - 5
end if

drawfillbox (x, y, x + 20, y + 20, red)
delay (10)
cls


if x > 100 then
put "You win"
end if



if chars ('P') then
cls
delay (10)
put "You Win!"
delay (500)
end if


end loop
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Mar 03, 2016 7:34 pm   Post subject: RE:Turing How to check if a object has moved in a certain area

Look up collision detection. There are many tutorials on this site in the Turing Tutorials section.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: