how to move ball diagonally
Author |
Message |
rcmp1234
|
Posted: Tue Apr 08, 2008 6:27 pm Post subject: how to move ball diagonally |
|
|
Hey guys, im trying to write a program. It is a simple program but I'm a newbie in Turing. Anyways, I am supposed to draw an oval at the bottom left of the window. it is supposed to move from the bottom to the top then back down. Once it gets to the bottom it has to move diagonally to the top right corner of the window. Then, it has to drop vretically to the bottom of the window again (top right corner)
I'm not sure how to move it diagonally...but heres what I got so far...please help
Thanks
Turing: |
for y : 1 .. maxy - 10
drawoval (10, y, 10, 10, black)
delay (2)
cls
end for
for decreasing y : maxy - 10 .. 1
drawoval (10, y, 10, 10, black)
delay (2)
cls
end for
for y : 1 .. maxy - 10
drawoval (y, y, 10, 10, black)
delay (2)
cls
end for
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
BigBear
|
Posted: Tue Apr 08, 2008 6:52 pm Post subject: Re: how to move ball diagonally |
|
|
This is good I am guessing you are asking how do I put the circle in the top. Well you have the idea to move diagonaly you can easily change the size of the run window. By adding this to the beggining of the code.
Also to remove the flashing o the circle adding offscreenonly to that same line
Turing: | setscreen ("graphics:500, 500, offscreenonly") |
And adding View.Update after you drawoval
Turing: | setscreen ("graphics:500, 500, offscreenonly")
for y : 1 .. maxy - 10
drawoval (10, y, 10, 10, black)
View.Update
cls
end for
for decreasing y : maxy - 10 .. 1
drawoval (10, y, 10, 10, black)
View.Update
cls
end for
for y : 1 .. maxy - 10
drawoval (y, y, 10, 10, black)
View.Update
cls
end for
|
|
|
|
|
|
|
Nick
|
Posted: Tue Apr 08, 2008 6:56 pm Post subject: RE:how to move ball diagonally |
|
|
rcmp, you wouldn't happen to have Mr. Holmes as a teacher, I had the exact same assignment last year :S |
|
|
|
|
|
rcmp1234
|
Posted: Tue Apr 08, 2008 6:57 pm Post subject: RE:how to move ball diagonally |
|
|
Thanks Big Bear, that did the trick!
and no, nick my teacher is not Mr. Holmes...lol |
|
|
|
|
|
Nick
|
Posted: Tue Apr 08, 2008 7:00 pm Post subject: RE:how to move ball diagonally |
|
|
an assignment as weird as that would be given out by anyone other than him, guess I was wrong |
|
|
|
|
|
BigBear
|
Posted: Tue Apr 08, 2008 7:05 pm Post subject: Re: how to move ball diagonally |
|
|
Or this teacher has changed his identity. eh Nick it is a possibility? |
|
|
|
|
|
Nick
|
Posted: Tue Apr 08, 2008 7:16 pm Post subject: RE:how to move ball diagonally |
|
|
no I got the same teacher this year |
|
|
|
|
|
BigBear
|
Posted: Tue Apr 08, 2008 7:19 pm Post subject: Re: how to move ball diagonally |
|
|
Umm ok but I meant because you changed your identity to protect your nemesis from finding you. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
A.J
|
Posted: Tue Apr 08, 2008 10:43 pm Post subject: Re: how to move ball diagonally |
|
|
if u want to learn more about movement in particular directions, try looking at examples of programs that uses them, like this one:
Turing: |
View.Set ("offscreenonly")
var x := maxx div 2
var y := maxy div 2
var r := 5
var keys : array char of boolean
loop
Input.KeyDown (keys )
if keys (KEY_UP_ARROW) then
y + = 1
end if
if keys (KEY_DOWN_ARROW) then
y - = 1
end if
if keys (KEY_LEFT_ARROW) then
x - = 1
end if
if keys (KEY_RIGHT_ARROW) then
x + = 1
end if
if keys ('w') then
r + = 1
end if
if keys ('q') then
r - = 1
end if
if keys (chr (32)) then
cls
end if
var c := Rand.Int (1, 255)
if keys ('d') then
drawoval (x, y, r, r, white)
elsif keys ('a') then
drawfilloval (x, y, r, r, c )
else
drawoval (x, y, r, r, c )
end if
View.Update
delay (5)
end loop
|
|
|
|
|
|
|
|
|