• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Sabo

Programming a 2D spritesheet animation system

6 posts in this topic

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?

0

Share this post


Link to post
Share on other sites

While not completely what you may be looking for, you might take a look at http://esotericsoftware.com/ at least as an example.  While it is a multi-piece system instead of single image animations, the basic concepts are likely going to be very similar at the base level.  Given the provided open source runtimes, it may save you time to take a look.

1

Share this post


Link to post
Share on other sites

While not completely what you may be looking for, you might take a look at http://esotericsoftware.com/ at least as an example.  While it is a multi-piece system instead of single image animations, the basic concepts are likely going to be very similar at the base level.  Given the provided open source runtimes, it may save you time to take a look.

Hmm... I had not planned to use skeletal animation for this particular game. Either way, big thanks for the link. I will definitely have a closer look at their stuff since chances are I will use skeletal animation in a coming project. Might even change my mind for the current project.

0

Share this post


Link to post
Share on other sites

You've pretty much covered what I have in my sprite code. My reference point is beneath the center of gravity of the figure, where the ground would be if the unit were standing. This is also marks the vertical displacement of the unit in the position vector. If I could go back, I think I would just make the reference point the center of gravity of the unit.

 

Actually, if I could go back in time, I would do a skeletal system.

 

Edit: no, really, if I could go back, I would use a 3rd party tool...

Edited by jms bc
2

Share this post


Link to post
Share on other sites

I'd allow for points and boxes to added to each frame as metadata.  In addition to allowing a "center of gravity" element, it would enable the following features to be added trivially:

 

1) collision boxes (often not the same as the sprite boundaries)

2) vulnerability / attack boxes (the intersection of a player's vuln. box and an enemy's attack box would trigger damage, for example)

3) spawn points for bullets

4) sound triggers (lets you play sfx for attacks, footsteps, etc., at precise timings)

 

I've used systems like this in the past, and they can be surprisingly powerful.  You could write a fairly simple tool in a day or two to let you graphically edit and place boxes and points in your sprite frames.

 

The variable-sized frames sound good, but I'd stick with fixed-size until you're sure that the memory savings is worth the complexity.

 

The time-per-frame is a good feature.  90% of the time, you'll want your frames to be evenly spaced, but i could see it coming in handy for some specific cases.

 

have fun!

 

1

Share this post


Link to post
Share on other sites

Alright. Thanks for the input. Good information in all posts. Will give it some more thought before I go ahead. Much appreciated.

0

Share this post


Link to post
Share on other sites

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?

 

I'm a noob but I guess I could tell you how I did this.

 

I used a Animation class to handle the animation itself. Then it had a list of Frameset class instances and a pointer to the current Frameset which it used to loop over it.

The Frameset class had a list of Frames and ability to add Frames etc. The Frame class had x/y cords for the image and offsets and some more stuff.

 

I hope you get the idea, some time ago since I coded it.

 

Maybe someone with actual skill can tell you how much my version sucks. :)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0