Turing How to check if a object has moved in a certain area
Author |
Message |
Robotkubo
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
|
|