Jump to content


Photo

rotation to time


  • Please log in to reply
9 replies to this topic

#1 flxp

flxp

    GMC Member

  • GMC Member
  • 325 posts
  • Version:GM8

Posted 30 May 2012 - 08:27 AM

i need to rotate an object 360 degrees per 86400 seconds...
ofcourse i can nerf the total time, but i can't figure out the equation..

[EDIT]
sorry i didn't explain myself well...

i made a planet object that i needed an equation to make it spin a full rotation in a certain amount of seconds.
in this case i wanted to test it at realistic time (1 day = 86400 seconds (one rotation on earth))

Edited by flxp, 30 May 2012 - 09:03 AM.

  • 0

#2 Jack Indie Box

Jack Indie Box

    GMC Member

  • GMC Member
  • 1489 posts
  • Version:GM:Studio

Posted 30 May 2012 - 08:37 AM

so 360degress=86400s?

if so

deg=86400/360;
angle=time/deg;

you need more info in your question if this wasnt what you needed

Edited by Jack Indie Box, 30 May 2012 - 08:39 AM.

  • 0

#3 flxp

flxp

    GMC Member

  • GMC Member
  • 325 posts
  • Version:GM8

Posted 30 May 2012 - 08:44 AM

what would i put for the time, cause i cant get this working...
  • 0

#4 Jack Indie Box

Jack Indie Box

    GMC Member

  • GMC Member
  • 1489 posts
  • Version:GM:Studio

Posted 30 May 2012 - 08:54 AM

as i said explain your question better you didnt give us any variables or your real situation.

this code if you use time as a value between 0-86400s would be a rotation between 0-360 and anything more would start the next rotation

also if rotation is in the wrong direction for you put a negative infront of time/deg

time was me assuming your using time... you didnt explain anything, just set time to the "rotation" amount you want in seconds relative to 86400s

please explain yourself, if you dont understand
  • 1

#5 flxp

flxp

    GMC Member

  • GMC Member
  • 325 posts
  • Version:GM8

Posted 31 May 2012 - 09:30 AM

what i want is the equation for this scenerio:


my fps is at 30
i want my image_angle to reach 360 from 0 in 84600 seconds
i know i would have to put these numbers in the equation..

84600, room_speed, 360
but i cannot make an equation :o
  • 0

#6 Pixel8ed72

Pixel8ed72

    Musical Brony

  • GMC Member
  • 408 posts
  • Version:Unknown

Posted 31 May 2012 - 09:55 AM

image_angle += 360/84600

I'd think that'd work.
That would go in the step event.
:)

Sorry, no.
The step event might speed that up.
:/

You could repeat an alarm:
CREATE
alarm[0] = 30 //Because this is your roomspeed, you could also use 1*room_speed

ALARM 0
image_angle += 360/84600
alarm[0] = 1*room_speed //Or 30, whichever you want :)

Edited by TerraCrafter, 31 May 2012 - 09:58 AM.

  • 0

#7 ralf2000

ralf2000

    GMC Member

  • New Member
  • 295 posts
  • Version:GM8

Posted 31 May 2012 - 09:56 AM

image_angle += 360/84600

I'd think that'd work.
That would go in the step event.
:)


No that wouldn't be accurate - there's 30 steps in a second, so I think you'd need to do something like this:

image_angle+=360/(roomspeed*84600)

roomspeed I think is a variable, but if not just replace it with whatever you're room speed is set at (default 30). That should give you accurate timings

Edited by ralf2000, 31 May 2012 - 09:57 AM.

  • 0

#8 Pixel8ed72

Pixel8ed72

    Musical Brony

  • GMC Member
  • 408 posts
  • Version:Unknown

Posted 31 May 2012 - 10:00 AM

Yeah, I realized that after posting.
:P

And the variable is room_speed if I'm correct.
:)
  • 0

#9 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 31 May 2012 - 10:07 AM

what i want is the equation for this scenerio:


my fps is at 30
i want my image_angle to reach 360 from 0 in 84600 seconds
i know i would have to put these numbers in the equation..

84600, room_speed, 360
but i cannot make an equation :o

you have what you have! :P
in create event:
alarm [0] = 1*room_speed
//variables
seconds = 0
minutes = 0
hours = 0
//angles
angle1 = 90
angle2 = 90
angle3 = 90
in alarm 0 event:
seconds += 1;
alarm [0] = 1*room_speed //let's keep on repeating it
in step event of clock object:
if (time == 60)
{
	seconds = 0;
	minutes +=1;
	if (minutes == 60)
	{
 		minutes = 0;
 		hours += 1;
 		if (hours == 24)
 		{
          	hours = 0
 		}
	}
}
//this is for getting the angles for a fancy hand clock
angle1 = (seconds * 6)+90
angle2 = (minutes*6)+90
angle3 = (hours*15)+90
that should give you hours minutes and seconds!
now to put the into some fancy hand clock! :D
for the draw event:
draw_sprite(spr_clock_face,-1,x,y);
draw_sprite_ext(spr_clock_hand_seconds,-1,x,y,1,1,angle1,c_white,1)
draw_sprite_ext(spr_clock_hand_minutes,-1,x,y,1,1,angle2,c_white,1)
draw_sprite_ext(spr_clock_hand_hours,-1,x,y,1,1,angle3,c_white,1)
done! :D
EDIT:
Fixed the alarm 0 event. :P
EDIT2:
I'm too sleepy to read correctly. Posted Image
anyways I'll give you the answer I think. Posted Image

in the create event:
alarm [0] = 1*room_speed
//variables
seconds = 0
angle1 = 0
in alarm 0 event:
seconds += 1;
alarm [0] = 1*room_speed //let's keep on repeating it
in the step event:
if (seconds == 60)
{
	seconds = 0;
}
//this is for getting the angle
angle1 = (seconds * 6)
in the draw event:
draw_sprite_ext(spr_planet,-1,x,y,1,1,angle1,c_white,1)

Edited by creators124, 31 May 2012 - 10:20 AM.

  • 0

#10 flxp

flxp

    GMC Member

  • GMC Member
  • 325 posts
  • Version:GM8

Posted 31 May 2012 - 10:35 AM

i have this planet(earth) rotating around a HUGE BALL OF FIRE(the sun) it'll take it 31536000 seconds to move around this sun...

and i set the earth's rotation on its own axis to *365 of the rotation around the sun..
Time+=360/(room_speed*31536000)

so with this code i should be able to make this work
TimeSpan=60 //seconds
Time+=360/(room_speed*TimeSpan)

this makes the planet spin way too fast.. it is suppose to spin once every 60 seconds


[EDIT]
nvm... thanks it worked (i needed to make 2 variables that separated the year and the day for the planet)

Edited by flxp, 31 May 2012 - 10:39 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users