Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualAshaman73

Posted 17 November 2012 - 10:14 PM

Here is something you should copy from the 3d world: world space and view space.
You should do all your game logic in world space, which should not differ between moving up or left. The view space is what you currently see and you need two functions to convert between the two spaces.
world2View(x,y) := (x-y*0.5,x+y*0.5) + (screenoffset_x,screenoffset_y)
view2World(x,y) := ...homework...

The world2View transformation is only needed for rendering your scene, please remember, that your world is somewhat turned by 45 degree, therefore you just can't make 1:1 conversion. The other way around (view2World) is needed whenever you want to convert input (e.g. mouse input) back to your world space.

There's some math involved which isn't hard, but makes the handling much easier. Once you work in world space independently of the screen lot of issues just vanish, like your movement example :D

#1Ashaman73

Posted 17 November 2012 - 10:13 PM

Here is something you should copy from the 3d world: 3d space and view space.
You should do all you game logic in a world space, which should not differ between moving up or left. The view space is what you currently see and you need two functions to convert between the two spaces.
world2View(x,y) := (x-y*0.5,x+y*0.5) + (screenoffset_x,screenoffset_y)
view2World(x,y) := ...homework...

The world2View transformation is only needed for rendering your scene, please remember, that your world is somewhat turned by 45 degree, therefore you just can't make 1:1 conversion. The other way around (view2World) is needed whenever you want to convert input (e.g. mouse input) back to your world view.

There's some math involved which isn't hard, but makes the handling much easier. Once you work in world space independently of the screen lot of issues just vanish, like your movement example :D

PARTNERS