• 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
Gorge Express

Implementing "actions" in an action game

6 posts in this topic

I'll use Link to the Past as an example

 

Frame 1:

[attachment=15864:link1.jpg]

 

Link takes out his sword and begins the attack animation. Though the sword is being rendered, it has no hitbox yet. For the next couple of frames, pressing the d-pad or any buttons will have no effect on Link. 

 

Frame 3:

[attachment=15865:link2.jpg]

 

The sword now has a hitbox and can collide with enemies.

 

Frame 6:

[attachment=15866:link3.jpg]

 

The player can now press attack to interrupt the current attack animation and start a new one. Any other input is still ignored. 

 

[attachment=15867:link4.jpg]

 

On the last frame of the animation (13), the game checks to see if the attack button is held down. If it is, Link enters a new state where he begins charging his sword. If not, on the next frame, the animation ends, the sword disappears, and full control is given back to the player.

 

I'm wondering, how would people approach the problem of implementing "actions" like these in a video game? Where rather than the action taking place in a single frame, it takes place over several frames and updates certain things(like the position of the sword is always attached to link's hand, even if he is moved by some outside force during the animation) each frame. With access to today's technologies of course. 

 

Best i can come up with for an "attack" action is hard coding it based on states. Pressing attack puts Link in the "Sword Attack" state and starts a timer. The game sees this, then creates the sword and starts playing out the animations. Each frame, the game updates, checks the time passed to see if it should add the hitbox or whatever it needs to do. The second half of the animation would have its own state, so the game knows that it is allowed to accept input for another attack to interrupt the current one.

 

That means coming up with a different set of states for every action in the game though, which would be a pain. Especially in a component+entity system, where you would need to add the code into a State System or something instead of each entity's  own update method.  So i'm wondering to see if there are better ways to handle this, especially more data-driven ways. 

 

 

0

Share this post


Link to post
Share on other sites

This is where tools come to the rescue.

 

My guess would be that they use an in-house development tool to compose the frames together, and able to inject extra information into each frame, such as collision boxes, tags, sound effects, and so on.  Then when the game loads the resource files, it creates a data structure of the animations and frames and tie them up together in such a way that simplify all these seemingly complex tasks.

 

For example:

 

Animation* animation = loadAnimation("link.dat");
animation->play();
 
// somewhere when checking for collision
// animation object already takes care of which frame it's currently playing, and whether there's a collision box in that frame.
if (animation->collides(another_animation))
{
   // do something here
}
Edited by alnite
0

Share this post


Link to post
Share on other sites
LttP was made in assembly, so they would've had to do things the hard way :p but yea, i was just using it for an example.
 
FSM sounds like what i was saying I would do. Using only a FSM to address the problem would be a real pain if you need to implement a lot of actions though. 
 
Using a data structure that takes care of itself makes sense too. Though something in the code would still have have to handle adding and removing the sword entity, adding and removing the hitbox, and changing the player state. You can't just change the player state out of "attack mode" after a set amount of time, because that amount of time isn't always known(imagine the hookshot in any Zelda game. If it hits a wall, you gain control of the player back sooner.)
0

Share this post


Link to post
Share on other sites

My thoughts would be to make the system far less complicated.

 

What I mean is I might start playing the attack animation when the attack key is pressed and then after a certain delay check to see if I an in range of the enemy (and facing the enemy). If I am then I assume that the sword hit the enemy.

 

I don't think I would mess with hit boxes or even creating the sword independently (depending on how many swords I had of course). I would probably draw or have an artist draw the hero with the sword. Or I would have the sword animated with the hero on a separate layer but I certainly would not attempt to position the sword somehow to the hero's hand every frame (as this would be asking for a lot of frustration).

 

When possible I would want to use other factors then animations and collision detection to determine my game state since animations and collision detection can take a lot of work. So to me the animation would be what is visible to the player, but it would not directly be involved in my game logic.

 

Just my two cents.

Edited by shadowisadog
1

Share this post


Link to post
Share on other sites

I think the complexity of the state machine depends on how we implemented it. If we use the old school FSM (with switch statements and if statements under one huge file) we are more likely encounter with the term "spaghettification".  

 

If we implement an FSM that uses the abstract class (I think its called modular FSM) the complexity will be reduced a lot since each set of rules for each state will  run only on their class scopes.  This also gives us the power of adding new states and running parallel states at the same time. An example would be a global state "Attack" and  the inner states of the Attack, like you described on your post. However, we might also end up with duplicated codes no matter how much we hate. 

Edited by Nusakan
0

Share this post


Link to post
Share on other sites

Thanks for all the input.

 

fun fact: Not only did Nintendo have to position the sword near Link's hand each different frame, but they also had to determine how to rotate the sprite. There are 36 different frames of the normal sword swinging animation, but only 8 different sprites for the sword. Link himself usually consists of 2 different sprites(he is only 1 sprite in some arbitrary frames) and they just change the x and y position of his head to make it look animated. Must have been fun doing all that in assembly. 

 

Anyways, what is a good way to deal with the timing of  actions specifically? That is, the activation/addition of a hitbox to the sword after a delay(or the check to see if an enemy is in front of the player), and the removal of the sword+reverting the state of the player back to normal after the action(which lasts an unknown amount of time) is done? The action must also end early if the player is hit. 

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