Sign in to follow this  

Need some help with Camera logic

Recommended Posts

Tallkotten    288


I've actually partially solved it on my own. So i need no further help on this

Hello there!

I've been learning SDL and for my learning I've been developing a what's to be RPG. To get accustomed to SLD i followed a few of lazy foo' production's tutorials, very well made. (only downside is that they always only use one file)

I've got a basic mapBuilder working which builds a map depending om what vector it's fed, a player you can move and collision detection. Now I'm looking to implement a camera. Problem is that I don't really understand how and lazy foo' productions isn't helping me in any way.

These are the steps I've set up for myself to make it easier:
1. create a SDL_Rect to hold the camera values

2. Hold the camera centered on the player

3. lazy foo' is drawing the player to the center of the camera (don't know why that is necessarily since the camera is centering on the player)

4. Only draw whats on the camera to screen

I've managed to complete task 1 and 2 and to test I've now got a rect (the camera) following the player when i walk. However that is all, so i basically only have a rect that is following the player around and need help to make it a camera.

How would you go about and do this?

I'm going to attach my project for those of you who want to test it out. I'm going to warn you that most of the code is sloppy since i want basic functionality before i start improving.

While you are looking you could check out my .dia file in the "/structure/" folder and comment on my organization of all the classes, since this is my first project ever i'd really appreciate that.

EDIT: To see the camera on screen when compiling make sure to uncomment line 192 in game.cpp (this code "SDL_FillRect(screen, &camera, 0xFF);")

[attachment=9806:game.rar] Edited by Tallkotten

Share this post

Link to post
Share on other sites
This topic is now closed to further replies.
Sign in to follow this