Camera Tutorial |
Camera Tutorial |
David Olofson
Guest
|
On Wednesday 25 November 2009, at 01.59.34, "Tabris"
wrote:
Are you going to use OpenGL or the SDL 2D API? (Not that it differs much beyond the technical details, as long as we're *really* talking 2D as opposed to "3D with 2D style camera".) Here are some basic examples that covers both: http://olofson.net/examples.html The parallax examples are SDL 2D only, whereas the smoothscroll example supports SDL 2D as well as OpenGL, selectable by command line switch. (Smoothscroll is actually intended to demonstrate sub-pixel accurate positioning for ultra-smooth scrolling, but that's really just a tweak to "basic" OpenGL scrolling of tiled backgrounds.) -- //David Olofson - Developer, Artist, Open Source Advocate .--- Games, examples, libraries, scripting, sound, music, graphics ---. | http://olofson.net http://kobodeluxe.com http://audiality.org | | http://eel.olofson.net http://zeespace.net http://reologica.se | '---------------------------------------------------------------------' _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Tabris
|
Hey thanks! i will look into it tomorrow and see if i can understand it =)
|
|||||||||||
|
Camera Tutorial |
Jonny D
|
If you're just unsure of how to get started with a 2d camera, then try this:
typedef struct Camera { float x, y; } Camera; Create a camera somewhere reasonable: Camera cam; In your game loop, update it each logic frame: cam.x = player.x - screen->w/2; cam.y = player.y - screen->h/2; Then draw the scrolling stuff (this is just a wrapper for SDL_BlitSurface): blitSurface(player.image, screen, player.x - cam.x, player.y - cam.y); Everything that you adjust with the camera position will be scrolling. Good luck, Jonny D On Tue, Nov 24, 2009 at 11:31 PM, Tabris wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|