#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Using camera and perspective on a 2d project?

Posts: 3

How would I use the perspective and camera on a 2d project, for example, a game like super smash bros, except with sprites. How would I get the camera to follow your character? Would I even need to use these? Thanks!

Tagged:

• Mod
edited October 2015 Posts: 5,396

@irie5000 - If your player is at Ax,Ay, then `translate(Ax,Ay)` will centre the camera on him.

You can fake the perspective by giving all your positions a z value which is how far away they are, then when you draw, you can adjust their size in proportion to the distance, eg

``````Ax,Ax,Az=300,400,1 --A is 1 pixel away from camera
Bx,By,Bz=200,300,25 --B is 25 pixels away from camera

--because we are in 2D, the z value will be ignored
--but we can use it in draw like this
--to scale the image size
sprite(picA, Ax, Ay, picA.width/Az)
sprite(picB, Bx, By, picB.width/Bz)
``````