Advice on rendering a 2D scene

jmasterx
  • Advice on rendering a 2D scene jmasterx

    My game will be made up of objects. Essentially the level editor will give me a bunch of objects to choose from and I can drag them in and thus a level is made. The objects could have animation in which case they are responsible for knowing which frame and layer they are on.

    So then I can have these:

    Animated non-movable objects
    Unanimated non-movable objects
    Animated movable objects
    Unanimated movable objects
    

    So first I was thinking of, when the level starts, build a quadtree for all non-movable objects.

    This way I can easily avoid rendering ones which are not in view.

    Then from there I can do bounding box check on dynamic objects (or maybe if I add something like Box2D it can do it).

    But then comes the rendering.

    At first I was thinking of each object rendering itself, but then I cannot do atlasing.

    I'd like to do atlasing. I was thinking that animated objects can just use their own frame sheet. But objects which are not animated should use atlasing.

    I know this can be categorized as premature optimization, but I don't want to eventually find out that it is horribly slow.

    Any design suggestions / comments would be welcome. Does it seem like a good idea to try to atlas in the sort of game I'm making, which is a platformer that is not tile based.

  • Make a rough guess on how many objects you will need in your game. Put 10 times that amount in the engine.

    If it doesn't run slow you are fine. If it runs slow, you might need to optomize, or you might still be fine.

    I would be more concerned with the logic having to iterate through a lot of objects than the a 2d render being slow.

    The only kind of culling that will be worth rendering is culling anything that is outside of the screen.

  • For a modern 2d game I would really look at Aquaria. http://www.bit-blot.com/aquaria/

    They have some pretty modern principles they apply to a fairly normal 2d engine. Their basic idea is just massive stacking of objects on different layers. Take a look at this video by the guys from Wolfire analyzing technical details.

    http://www.youtube.com/watch?v=1BpRsjF7QTM&feature=channel_video_title

    I'd assume that when in non-editing mode static objects are combined into larger objects which are stored in a single surface but that is just a guess by me.

Tags
opengl c++ 2d
Related questions and answers
  • that make really hard to work with when coding some functions that use them. I was thinking of making ie. SimpleMesh and HierarchyMesh objects, which will also require that the renderer can deal... I was thinking about making smaller structures with the fTime variable each so I can have attribute keyframes, light keyframes and buffer keyframes, then make the node structure look like... at this level I prefer to have well-defined data so I can store and work with fast during runtime. It's this complicated because it must support a lot of rendering and animation techniques, must support

  • code in them... Right now for testing purposes, I just have the main loop call Level1 level1; and use the functions, but when I run the game I get a segmentation fault. This is the first time I've... that'll have the inherited level classes pushed onto it...This is what my code looks like at the moment, I've tried various things and get the same result (segmentation fault). //level.h class Level... supposed to include in the inherited class structure, but this is what I have at the moment... //level1.h class Level1: public Level { public: Level1(); ~Level1(); void load(); void

  • ; //this method is unique to the class player void generate_mesh(); } Now in the game engine I want to have a general object list where I can check for example for collision, move objects, and so... to implement the game engine. So I thought my game engine should control this things: - Moving the objects in the scene - Checking the collisions - Adjusting movements based on collisions - Passing the polygons to the rendering engine I designed my objects like this: class GlObject{ private: idEnum ObjId; //other identifiers public: void move_obj(); //the movements are the same

  • on screen... Since the result was kind of hacked together, I am thinking that maybe I am performing some extra steps or extra rendering tasks that maybe are not needed, and are slowing down the game...I am quite new to OpenGL, I have managed after long trial and error to integrate Nehe's Cel-Shading rendering with my Model loaders, and have them drawn using the Toon shade and outline... float frac = (time - (float)(frameIndex1 - startFrame) / (float)(endFrame - startFrame + 1)) * (endFrame - startFrame + 1); // I ADDED THESE FROM NEHE'S TUTORIAL FOR FIRST PASS

  • is, to keep the total data usage hovering around / under the soft limit, the manager will have to have a smart way of determining which objects to unload. I'm thinking of using some kind... a soft target for the total memory used by all the game's resources combined. Other classes will create resource objects, which will be in an unloaded state, and pass them to the ResourceManager... in advance of first use. Here is a bit a sketch of the classes I am using: typedef unsigned int ResourceId; // Resource is an abstract data type. class Resource { Resource(); virtual

  • the objects at a fraction of the distance between their previous and current value positions and rotations. That is yet to be done. Question: Will I also have to do move my collision detection code... a problem with smoothness. If I reduce my physics updates to 25 per second which I have only done as an experiment then it is a bit jerky. But the game easily runs at higher rates than that so there may... my game working at the moment without interpolation. It does physics updates using fixed step time deltas. The frame display rate is decoupled from this. So, it might be doing 40 Physics updates per

  • I'm trying to create a formula that can be modified simply by changing two values: number_of_levels, and last_level_experience. This is to enable people modding the game to change the levelling requirements. I've got it so that I can specify the number of XP needed for the last level up, but I want to be able to control the XP needed for the first level up, which in this case can differ wildly. For example, if I have 40 levels, and 1,000,000 XP for the last level, the first level up requirement is then 625. But if I change the levels to 80, the first level up becomes 156. In both cases

  • ->setOrientation(quart); } } The QuaternionToEuler function isn't needed so that was removed from code and header files. The objects now collide with the ground and each other appropriately. ... this on what I had done there, but modifying it to fit with Ogre. It is working but not correctly and I would like some help to understand what it is I am doing wrong. I have a state system and when... to collide with.. as follows. I expect there is issues with this as I get objects colliding with the ground but half way through it and they glitch around like crazy on collision. void GameState

  • () { } Cube::~Cube() { pBuffer->Release(); // why does this only work when put here? because it's created here? I thnk so, why not iBuffer though? } void Cube::Draw() { render_frame(); } void Cube...(); }; #endif If I call Init() from game.cpp, the code works fine, if I call cube->init(), just as this function is entered (not when the other one is left), the device pointer suddenly has an address...Basically when placed in the same file this works fine, but if placed in separate files (and I have tested this) just after Init() is called, the pointer to ID3D10* device's value is suddenly

Data information