Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Sep 2007
Offline Last Active Nov 16 2013 08:10 PM

Topics I've Started

Programming a 2D spritesheet animation system

24 May 2013 - 11:55 AM

I am about to start working on a 2D animation system using spritesheets. Below are my plans for this system, but before I implement it I thought I would ask for some thoughts and opinions.


  • Not all frames in all animations are of the same size. I then map each frame to a rectangle with the size of the frame which will save me a few bytes of memory.
  • I plan to have an array of frame times to allow different frame time for each frame. Will make it easier to control the animation.

Good? Bad?


I am also curious about how to best implement some kind of achor point. A simple example, a guy is standing straight (thin and high frame), then falling over (wide and low frame). Using either of the corners as an anchor point, the "standard/default" way, would result in the guy not only falling over, but also moving sideways on the screen. To solve this the anchor point needs to be set to the feet. Right? If so, I will also need an array for the anchor point for each frame, where the anchor point will indicate how much to move the sprite up/down and left/right. Or?


Am I missing something? Better way of doing things?

When to run the collision detection code?

12 May 2013 - 05:50 PM

I am currently developing a 2D puzzle game. Moving entities are: the player, the enemies, projectiles. I am a bit unsure if I should run a collision check after I move each entity, or move all entities and then check for collisions. The latter makes more sense for a few reasons, one being the case where two entities would collide only after both have moved. If we run the collision detection after each entity moves the collision (and bounce, if that's what they do), would not look correct. Granted, it would probably not be noticable depending on how far they move and the framerate and what not, but still.


I just wanted to see if there is ONE answer to the question, or if not, thoughts on when to run use either of the options.

How to create "fixed" movement in 2D?

15 December 2009 - 11:08 PM

I am working on a small grid-based game. The characters can only move horizontally and vertically, moving one half grid at the time. That is, the user press "Up" and the character begins to move north over several frames. While the character is moving it is not accepting any new directional input. Suggestions on how I should implement this? I have a working solution, but it feels... dirty. Check if the character is moving (bool), and if it is, check if it is moving north, east, south or west (enum), and then check if it has reached its destination. If destination has been reached, swich the moving boolean and clamp the position. Any better way to do it?

How to construct a laser beam for space scroller

20 February 2009 - 05:13 AM

I need some help when it comes to constructing a laser beam for our game. I want it to be smooth, so that when the ship is moving up and down the beam will bend nicely, ideally each part of the beam is one pixel wide. I am not sure how to proceed, so any pointer would be appreciated.

Need some help with code structure design

11 January 2009 - 05:19 PM

I am writing a small game using the XNA Framework. It is a 3D game with some 2D objects in it. I would like to use a base class and inheritance since there are a few attributes that all objects will share, as well as dynamic binding etc, but I have some problems setting this up in a nice way. All objects have the following attributes: Position Rotation Scale Active The 2D objects have the following attribute: Texture The 3D objects have the following attribute: Model The movable objects have the following attribute: Velocity Right now I have it set up in the following way: GameObject Statid2D : GameObject (texture) Movable2D : Statid2D (velocity) Statid3D : GameObject (model) Movable3D : Static3D (velocity) This structure feels a bit awkward though. Suggestions on improvements? I would also like to do a base Projectile class that inherets from one of the classes above. A problem here is if I want to be able to create both 2D and 3D projectiles. I am not sure how to best solve this, but problem might be automatically solved with a better structure of my GameObjects hiearchy above.