Multiple Loops
Author |
Message |
bvbjules13

|
Posted: Wed Nov 21, 2012 11:10 pm Post subject: Multiple Loops |
|
|
What is it you are trying to achieve?
im trying to make an animation run at the same time as i run another figure which is controlled by the up and down arrows
What is the problem you are having?
i have it on loop and will only run one thing at a time and i am told it is bad to use process
Describe what you have tried to solve this problem
i have attemted process and messed up the program, i got flickering and the screen got cleared
this is basically what i am doing, just simplified to circles instead, so far i only have two loops but running one after the other
Turing: |
View.Set ("graphics: 600,400, offscreenonly")
var x : int := 50
var key : array char of boolean
var y : int := 200
var i : int := 200
loop
Input.KeyDown (key )
Draw.Fill (i, y, 0, 0)
Draw.FillOval (i, y, 50, 50, red)
if key (KEY_RIGHT_ARROW) then
if i not= 550 then
i := i + 1
end if
elsif key (KEY_LEFT_ARROW) then
if i not= 50 then
i := i - 1
end if
elsif key (KEY_UP_ARROW) then
if y not= 350 then
y := y + 1
end if
elsif key (KEY_DOWN_ARROW) then
if y not= 50 then
y := y - 1
end if
end if
View.Update
end loop
loop
x := x + 1
Time.Delay (10)
Draw.Fill (x - 51, 50, 0, 0)
Draw.FillOval (x, 50, 50, 50, 16)
View.UpdateArea (0, 0, maxx, maxy)
if x = 651 then
Draw.Fill (x - 51, 50, 0, 0)
x := 50
end if
end loop
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Insectoid

|
Posted: Wed Nov 21, 2012 11:22 pm Post subject: RE:Multiple Loops |
|
|
You need to put everything in the same loop. Move your first oval a single frame, then move your second oval a single frame, then get your input. You don't necessarily have to do it in that order, but it all needs to be in the same loop. |
|
|
|
|
 |
Panphobia

|
Posted: Wed Nov 21, 2012 11:45 pm Post subject: RE:Multiple Loops |
|
|
think about it, one cannot run while the other is in a loop completely not connected to itself, how can you expect two things to move at the same time if they are in two different loops, only one of those loops can loop at a time  |
|
|
|
|
 |
|
|