Jump to content

  • Log In with Google      Sign In   
  • Create Account

Need some help with Camera logic


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
1 reply to this topic

#1 Tallkotten   Members   -  Reputation: 288

Like
0Likes
Like

Posted 03 July 2012 - 01:23 PM

/********************************************************

BEFORE YOU READ ON!

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);")

Attached File  game.rar   1.43MB   35 downloads

Edited by Tallkotten, 04 July 2012 - 12:32 PM.


Sponsor:

#2 Tom Sloper   Moderators   -  Reputation: 9883

Like
0Likes
Like

Posted 05 July 2012 - 07:22 AM

Closing at request of OP.
-- Tom Sloper
Sloperama Productions
Making games fun and getting them done.
www.sloperama.com

Please do not PM me. My email address is easy to find, but note that I do not give private advice.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS