Jump to content

  • Log In with Google      Sign In   
  • Create Account


"Camera" movement in C++ with Allegro 5


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.

  • You cannot reply to this topic
1 reply to this topic

#1 Toshi   Members   -  Reputation: 126

Like
0Likes
Like

Posted 20 January 2013 - 04:03 PM

Hey guys,

 

A second question in one morning.. something that has been bugging me.

 

I have been following the great guide by Mike Geig at fixbyproximity.com, and have made a background for my character to walk on.

 

However, I want the "background" or map to be much larger than one screen worth, and so have designed a tile background.

 

The problem is, that the "camera" or viewpoint of the player, doesnt move.

 

So, the players character can move off screen, ostensibly on to the different areas of the mapped background, but can no longer be seen by the player.

 

Alternatively, the mapped background is much bigger than what is seen on the screen, but the only way to see it is by including an "offset x and y" which moves the background itself, but then the players character is not connected to the background, it is as if the ground is moving out from underneath him but he stays in the same place.

 

If I were to leave the background not being able to move, have the character only bound by the maximum background size instead of WIDTH + HEIGHT (of the display), but have the players viewpoint/camera actually move instead around the background, tied to the players character, this would be a solution I would be very happy with.

 

Is this possible, and if so, how would I make it happen?

 

Cheers,

Toshi



Sponsor:

#2 EWClay   Members   -  Reputation: 655

Like
0Likes
Like

Posted 21 January 2013 - 10:13 AM

Use two coordinate systems. The first should be used for the background, the player, and all the game logic.

The second coordinate system is for rendering and represents the screen.

Whenever you render something you will need to transform from world coordinates to screen coordinates. This will probably just be a case of adding an offset.

You can use a viewpoint or camera object to handle the transformations. Then moving the camera will change the visible area on the screen.




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