gfxgfxFreeBASIC Games Directory Forumgfxgfx
gfx gfx
gfx
Welcome, Guest. Please login or register. June 20, 2013, 03:58:47 AM

Login with username, password and session length
11.5.2013 - Added a webpage for the latest FBGD competition.

13.3.2013 - Members registrations temporary disabled. For all membership requests, please email me: lachie13@yahoo.com

30.11.2012 - The ninth issue of BASIC Gaming is out! Read it here: http://games.freebasic.net/forum/index.php?topic=560.0

22.11.2012 - Be sure to check our currently running annual FBGD game making competition. This year's theme is SEASONS OF THE YEAR, 300 $ first place prize, and the competition runs till 18th of February. Link: http://games.freebasic.net/forum/index.php?topic=559.0
gfx
gfx
*
gfxgfx
gfxgfx gfxgfx
gfxgfx Home Help Search Login Register   gfxgfx
gfx gfx
gfx
Pages: [1]
Print
Author Topic: Game Camera Systems - An Important Part of Game Play v.Alpha  (Read 1504 times)
Pritchard
Global Moderator
Forum Howler
*****
Posts: 149



View Profile Email
« on: March 11, 2008, 03:49:48 AM »

One of the most important devices in a game is going to be your camera.  Different games have had different cameras, for different reasons.

I'm going to spray you with a few camera systems.  Rather than develop a small number of very advanced camera systems, I want to show you some of the different methods you can use to update your camera and focus on the player.  I hope that once you've gotten familiar with the idea, you study motion and targeting enough to develop your own camera system.

The main camera updating code will be in camera.updatePos().

1)  Hover Over a Player at a Given Point

A camera's just a point that's focusing on one or more targets.  The camera moves right, you appear to move left.  Rendering is just your (position - camera position).  I also gave the camera a "center" vector in case you wanted to adjust what point the camera keeps you at.

2)  Follow the Player Once They Try and Escape the Bounding Box

Here we just move the camera when the character moves out of the boxed area.  This is one of the most simple, yet most effective camera systems there are.

3)  Follow the Player Once They Try and Escape the Circular Distance Area

You may wish to use a circular camera, especially if your game play focuses on the center of the screen.  Here we projected a point on the edge of our camera, based on the angle between you and the camera, and made sure you didn't escape the circle.  Once we find the point on the edge of our camera, this is just like the first camera example.

4)  Follow the Player at a Constant Rate

The camera here moves at a constant rate towards you.  It might skip around a bit since it doesn't slow down when it gets close to you.  To prevent massive shaking, however, I have it simply stick to you if you're at or closer than 5 pixels to its center.

5)  Follow the Player at a Rate of Reaching Them in N Seconds

This is a more advanced version of the second camera example.  We set how long it should take the camera to reach the player.  We update the camera speed every frame, so the camera will slow down as it gets closer to you.

6)  Jolted Movement

The jolted movement really only works well when you have a more advanced system for it, but here's the basic idea.  Your camera's now being held by someone with unsteady hands.

7)  Velocity-Based Movement

We gave this camera velocity.  It may skip over the player a bit, like a real camera operator would, or at least how something with velocity would.  Since when did we move toward the target until we're exactly over its center, anyways?  A more advanced version of this would randomize the point the camera focuses on, making the focus a bit off center, so we're not some mad genius focusing exactly on the target.


For the most part, I've found that unless you create a very advanced camera system, the extra work to make it seem more human isn't worth the effort, or the processing power.  Depending on the game, however, you may want the camera to reflect environmental effects, player actions, and player state (Ex: unhealthy has a blurry/shakey camera).  All for dramatic ambience of sorts.

8Camera Bounding Box Collision

The bounding box collision here just checks if you're collided now.  If you weren't last frame, then you must have *just* collided this frame, so we can push you back on that edge.  Using this technique, you could collide with multiple edges, moving at all angles.


