I've ju开发者_StackOverflowst finished a month long project of building a very complex map / world editor for a 2D tile rpg type game. Now I'm at the point where I'd like to actually play the game and am in the process of creating the runtime implementation of the game using the maps, characters, and other things that were generated through the map editor. I know almost exactly what I am doing, aside from the camera. I cannot think of a way to make the camera work in a way similar to games like zelda(gameboy) (where the camera is fixed on the character) without scrolling the (x,y) values of every sprite and tile in my game everytime the player moves. I've looked into some game engines but I'm not convinced that is what I need, though I'm very willing to be wrong on that assumption. The entire game is done with images, there are no rendered shapes, which leads me to believe that I do not need to mess around with openGL to make the camera work as desired. Could anyone suggest a way to implement a camera without using openGL? I'm not against using openGL but I'd rather not learn it if I dont need to as I am crunched for time already with other projects. Thank you for the suggestions.
I would only draw what was visible in the characters camera area, thus you wouldn't need to move all of the sprites and such when your character moved. However, anything on screen would have to be redrawn. Which wouldn't be too memory intensive and you could set it up with some sort of database system or even multidimensional arrays where it would only draw what was within the camera.
For example, if you character is on tile 100(x) and 50(y) and the camera was a 7 by 7 grid of the tiles, all you would need to draw is whatever happened to be in the 48 tiles surrounding the player. This is how almost all tiled games do scrolling and isn't very hard on the memory. You should be able to do this with minimal lag and not too much programming... depending on how you set up your tiles and their layering.
One easy solution is to create an Image object, draw to that, and then paint that on the screen with the correct offset
精彩评论