From 6f45c0a80d0efa1dcfcc81499e0ed55d287e7efd Mon Sep 17 00:00:00 2001 From: brettchalupa Date: Mon, 4 Nov 2024 19:42:46 +0000 Subject: [PATCH] deploy: c9f430d0163451bf488a871c6a00d571037c32ee --- 10-animation.html | 2 +- sitemap.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/10-animation.html b/10-animation.html index 1844340..0ed7200 100644 --- a/10-animation.html +++ b/10-animation.html @@ -158,7 +158,7 @@

Ani

#frame_index is a method DragonRuby GTK gives us on integers to keep track of what frame to use when animating. 0 is when we want to start the animation, which we want to start at the beginning of our game. We have 6 frames in our animation, and we want to display each of them for 8 ticks, repeating forever! Change the hold_for value and see how it affects the animation speed and feel of the game. Pick a rate that feels good for you or just stick with 8.

Then we take the player_sprite_index and use that when specifying the path of our player sprite by interpolating it into the path to our sprite. Our dragon frames are named dragon-0.png, dragon-1.png, and so on. So we take what #frame_index gives us and inject it into the path to the image, making that value dynamic. Remember string interpolation from Chapter 1? It comes into play all the time when coding.

A Note on Spritesheets

-

If you've done any game development before, you may be familiar with spritesheets, where each frame of an animation is contained within one image file. When using a spritesheet for animation, instead of changing which image file path is used for the sprite to render, you change which piece of the large spritesheet you render. The DragonRuby GTK docs have a detailed example of how to do this.

+

If you've done any game development before, you may be familiar with spritesheets, where each frame of an animation is contained within one image file. When using a spritesheet for animation, instead of changing which image file path is used for the sprite to render, you change which piece of the large spritesheet you render. The DragonRuby GTK docs have a detailed example of how to do this.

Extra Credit