Overall, my goal here was just to get you thinking about camera systems and show some I've played around with.  The perfect camera system for your game will depend on a lot of variables.  I just hope I've sparked a few ideas in your heads.  Hopefully you'll study motion a bit and come up with the camera system best fit for your game.
« Last Edit: March 14, 2008, 02:57:16 PM by Pritchard » Logged
nkk_kan
Forum Howler
****
Gender: Male
Posts: 180

Let's rocK~!

nkk_kan
View Profile WWW Email
« Reply #1 on: March 11, 2008, 08:09:52 AM »

Excellent! you need to fine tune it a bit ..explain some bits here and there..

The example of Follow Player at Constant rate Camera seems to be buggy..
It sometimes shakes after player comes back on center

and i don't understand that Jolted movement one..can you explain in more detail?
It seems to shake even when no key is pressed..

i particularly liked the Follow the Player Once They Try and Escape the Bounding Box Camera.
Logged

Pritchard
Global Moderator
Forum Howler
*****
Posts: 149



View Profile Email
« Reply #2 on: March 11, 2008, 01:12:34 PM »

Thanks for the feedback.  I'll not be editing the first post until the final version's complete, but I'll be working on what you asked for sure.  Yeah, the camera's supposed to shake and look "human" like, as if a person was holding it.  I could make a MUCH more advanced version than that, but I'm not sure if I'm up for explaining a single camera method so heavily and lengthening the tutorial even more.

The jolt camera can be enhanced severely.  Since when have people ever followed something at the exact angle from the target position to the target? :rofl:

Also, I'm thinking of removing the Vector2D and FrameTimer from each example to shorten the code.  I might just tell people to add it in every example themselves...


TODO:

- Explain how each camera system works and why
- Explain potential bugs and stuff
- Explain individual camera settings and their effect.
- The jolt camera's a bit useless, but the concept is a good one.  Explain why I refuse to have a huge fricken complex jolt camera as an example, and how I can make it more realistic.
« Last Edit: March 11, 2008, 01:35:59 PM by Pritchard » Logged
notthecheatr
Global Moderator
Forum Sage
*****
Gender: Male
Posts: 351


Who's the guy from 21 Jump Street?

notthecheatr TheMysteriousStrangerFromMars
View Profile WWW Email
« Reply #3 on: March 11, 2008, 04:23:14 PM »

Not bad.  I was thinking about writing something about motion in general earlier - not exactly the same, but similar.  I decided to write about scripting instead though, since you asked about it for a QBE article.  Maybe I'll do motion later.
Logged

The funniest thing happened yesterday.
Lachie Dazdarian
Double dipper
Administrator
Forum Sage
*****
Gender: Male
Posts: 1197


lachie13
View Profile WWW Email
« Reply #4 on: March 11, 2008, 05:48:35 PM »

I need to find time to plow through this.

But kudos for the effort.

Interesting topic.
Logged

"Things like Basic and Free Basic provide much-needed therapy and a return to sanity and a correct appreciation of people. The arrogant folk really hate a word like 'Basic' - fine, and good riddance." ~ pragmatist
Pritchard
Global Moderator
Forum Howler
*****
Posts: 149



View Profile Email
« Reply #5 on: March 11, 2008, 07:57:15 PM »

Not bad.  I was thinking about writing something about motion in general earlier - not exactly the same, but similar.  I decided to write about scripting instead though, since you asked about it for a QBE article.  Maybe I'll do motion later.
Motion would be awesome.  I want to make something more advanced, but I don't think I'd have enough time or space to describe an advanced motion system... I just kind of wanted to throw some ideas out there with this.
Logged
Pritchard
Global Moderator
Forum Howler
*****
Posts: 149



View Profile Email
« Reply #6 on: March 14, 2008, 02:44:39 PM »

Alright.  Bump.  I'll probably shorten the article's explanations a tad and maybe even get rid of them.
Logged
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Cerberus design by Bloc
Valid XHTML 1.0! Valid CSS!
gfx
gfxgfx gfxgfx