Sunday, June 12, 2011

Camera Controls!

Good evening, everybody!
WHAT'S SO GOOD ABOUT IT?!
I didn't get a whole lot of work done today, aside from realizing I sent David on a wild goose chase in our game... because of an uncapitalized letter.
Oops.
My B, dude. srsly.
Aside from that I didn't get a whole heck of a lot done.  I fiddled around with the idea of a 2d "Camera" object that lets me essentially view the game world from any "position" and "zoom"

So far, the system works flawlessly (...depending on what you want it to do)  The camera can track an object or a point and it can zoom in and out.  What's so special about this may you ask?

Well, considering it's been done a thousand times before in countless games, nothing.  But the fact that I did it myself in about a day is something I am just a bit proud of.  So sue me.  What you don't realize about cameras (in games) until you start making games is how in the blue blazes do I get all of these objects to change their positions/sizes and rotations based on where my "camera" is supposed to be?

Well, it's actually much simpler than that, I create one object, a camera, that calls its own drawing function.  The game engine (not that you can call it an engine at this point... but humor me) is still doing all of it's calculations and movement with original sprite locations and sizes, but the Camera object calls a draw function that simply draws the objects using their location as relevant to the camera and at the appropriate size based on the camera's zoom factor and does a quick equation that adjust's the distances of sprites between each other based on the zoom factor, and then draws the sprites accordingly.

So, "physically" speaking the objects remain unchanged, but they are just being drawn on the screen in a manner that represents them being viewed from a certain position/height.

Did anyone follow that?
What?! No! I didn't, just shut up or I'll SHOOT.
I included nothing coding-specific there, it's mostly an exercise in conceptual thinking at that point.  I've got the system mostly working.  It handles zooming in and out perfectly, and movement.  Next is handling camera rotation (Why?! I don't know I like flexibility in my code, OKAY?!) then being able to "limit" my camera, so it doesn't go outside certain bounds and won't follow a player off of the map if he escapes, etc.

And I need to take some more pictures of more doodles, I think I've exhausted my current digital supply!  Or I can't tell what's been used and what hasn't at this point.  I apologize for any re-posts.


All that is man?

Silicone Upper-Body suits.  With funny-looking pecs.  Oops.

I could draw comics! (LOL NOPE)

A cool new hat?
The face of a programmer.  I just look like this for hours at a time at the computer.
- Kev

No comments:

Post a Comment