Friday, April 25, 2014

Goblin Horde: Sprite Sheet

So another game I am working on is called Goblin Horde. This project is just to build a prototype. I wanted to see if I could build a simple game from scratch, unfortunately, due to some stuff with another programmer who is no longer on the team(for other reasons), and to keep things simplified, we ended up using the sample game here as a base for the logic. However we've redone the assets, slowly (still working on that) and I've been rewriting the programming every now and then to suit our needs. This brings up it's own issues, because if I had written the program I would know how it works, and I would know (more or less) how making a change to one part of the programming, would effect other parts of the programming. Anyways, what I want to talk about is making this sprite sheet:
Goblin Spritesheet

 This sprite sheet is for the main character of goblin horde. Btw, let me explain real quick what goblin horde is all about. Goblin horde is 2D platformer where you play as a group of goblins, and every level you raid a different fantasy race's town. In the first level, it is simply humans. The trick is that you play as a single goblin, and since you are a horde of goblins you have 50 lives. Every time you die, a new goblin pops on screen. At first this is just useful for when you die against an enemy, but later on it becomes tricky, as you come up to traps and puzzles, that require loosing goblin lives in order to proceed onward. You also get a lot of use out of trial and error attempts, the idea being that: 1, you have plenty of lives, and 2, death is fun in this game. That's the crux of the game, now back to this sprite sheet.

Here's an animation that I had to add:

A goblin swinging his sword

This is a simple animation of the attack action. Done by my artist friend, not me. Adding this animation into the sprite sheet isn't an easy task for a few reasons. Mainly, the communication between me and my artist was not very clear and so I had thought that we agreed to the dimensions of the character. However, when my artist sent me this it was on a 500 x 400px image. What we agreed on, I don't remember, but I do remember that it was a multiple of 30 for both dimensions(for programming reasons), and that it was around (30-60) x (30-90)px. But when my artist sent me this I endeavored to make it work.

So, to get this image to fit, I have to take every frame from the different images that my artist later resent me so that it had a clear background, and I added them to the same image in GIMP (Which is open-source photoshop) in different layers. I then looked at all the layers and determined the farthest left, right, top, and bottom points across all the frames. Those points then became the borders of the image. Then I found out the length and height that those borders would make the image, and I rounded those lengths and heights up to a multiple of 30 (I needed to for the way this game model works as far as I could tell.) After that I cropped the image to be those dimensions, popped up the sprite sheet, changed the grid to match the dimensions of this animation, and set up an offset for the grid so that the animation frames would land in the right spot, and slapped them on the image. (I had to redo it when I found out that the attack animation, with the way the original programmer set it up, were double the size of other images. I ended up making some new variables anyways, so that I could mod the dimensions of any animation in the spritesheet in case a weird situation happens again and I need to change the size of an animation.) So that was a pain, it also took me about an hour to and hour and a half to also make sure his feet lined up with the other animations on the sprite sheet + testing) Now take a look at this next animation, it is the jumping animation.
This Image created a few problems. See if you can figure out a few of them.

Here are the issues with this animation and how I tackled them:
1 - Since the goblin is jumping and literally moving up and down in this animation it increases the height of the dimensions needed to play this image by a lot, something I didn't want to deal with.
Solution - I ended up moving the goblin down so that his feet were on the same level on every frame. This works, because the game itself moves the image up and down when the player jumps, so the animation itself does not need to have the goblin actually lifting up into the air.

2 - This animation shows the goblin both "jumping" and "landing". This means that the goblin needs to jump and land at a precise timing.
Solution - one thing you have to realize is that the timing is not going to be precise, because the time it takes for the goblin to jump up and down on level ground is not the same time it takes for the goblin to jump up and off a cliff and then land on the ground below. So, to fix this, I had to do two things: The first thing I had to do was divide the animation up into two different animations. One animation is for "jumping" (which ends when the goblin reaches the peak of his jump) the other animation is for "falling" (which is the rest of the animation). After setting up these images, I got that added bonus that if the goblin simply walks off of a cliff, it will still play the falling animation without doing the jumping animation, which would look weird. The second thing I had to do, was I had to add a new functionality to the animation class. This is because, with the way the class was setup, there was no way to have an animation play once and then stop on the last frame. As it was setup, animations for attacking would simply be swapped out for another animation as soon as the animation was finished. Here's the code with my alterations.


SetFrames(BufferedImage[] frames) is the old function and setFrames(BufferedImage[] frames, boolean playonce) is the function I added. All I really did here was take the code for the first function and put it in the latter function. Then I added the line "this.playOnce = playonce;" which is read later on in the animation function to tell whether the image is supposed to play more than once or not. Lastly, I went back to the former function and I had it simply pass "frames" to the latter function as well as giving "false" for the boolean playonce. This was an important step, because the program, as it stood, made several calls to the function setFrames(BufferedImage[] frames) and I did not want to have to find all those call just to add in a boolean. By doing it this way I was able to make the boolean playonce have a default value of false if the code did not specify and that's how it worked normally.

3 - The image shows the goblin preparing to jump, but the program will have the goblin lift up into the air immediately. This might look weird as the goblin crouches down to prepare for a jump but simultaneously, he lifts off the ground and into the air
Solution - this was probably the easiest problem to fix as I simply sped up the animation so that by the time he lifts off the ground, the crouching part of the animation is finished and so it looks "organic enough" to get away with.

4 - The very last part of the animation has the goblin hit the ground and crouch to "settle" as his body absorbs the force of his weight. Then he moves back into a standing position. This is pretty hard to see from the animation above, as that animation is playing too fast. The problem is that this part of the animation got grouped into the "falling" animation and so the goblin now crouches and stands up in as he is falling in the air.
Solution - okay this is actually something I still need to fix. This essentially requires me to make a new animation "action" called "landing". This action occurs when the goblin hits the ground and all that happens, is the goblin plays this animation. I have yet to do this because I know that it requires me to create a new "action" and I hadn't added new actions or deleted any of the actions that were already present. ("falling" was an action already present).

Phew. Overall it has taken me about 4~5 hours, to implement all the animations currently available (coding and testing included), and I still need to add another attack animation, and I need to get a walking animation from my artist at some point. Suffice to say it has been a learning experience to work on this sprite sheet. :3

P.S. I also am about to sign onto a new project for the summer. This project is supposedly going to pay. yes! And I think it might even be money they are paying! No more of those stupid peanuts! Don't want to talk too much about it, but I'll say it's a kids game about saving endangered animals, and the scope is relatively small so I think it will be pretty reachable. I'll talk more about it as it develops. Btw, I'll be working with another reddit user, and if you didn't know this, I only eat free-ranged meat and I love cute things, so this game seems to be right up my ally, plus.... money!?
- Thanks for reading, leave some comments below.

Monday, April 14, 2014

Been working on a project for a Skyrim mod
Quest: Grave Danger

The concept of the mod is that I want to introduce a new fight mechanic into Skyrim. One of my friends, when he DM's his Pathfinder PnP RPG game, he has these fights, where some big bad epic guy is there, and he has tons of minions that never stop coming, in fact more spawn every turn. In these fights, we also have an objective, which is sometimes simply kill the bad guy, but often times it is more complex than that. For example, we once had a fight where we were riding in our caravan when these dragonmen attacked us. Our caravan driver drove our horses as fast as he could, but we came up to a ravine with a bridge, and the bridge was up. So during this fight, dragonmen kept coming, and we had to get across the ravine to let the bridge down, after which we could just raise it up and that would give us the time we need to get away. So this became an epic battle and I still remember it for being so singularly awesome, because it didn't stop there. In addition to this, the DM also put some treasure chests around, and this tempted us to no end. We knew we didn't need the treasure but we wanted it, and it was as if the DM was asking us "Hey you can get this treasure, but your gonna have to work for it."


