Help with a 2D Space Shooter!

Started by
11 comments, last by Norman Barrows 10 years, 10 months ago

I dunno, it was pseudo-code-esque. I'm not familiar with sfml.

I'm sure there will be a normalize function somewhere, maybe not a method of sf::Vector2f though... Or work out the length of the vector and divide by the length.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Advertisement
It can be called "unit"

or you can divide the vector by itself length (/magnitude)

o3o

for a mini map or look down radar, you'll draw in a manner similar to drawing the screen, but at much smaller scale.

so lets say you're running at 800x600, and your "world" or "level" is 2x2 screens (1600x1200 pix).

so you'd take the world coords of everything you want to draw in the mini map and divide by 10. that way your minimap is 160x120 pix in size (20% of the width and height of the screen in size).

add an x and y offset to each object on the map to effectively move the UL corner of the mini map where you want it on the screen and you're done.

then just draw a symbol or colored dot representing the object at the coords you've figured out:

minimap_x = world_x / 10 + minimap_xoffset;

minimap_ y = world_y / 10 + minimap_yoffset;

that divide by 10 is just an example.

it will actually be divide by "scale of world compared to minimap"

so if 1 pix on the minimap = 100 pix in the world, it would be divide by 100, and so on.

then you can get fancy and rotate objects around the player's position on the mini map based on the player's direction, so the mini map "turns" with the player.

.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement