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

Username:   Password: 
 RegisterRegister   
 Delay Function and Window
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Omster




PostPosted: 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
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: