Rotaing Planets
Author |
Message |
sammi
|
Posted: Tue Oct 18, 2011 4:35 pm Post subject: Rotaing Planets |
|
|
What is it you are trying to achieve?
< When i hit an arrow key I need to make both circles move in whatever direction that the little ball is pointing.>
What is the problem you are having?
<Not sure what kind of changes i need to make to my program>
Describe what you have tried to solve this problem
<Different combonations of adding and subtracting variables>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
<View.Set ("graphics,offscreenonly")
var x, y : int
x := maxx div 2
y := maxy div 2
var xDist, yDist : real %width/height of the circle
var distance : int := 20 %
var angle : int := 30 %where the little goes around the big circle
var hyp : int := 60
var keys : array char of boolean
loop
Input.KeyDown (keys )
%if keys (KEY_LEFT_ARROW) = true then
% angle := angle + 1
%end if
%
% if keys (KEY_RIGHT_ARROW) = true then
% angle := angle - 1
% end if
if keys (KEY_UP_ARROW) = true then % make rotation farther away
hyp := hyp + 1
end if
if keys (KEY_DOWN_ARROW) = true then %make rotation smaller
hyp := hyp - 1
end if
if keys ('a') = true then % move both planets left
x := x - 1
end if
if keys ('d') = true then % move both planets right
x := x + 1
end if
if keys ('s') = true then % move both planets down
y := y - 1
end if
if keys ('w') then % move both planets up
y := y + 1
end if
angle := angle - 1
% trig calculations
xDist := cosd (angle ) * hyp
yDist := sind (angle ) * hyp
Draw.FillOval (x, y, 40, 40, 43)
Draw.FillOval (round (x + xDist ), round (y + yDist ), 5, 5, 26)
put angle % show angle on the top corner of the screen
View.Update ()
delay (5)
cls ()
end loop>
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Oct 18, 2011 4:58 pm Post subject: Re: Rotaing Planets |
|
|
sammi @ Tue Oct 18, 2011 4:35 pm wrote: Describe what you have tried to solve this problem[/size]
Different combonations of adding and subtracting variables
I don't think randomly throwing commands to see if anything sticks is ever an appropriate approach. You'd need to simply sit down and figure out the math required for the movement. Don't be afraid to do calculations on paper first -- it's a great tool for figuring this kind of things out. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Zren
|
Posted: Tue Oct 18, 2011 4:58 pm Post subject: RE:Rotaing Planets |
|
|
Basically you want the sun to follow the asteroid. Then have the asteroid move in the same direction the sun moved.
This should help:
http://compsci.ca/v3/viewtopic.php?t=17607 |
|
|
|
|
|
Aange10
|
Posted: Tue Oct 18, 2011 4:59 pm Post subject: RE:Rotaing Planets |
|
|
Quote: When i hit an arrow key I need to make both circles move in whatever direction that the little ball is pointing.
Well you title says rotating, and considering wasd moves the planets just fine, I'm going to assume that you mean rotating them in place.
Considering your object isn't 3d, I think you mean having a sprite sheet. That topic was discussed here if you'd like to view it.
If that doesn't help, let me know and I'll try and help you more specifically.
ALSO: I'm pretty sure the angle of my ball isn't -35,632 (: |
|
|
|
|
|
Zren
|
Posted: Tue Oct 18, 2011 5:01 pm Post subject: RE:Rotaing Planets |
|
|
D:
I was gonna redact/edit the link out till he attempted the math. So sir sammi, I trust in your honour to attempt drawing it out first. |
|
|
|
|
|
Aange10
|
Posted: Tue Oct 18, 2011 5:06 pm Post subject: RE:Rotaing Planets |
|
|
Hmm, sorry, Sammi, I may have misunderstood your question |
|
|
|
|
|
sammi
|
Posted: Tue Oct 18, 2011 5:24 pm Post subject: RE:Rotaing Planets |
|
|
first of all lol im a girl not a sir haha (dont worry no offense taken). Secondly i want both planets to stay together as they move around the screen. |
|
|
|
|
|
Aange10
|
Posted: Tue Oct 18, 2011 5:57 pm Post subject: Re: RE:Rotaing Planets |
|
|
sammi @ 18/10/2011, 4:24 pm wrote: first of all lol im a girl not a sir haha (dont worry no offense taken). Secondly i want both planets to stay together as they move around the screen.
I believe W A S D already does that...? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
sammi
|
Posted: Tue Oct 18, 2011 5:59 pm Post subject: RE:Rotaing Planets |
|
|
kay i'll look that one up |
|
|
|
|
|
Aange10
|
Posted: Tue Oct 18, 2011 6:02 pm Post subject: Re: RE:Rotaing Planets |
|
|
sammi @ 18/10/2011, 4:59 pm wrote: kay i'll look that one up
Well, what do you mean? It's already in the program..? |
|
|
|
|
|
sammi
|
Posted: Tue Oct 18, 2011 6:46 pm Post subject: RE:Rotaing Planets |
|
|
i have no idea......i couldnt find anything useful in the other posts and i couldnt find anything on google
do u mind telling me what WASD is? |
|
|
|
|
|
Beastinonyou
|
Posted: Tue Oct 18, 2011 7:02 pm Post subject: Re: Rotaing Planets |
|
|
He's referring to the keys, "W, A, S, D"
Just like in games, (W) is Up, (A) is Left, (S) is Down, (D) is Right.
____
Now, Maybe you should be Re-Phrasing your Question, because it's quite difficult to determine what Exactly you wish to be done.
Title says Rotation, and apparently it involves planets, a bigger one, and a smaller one.
when you go use the keys WASD, you move both of the planets accordingly (Up, down, left or right), and when you use the Up / Down arrow, you make rotation around a specific point larger / smaller (maybe resembles gravitational force of the larger planet the smaller is revolving around.)
So, I'm assuming you want a small planet (circle) to "Orbit" around the larger planet (Large Circle).
If that is what you need, I suggest first finding a way to just get the smaller circle to revolve around the object, and you should be able to easily find how to increase the radius of the travel pattern |
|
|
|
|
|
|
|