ARGHH I suck at math!! Help!!!

BlitzMax Forums/BlitzMax Programming/ARGHH I suck at math!! Help!!!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I don't have bmax so there may be some trickery I'm not aware of, but I'd just do something like:

- Move and set each game objects position and rotation in the game logic as normal, just as if the gameworld was axis-aligned, ala Asteroids.

- At render time, or just before, transform all game objects to the rotated world as follows (pseudo code):
cos_rot# = Cos(-90 - player.rot)
sin_rot# = Sin(-90 - player.rot)

origin_x = screen_width / 2
origin_y = screen_height / 2

For this = Each game_object

	; Get vector from player to this game object.
	x = this.x - player.x
	y = this.y - player.y

	; Transform (rotate) vector.
	trans_x = (x * cos_rot) - (y * sin_rot)
	trans_y = (y * cos_rot) + (x * sin_rot)
	
	; Set actual position this object needs to be drawn at.
	this.screen_x = origin_x + trans_x
	this.screen_y = origin_y + trans_y
	
	; Set actual rotation this object needs to be rotated to.
	this.screen_rot = this.rot + player.rot

Next

(Not tested, but you should get the idea)

[edit]Ooops. Forgot something.