Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Delay Function and Window
Author Message
Omster

Posted: Fri Jun 09, 2017 1:27 pm   Post subject: Delay Function and Window

Hello,
How would you set speeds to 2 different objects? I am trying to make a user-controlled circle animation go faster than another randomly moving circle animation, but the delay function applies to all above it.
Also, how would I set limits to the x-and-y-coordinates of my circles to prevent them from going off the page?
I am using Turing 4.1.1.
The code is below.
Thanks

var x, y : int
x := 100
y := 100
var obstx, obsty : int
obstx := 200
obsty := 100
var obstx2, obsty2 : int
obstx2 := 245
obsty2 := 295
var chars: array char of boolean
loop
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
y := y + 2
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 2
end if
if chars (KEY_LEFT_ARROW) then
x := x - 2
end if
if chars (KEY_DOWN_ARROW) then
y := y - 2
end if
cls
drawfilloval (x, y, 10, 10, blue)
drawfilloval (obstx, obsty, 20, 20, red)
drawfilloval (obstx2, obsty2, 20, 20, red)
obstx := obstx + Rand.Int (-10, 10)
obsty := obsty + Rand.Int (-10, 10)
obstx2 := obstx2 + Rand.Int (-10, 10)
obsty2 := obsty2 + Rand.Int (-10, 10)
if x >= obstx - 20 & x <= obstx + 20 & y >= obsty2 - 20 & y <= obsty2 + 20 then
put "Game Over!"
exit
end if
if x >= obstx - 20 & x <= obstx + 20 & y >= obsty - 20 & y <= obsty + 20 then
put "Game Over!"
exit
end if

end loop