Jump to content

  • Log In with Google      Sign In   
  • Create Account


Czar05

Member Since 20 Jun 2011
Online Last Active Today, 11:20 AM
-----

Posts I've Made

In Topic: Clarification on SAT?

08 June 2014 - 03:28 PM

Thanks for the response  Aardvajk,

 

Sorry I was not clear before, I meant to ask which axes would I project my shapes edge on the X  and Y axes or on an arbitrary axes that is made up by myself.


In Topic: Best Laptop for Game Development

07 January 2014 - 12:47 AM

Thank you all for your input, they are very insightful. Just curious why everybody here is favoring AMD, instead of Intel. I asked my brother for his input and he said intel, but I am eager to here your opinions on the matter.

 

@_greyfox Lol thanks I'm gonna need it.


In Topic: Moving in the direction of rotation?

23 December 2013 - 05:30 PM

Turns out I was on the right course on the first couple of attempts. My problem was really an image issue not a mathematical one. Lol

 

Thank you everybody for all your input. Each one of your responses was insightful and I appreciate your thoughtful responses.


In Topic: Moving in the direction of rotation?

18 December 2013 - 10:39 PM

Thanks @warnexus, I have a better understanding of the

this
keyword.

In Topic: Moving in the direction of rotation?

17 December 2013 - 06:13 PM

I appreciate the reply's Kryzon and ferrous.

 

@Kryzon, I am curious on why you recommended the first attempt better because Paradigm Shifter recommended I use vectors, which is a good suggestions for future projects.

In terms of controls, I want my controls to be similar to the original asteroid where the UP arrow key is the only button that accelerates the ship right, left, up, down, left or right depending on the direction of rotation. I made a direction vector that had the ship coordinates:

 Vector2f Direction = new Vector2f(shipx, shipy);

then used the Direction vector to render the ship:

public void render(GameContainer gc, Graphics g)
{
  g.drawImage(Ship, Direction.x, Direction.y);
}

followed ferrous advice and normalized the Direction in the update method so I could use the vector to focus on the direction instead of the magnitude

public void update(GameContainer gc, int delta)
{
  
 
if(Pressed Key Up)
{
  Direction.normalize();
   Velocity.y += Direction.y + thrust;
}
 
}
 

when that didn't work I used the following method

 

Variables

static float shipx = 300f;
static float shipy = 300f;
static float posx = shipx;
static float posy = shipy;
static float speedx = 0.3f;
static float speedy = 0.3f;
Vector2f SpaceShip = new Vector(shipx, shipy);
Vector2f Direction = new Vector2f(posx, posy);
Vector2f Velocity = new Vector2f(speedx, speedy);
 
 

Render Method

public void render(GameContainer gc, Graphics g)
{
  g.drawImage(Ship, SpaceShip.x, SpaceShip.y);
}

Update Method

 
public void update(GameContainer gc, int delta)
{
   
  
  if(Pressed Key Up)
{
     Direction.normalize();
   SpaceShip.x += Velocity.x * Direction.x;
   SpaceShip.y += Velocity.y * Direction.y;
}
  
}
 

Pretty confused on how I should properly execute this?


PARTNERS