Results 1 to 8 of 8

Thread: asteroid-type movement help

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    62

    asteroid-type movement help

    Again, I'm making an arcade game, a little bit like galaga and space invaders, but I want my ship to move like the one in asteroids. I'm tired of having it move twip by twip. What kind of coding will allow me to do this?

  2. #2
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: asteroid-type movement help

    So you want the ship to rotate, with a thrust, right?

  3. #3
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: asteroid-type movement help

    I dunno what you are doing this in, but in asteroids, your are in space so it is as easy as.

    Vd = Vu + (Va * t)
    VPos = VPos + Vd

    Or, The Displacement is equal to the initial velocity plus the acceleration of the object multiplied by the time of movement.
    Then add the displament to the pos.

    They are all vectors except t, t is the time that has passed since the last frame, or the last time the unit routine was checked.

    Va may be tough to determine at first, but lets say you want an acceleration 45 degree down the x,z travelling 5km

    Va.X = cos(45)
    Va.Z = sin(45)
    Va = Va * 5

    Of course 45 must be converted to RAD before used with most cos and sin functions. Once you multiply by 5 you will have a unit vector 5 steps down 45 degree, so any unit using that will accelerate at a rate of 5 units (units can be anything you specify, so in this example we are in KM).
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: asteroid-type movement help

    To convert it to radians you do this:

    VB Code:
    1. Va.X = cos(45 [b]* PI / 180[/b])
    2. Va.Z = sin(45 [b]* PI / 180[/b])
    3. Va = Va * 5

    Where PI = 3.141592654

    In bold is the area that converts it. So the formula is basically Angle * PI / 180

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    62

    Re: asteroid-type movement help

    I didn't intend for it to rotate. But I just want the movement. Like when you would make it move right,by pressing the button once, it would move but very slowly. And if you were to hit it multiple times, or hold the button, it would go faster. Ya know? The asteroid ship movement, just kinda floats when you make it move a certain direction.

  6. #6
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Re: asteroid-type movement help

    We gave you all you need to know to accomplish that.
    Think about it.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    62

    Re: asteroid-type movement help

    Ok well, i got it. I just dim avariable as single, then made x = x + or - 5 and the same with horizontal controls.

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    Re: asteroid-type movement help

    Think of the basic properties of physics, acceleration, velocity, and position. When you isolate these things everything will come easier. Then you don't ever have to do anything complicated, just integration over time.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width