Skip to main content
gamedev.net
🔒 Locked

2D platformer camera control

Started by GuyWithBeard 3 replies 1.7k views
Original Post
GuyWithBeard
GuyWithBeard
Hi! I need your oppinion on this... I am creating a 2D platformer (mario-like) game that currently supports, as input devices, the keyboard and XBox 360 controllers, through XInput. (I might add DirectInput support for other devices later). I am planning to allow the player to move the camera a little up/down/left/right from the character to allow some degree of "free look", i.e. examine what is surrounding the character. I thought about using the right thumbstick on the X360 controller for this (the left is character movement). This should work fine and be easy to implement. However, I have no idea on how to control the camera trough the keyboard. One idea would be to change the arrow keys from character movement to camera movement if a certain key (e.g. Ctrl) is pressed, but is this perhaps a little clumsy. The player cannot move while looking up for example. Any ideas on how to do this in an elegant way? How have other similar games done it? Thanks!
GuyWithBeard
GuyWithBeard
I have considered the mouse, however, I decided at an early stage not to use a mouse at all inte the game. There is no problem adding it, the game actually captures the mouse every frame, it is just not shown.

The camera actually moves along with the character, reacting to its movements and speed, e.g. zooming out a bit when the character moves fast to see a little more and so on...

The free look is there mostly to allow examination of the surroundings if the player is unsure where to go.
Zipster
Zipster
How about using the WASD keys for movement, and the arrow keys for controlling the camera? That also has the added benefit of mimicking the left-thumb movement and right-thumb camera controls on the controller (except instead of thumbs you have fingers).
kvakvs
kvakvs
To reduce amount of control keys required to make camera move, you could limit "peeking" to front/front-up peek direction, and only do it, if there's something that's interesting (monster, powerup or another game object). Like press "Space" to peer around, and then if Space is pressed look forward and scroll up/down a little. If player wants to see another direction, he will turn the character and press Space again.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.