Finally it’s case 6, the last case this autumn. This case was about making an enemy in my game. The enemy was supposed to be made in its own class, have an animation and behave individually no matter what the player is doing. But when the character hits the enemy, something should happen.
I started this case with the part I knew I could do: the animations. I decided I’d have a squirrel as the enemy because it’s not a natural enemy of a fox, and they’re mostly thought of as cute, but they’re rather cool animals who won’t stand down from a fight if something is in their way. So I thought it could be funny.
Of course, it did not turn out the way I intended and it looks awfully off, but I figured that as long as it moved I’d be happy. I decided to make it move in a pattern that made it possible for the player to move the character past the enemy when the enemy was somewhere else. Basically I made it possible to win the game.
Making that happen and fitting it in my game was not much of a problem. Neither was the HitTest part when the character hit the enemy. But of course it can never be that easy. We were told that it was just needed a few sentences in the enemy class to make it work, but I couldn’t seem to make it work. When I showed up Friday to get some answers we were suddenly told that we could use a class that our teacher had made. That was fine by me, but it wouldn’t teach me anything.
I looked through the class to see if I could understand what’ve been done. But as the idiot at scripting I am, it might as well have been a plan for making an airplane. I didn’t get anything from looking at the class, so I decided that “it’s just the way it is”. But it made me think that I’ll eventually fail at this subject.
After I settled down with my failure, it was to the part of making it actually work. After changing the name in our new class and adding a few functions (move,turn) it could walk, in theory. Of course, things weren’t just going to be easy now, so it decide to spin back and forth on the spot instead of moving. I changed some values here and there and then the squirrel moved nicely left…finally. But then it also had to stop and turn. The teacher showed us a way to make it walk to the edge of the scene before it turned around and walk to the other edge and turn again. All was functioning nicely. If I only had a game that worked that way.
My scene “moves” so that the character has a bigger areal to move in. Basically it’s the environment that moves and not the character, but it looks like the character is moving though the environment. This made it harder because I couldn’t have the squirrel moving back and forth between the edges, because then it’d never leave the scene. Luckily for me, I still had a clear memory of HitTest and If-sentences. I figured that if I made objects in the scene, like two green balls matching the ground and making them invisible, that I’d make move forward with the environment, it’d work. Sort of.
I made my two green balls on the ground, pretty far out in the environment, and had them moved in as my character walked. I made them with a red outline so that I’d see where they were. When they were moving as they should, I added my squirrel. Of course it started spinning again once it hit the green ball, but a little fixing with some values randomly around my script finally made it look less…utterly stupid. I’ll add a little screenshot of what my little invention looked like.
After my squirrel was moving happily around in the scenery, I made a hitTest of what would happen if the character should hit the squirrel. I decided to make the squirrel a Sprite and added a onHit animation, or rather a picture. I also added a blank frame in the characters Sprite that I’d activate once it hit the squirrel, so that it’d disappear.
I also removed all Listeners to make everything freeze once the hit. All of this I put into my If/hitTest-sentence. I actually like If-sentences because I think it makes sense. If something happens then { something else happens }.
One thing I was not so happy about was that I can’t get my RemoveChild to work, it only gives me loads of errors and ruins everything. So I used a lot of Alpha all over the place. Both to make things disappear and appear, like points and text, but it still feels a bit like cheating although we’ve not learned how to do it differently. I hope it won’t be a big deal in the end.
All in all I’m satisfied with how this case turned out. But I’m still quite disappointed that our teacher doesn’t teach us what we need to know in order to complete the task, and instead gives us a script that I at least have no idea of how actually work, I just know that it does. I thought it’d be interesting to learn scripting, and I think it would’ve been if we were taught differently, but right now I’m just happy to be done with it for now. I wouldn’t have been able to complete these cases if it hadn’t been for good classmates and some helpful advice at the lab. I hope things will be different in spring, when things get harder. Right now I’m feeling like I have to learn a new language and I’ve been given a short text in order to write a novel, without knowing half of the words I have to use. It’s really frustrating and I hope that things will change for the better. Mostly because I think scripting could be really interesting and actually fun! Sometimes when I did these cases I found that I enjoyed it and wanted to know how things worked. Sometimes I’d sit down and try to do things that we weren’t told to do, just for fun, but because I do not know the words I can’t write the sentence. Even if I know what I’d need. I actually made my character jump without help, but it only jumped while I pressed the button so it was quite annoying. Still I made the jump and I made the character move while it jumped and I made it pick up points while it jumped. Just to see if it could work the way I thought it would. But I removed all of it, because it wasn’t good enough or part of a case. I’ve decided to not make any more of this subject than I have to. Just be done with it. It has taken most of my time when I’ve done my homework, and I’ve decided not to let it anymore.
Click to enlarge pictures.