Those are the kinds of moments I hope to capture by adding this mechanic, as well as just opening up possibilities for new kinds of fights. Currently, I've designed a quest for the mod that has you defend an alchemist from Draugr while he does an experiment. The story is kind of a cheap way to put the player in a situation similar to that DM's fights. You have to "fight waves of enemies" while "completing an objective(defending the alchemist)". I also am a huge fan of fights where you defend things, because you can have time before hand to set up some defenses and plan an attack. Spells like "fire rune" which is essentially a trap spell in Skyrim, don't often have the chance to shine as traps since, in Skyrim, you are often moving forward. I really wanted to add in some extra traps that you could set up as a reward for having high skills in any of the more rouge skill sets, as having swarms of enemies makes it hard to play a stealthy character, but more over I really wanted the player to have a few options for preparing defenses. I added an object that lets you summon a extra summon (with choices based on your conjuration skill) for this very reason.

First Fight

The second fight is really just a bread and butter "kill x amount of creatures to advance". I put it in because I wanted to have an example of a fight that ended based on the number of enemies killed, as opposed to the first fight which just lasts a certain amount of time. There is also a mechanic that sets the lower end of the stage on fire at certain intervals, and on other certain intervals, it fills the top of the stage with gas. This means that the player has to dance between fighting on the upper level and fighting on the lower level. (I also managed to get the enemies to leave the parts of the stage that were in danger, which was a trick in it's own.

Second Fight

The third fight (one I'm still working on) represents the third condition in which these waves can end, and it is by far the most exciting (to me) and that is by objective. In the third dungeon, the player has to explore a  labyrinth and find three orbs and then return them to their pedestals. Kind of drawing on some Zelda here. While the player is running through the labyrinth enemies are spawning and searching for the player so you really can't stand around for too long, and your bound to run into a group of them once in a while. In addition, I'll also be adding some traps, that the player will have to be careful not to step on, but they are also there to be useful for getting rid of large groups of enemies. Lastly, there are three loot rooms in the labyrinth, two of which have some story to them. One of them has an adventurer who went into the tomb before but locked himself in the loot room to get away from the draugr. He ended up starving to death (all of this is explained in a short journal) but he left behind his staff that he brought, a staff that casts "Clairvoyant" which is a spell that shows you the direction to quest objectives(think about it). The other story has a dead adventurer who was mapping out the labyrinth and he had managed to map it all out and find the location of the orbs before he died. This is pretty helpful to use with the local map, to tell what each floor looks like, but it's not overly helpful, I think, as the local map is confusing since, the way they designed Skyrim, it shows every level of the labyrinth superimposed on each other, but player's should be able to piece together where they are and where to go using this.

Third Fight WIP

Lastly, I had wanted to take some dungeon concepts from users of my mod and poll them. I liked the idea of creating a little bit of a close connection between myself and the player base but in the end I only got one idea submitted to me, and I really wanted to get a bunch, and have some energy going. I designed the fights, to be very polished with the idea that players might want to fight them multiple times since you can use a lot of different valid strategies to beat them and they have a difficulty slider "medium" and "hard". (my favorite way so far is to use a bow and a follower and let the follower tank, while you pick off enemies. The fights in this mod are on a very large scale so there are a lot of abilities that come into play that normally don't matter. For example, stamina and run speed actually matter quite a lot in these fights) I still have some ideas (Zombie survival mode) that I could put in but seeing as I can't get players to shoot me some ideas for fights, I think that once I complete my third dungeon, I'm going to work on a new project and call this mod "finished".

Anyways, that's what I have cooking on my current Skyrim mod. I of course, am also working on a few other projects, that I'll post about later, but I wanted to keep these thoughts about this mod in one place. I'll also be slapping a few images up here for the dungeons. Modding is hard work. It took me probably about 200-300 hours to make the first two fights, and I believe less than that many players actually played my mod. Anyways, I asked for feedback near the end of the mod, and I've gotten some so that should make me a better modder :3