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

Insectoid

Posted: Sat Jun 10, 2017 6:51 am   Post subject: RE:Delay Function and Window

How about instead of changing the delay, you change the number of pixels you move per delay?
Omster

Posted: Sat Jun 10, 2017 7:40 am   Post subject: Re: Delay Function and Window

How would I do that?
And also how would I stop the circles from going off the screen?
Insectoid

Posted: Sat Jun 10, 2017 7:43 am   Post subject: RE:Delay Function and Window

Instead of moving 2 pixels at a time, do 4 pixels at a time. Now your circle moves twice as fast.

Can you think of a way to check if the circle is at the edge of the screen?
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 4 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: