Skip to content

Instantly share code, notes, and snippets.

@ajweeks
Last active January 31, 2016 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajweeks/1b4470fb813d6496af29 to your computer and use it in GitHub Desktop.
Save ajweeks/1b4470fb813d6496af29 to your computer and use it in GitHub Desktop.
Twenty-Third of Devember

Devember Day 23

Working on TM495 is beginning to become that kind of difficult game development, where you haven't ever done a lot of the features which you want implemented. Up until this point, most things I've added to the game I have written before; getting a rendering context, drawing a sprite on the screen, retrieving keyboard input, etc. But recently, I've been doing a lot of "well, I've never tried implementing this kind of system before, but this janky thing I just tried seems to work..." I suppose that is one way of learning game dev, and to some extent, maybe it's simply how the medium is mastered.

In my first programming projects for example, I would figure out how to get a rendering context going (by following tutorials mostly) and then become completely overwhelmed by the enormity of the task ahead of me, and end up scrapping the project, half finished. Then, as my skills progressed, I would get further and further into projects, but eventually I seemed to almost always hit a certain point where my motivation would just die out with the never-ending onslaught of learning how to implement new things.

I'm not sure if this is a common feeling which others can relate to me on, but I sometimes feel like making decisions can be a tiring thing to do. Whether it's what to buy at the grocery store, what clothes to get, or how to implement a specific game feature. I'm not sure if it's the idea of making the wrong decision and being worse off in the future, or what. Any psychologists out there?. In any case, I want to take a bit of a break from making new features for a while, I'll see what else I can do, maybe something not even related to TM495.

Today I spent some time improving the sprites. I added a very very basic walking animation for the player, and two simple axes.

Steel axe Gold axe

I was quite pleased to find an extremely simple way of animating the axe swing, shown in the following snippet:

this.axeMesh.rotateZ(-1);
setTimeout(function(w) { w.rotateZ(1); }, 300, this.axeMesh);

The first line rotates the sprite clockwise, then the second rotates it back 300 ms later. This works even when the player swings at more than one tree in that time window. However, that doesn't produce the smoothest animation ever, so I broke the motion down into smaller segments, which looks even better:

this.axeMesh.rotateZ(-0.5);
setTimeout(function(w) { w.rotateZ(-0.5); }, 50, this.axeMesh);
setTimeout(function(w) {  w.rotateZ(0.5); }, 125, this.axeMesh);
setTimeout(function(w) {  w.rotateZ(0.5); }, 225, this.axeMesh);

It still looks a bit primitive, but certainly good enough for now. As to how efficient it is, well, probably not the most. But, it works great for me for now, so it's staying.

Lastly, I added a cooldown for chopping down trees. As fun as it was sprinting through the forest insta-chopping everything in sight, it's a tad too easy. You can still insta-chop, but you then have to wait to chop again for a small period. I still need to add some way of chopping down trees more slowly. Right now I'm thinking either by holding down a key (Minecraft style), or by tapping a key several times.

Here's a shot of the axe right after being swung:

TM495 Screenshot

That will do it for today, I feel like that was a very productive 2 hour session. See you tomorrow!

Previous Entry | All Entries | Next Entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment