Moving Ball
Author |
Message |
upthescale
|
Posted: Wed May 24, 2006 6:34 pm Post subject: Moving Ball |
|
|
I would like to move a ball with te up and down key, while with the arrow keys, the line inside the ball will rotate 360 degrees, im sure u have seen this b4, and im sure u no wut i meen, if not here is the
code:
code: |
setscreen ("offscreenonly;graphics:700;600;nobuttonbar;position:truemiddle;center")
var x, y : int := 200
var aimx, aimy : int := 200
var chars : array char of boolean
aimx mod= 360
loop
colorback (7)
Input.KeyDown (chars)
cls
drawfilloval (x, y, 20, 20, red)
Draw.ThickLine (aimx, aimy, aimx, round (aimy) + 35, 4, red)
if chars (KEY_RIGHT_ARROW) then
Draw.ThickLine (aimx + round (cosd (x)), aimy - 170 + round (y), aimx, round (aimy) + 35, 4, red)
end if
delay (12)
View.Update
end loop
|
yopu prolly thinkng...wow that is off, yes it is because i dont really know wut to do, i would like it so wheni hit the left arrow key, or right, the line in the ball will spine.. lol so anyhelp wud be great thanks! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Wed May 24, 2006 7:20 pm Post subject: (No subject) |
|
|
Again, you'll need to know trigonometry.
code: |
if chars (KEY_RIGHT_ARROW) then
Draw.ThickLine (aimx + round (cosd (x)), aimy - 170 + round (y), aimx, round (aimy) + 35, 4, red)
end if
|
This makes no sense. Why would you draw a line between these two points when you press the right arrow key? I think what you want to do is decriment the angle.
To draw your line:
code: |
Draw.Line (round (ball.x), round (ball.y), round (ball.x + cosd (ball.angle) * line_length, round (ball.y + sind (ball.angle) * line_length), black)
|
You should be able to get it working with that. Please, give it a reasonable try. |
|
|
|
|
![](images/spacer.gif) |
|
|