Wednesday, December 30, 2009

....riiight.

So, I'm being a complete tard and forgot to post a preview of the final game. I might have said this earlier, but there are still some minor bugs, but the game i play-able :)

You can try it out here : FlashBob Adventures

(yeah, the font is bugged because I've formatted my machine and forgot to take a backup.)

Monday, November 30, 2009

Final Post about the Final Case

So, here we are at the end of the road. After about three months. It has been a fun journey, and very educational for my part. I started out not knowing anything about Flash, ActionScript or programming i general. Now I have a nice idea of how things work. By doing all these cases every week i've gathered a lot of info about programming in the ActionScript 3.0 language. From time to time it has been very, very, very frustrating. But I guess that's part of the life of a programmer. And when that time comes, the only thing you can do is sit down before the code and reed through it 'til you find the errors. Well, dunno really if anyone has followed this blog, but if you actually have, I hope it has been worthwhile your time. And maybe learned something yourself. Who knows.. Enough about this. Let me get to the point of this last case. And that is how to put the startmenu, win and game over screens into the game and make the work. In my opinion the most ballbusting and frustrating case, but also a fun one. At least until you run into problems that is ;)

Okay, so let's get down and dirty. I just said that I was going to put all the sreens into the game. But before one takes on such a task you must think of how you want the menus to behave and in how they're stacked. I didn't draw anything, but I made a picture in my head of how I wanted the menu to be. We're talking about a studen making a game in Flash, so the complexity of the menus is rather low. Well, keeping all this is mind, the code itself needs a major overhaulin' because 'til now the game was in the constructor, wich started the game as soon as I pressed Alt+Enter. Now instead of the game staring right off the bat, you want the Start Menu to appear. So basically I had to remove everything I had in the constructor, and make a new function. I called it creatGame, and basically do what the constructor did before. Then I made another new function, that creates the start menu and add eventlisteners for the how to play screen. Then enable the startbutton to run the createGame function. Basically I had to rearrage all my code, and make about 6-7 new functions that intertwined make the menus work. I don't think I'll bother wriing the code here. It'll suffice to say that it was a lot of work. And to my joy I was able to make the start menu and the how to play menu work perfectly. The game over / win screen were more a pain. To make the game over screen work I just added an if in the update function and said that if the players life is zero, or if he falls of the level he dies and the game over screen is to be created, and the game, with all it's objects is to be removed. The win screen on the other had has been everything but cooperative. I almost set it up to work identically to the game over screen, exept that for the win screen to appear the time must run out without the player dying. This oddly enough didn't seem to work. Just the occasional random time from time. I had fellow studens look at my code, I had fellow labassistants look at it. But everything seemed right. Finally I just gave up. My time was running out, and besides turning in the game for evaluation and not flunking the course, I have exams and other stuff to tend to. So I just let it be, 'couse after almost a week of fiddling with that screen I ended up making more bugs. Thankfully I had the code copied before I tried to fix stuff. So, I just hope it's enough to pass. I got everything else down. And I've learned a great deal, so I'm happy with what I've accomplished so far.

Thanks for reading my blog, and maybe I'll keep on writing about school stuff the next semester, who knows.

Thursday, November 26, 2009

Case 10

This is the final case in this project. Once I've completed it I'll be done with the game.

Unfortunatley, I had a setback, so I haven't yet got to this point. I'll post more about it later though.

Ahh! Maybe I should tell you what the case is about :) It is about putting in all the screens. The start screen, win/loss screen, controls etc.

Since I haven't been able to show you previews is a while, I thought I'd upload one now. Just keep in mind that there is still stuff to be fixed :)


Case -- WIP preview by ~Elr0hiR on deviantART

Tuesday, November 24, 2009

Case 09

I'll sum up this case in one post since it is a pretty simple one. And the idea here is to add sound to the game.

This is a pretty straightforward process. You just find the music and sounds you want and import it to your flash file library. Then you prep the sounds to get exported to ActionScript. Coding-wise you just add media at the top like this import flash.meda.Sound; and import.media.SoundChannel; and finally import flash.media.SoundTransform; (for cleaness sake I just added import flash.media.*; the star just means that you import everything from media).
Now, I'll first tell you what these three thing do. Basically it makes it possible to use sounds. The first one enables the soundfiles you want to use, the second one is used to layer the sounds. For instance, you want to have a soundchannel for the themesong and other ingame effects. Then you can use a second channel for the soundeffects you character make. And thid for you enemies.
The last thing you imported was the transform functions wich makes it possible to transform the sounds, like turning the volume up and down. This especially practical when you have soundchannels. Let's say that you really can't hear the soundeffects you'r character makes while ingame due to the theme music. Then you can simply increase the volume on the character soundchannel. And voilá, you fixed the problem, nice and easy.

Let's get back to the code. After importing the media, I added variables for each sound, channel and transform.
Then you just add the variable where you want the sound to appear. Like adding the jump sound in the function that makes you character jump. The themesong at the beginning of the constructor so it starts playing when the scene is created.

This was in my opinion a pretty simple case, and was solved fast without any major problems. I would add a preview, but since I'm revamping the game, things don't quite work as they're supposed to. You'll have wait for the final game to be finished. I wouln't hold my breath though. Even though I'm pretty sure I'm going to have it finished by a week.

Thanks for reading! :)

Sunday, November 22, 2009

Case 08 - Final

In this case with arrays and timers I decided to use them on my enemy class. What I did was make an array that creates 5 enemies at the top of the screen, but placed randomly each time. Then I added gravity to them so that when they spawn, they fall to the ground and follow the player. In my head this worked better, so I donæt think I'll be using this for the final game. But I did get to implement both arrays and timers for the case so I'm pretty content with that. I would upload a preview but as I started to work on the next case I accidently started working on my case 08 so for the time being a lot of stuff is screwed and not working >_>

Anyway, I'll tell you a little bit aout arrays and timers. At least what I've understood 'til now.

Basically when you make an array, input a number and then you can manipulate it. Like adding more to it, subtract og make it go through the numbers and start again from zero. You can do this by using the .push, .splice and .pop commands. You use this command under the array when you descibe what you want to create with the array.
In my case I wanted enemies, so I wrote the basic code to place an object in the scene;
blobb = new BlobbMain();
blobb.x = math.Random/1000; // this gives me random numbers from 0 to 1000, wich is the width of the scene
blobb.y = 0; // I want them to spawn at the top of the screen.
blobbArray.push(blobb) // blobbArray is the name of the array, and (blobb) is the object I want pushed in the array.

I still don't fully understand the arrays, but I'm getting an good idea to what it can be used for. I'll move on to timers. I wanted my character to blink when struck by enemies or when dying. I decided to go with the latter.
To do this I made a timer called "blink" like this:
var blink:Timer = new Timer(150, 20);
The numbers are the time - I want the character to blink - in milliseconds. When this is done I also make a new boolean and basically make a function to check if the player hits the enemy, if it does and looses all life, it starts to blink and then disappears, and you're dead. :)

And that's it for now :D

Saturday, November 21, 2009

Case 08

Arrays and timers. What are these you may ask. Well I'll tell ya. Say you want multiple objectes to be created in the scene. In stead of writing 3134 lines of code, you can simply bake one array on a couple of lines that create a set number of objects. Timers are just that; timers. If you want to make something happen for a period of time you need a timer, if you need something to happen after a period of time you ned a timer.
Timers are basically stopwatches you can attach to things, and give them a duration, or whatever you want.

The thing I wanna use this stuff for if for my newly created enemy class. I'm gonna try to use arrays to spawn a set number of enemies on random locations each time.
I'm then going to try to make the player character blink a couple of times when hit by enemies by using timers.

Case 07 - Final

This is kinda late, I know.. Been buisy doing other school stuff so I kinda forgot to blog =_=

So this case was about mutiple classes divided on different actionscipt files. This is called OOP(Object Oriented Programming) and means you write several codes in different files. This makes it easier to arrange stuff, and you can use different classas you create on different elemtents. A nice exaple is veihicles, say you make a base class for different cars, they all share the same base properties, like they drive forward, can turn to the left or rigth. But you might want to make some cars faster than others, and some that can withstand more than others. By making a base class you can just change the properties on the different cars, instead of writing code from scratch for each car.
OOP also gives you a better overview of your code, because instead of having 1000+ lines, you split it up in several files.

That being said, this case was about making a new class for the game, namlely an enemy class. What we're supposed to do here is make a new ActionScript file and start from scratch to write the code. When this is done you can use the enemy class you've created and import it from the main ActionScript code. This saves space in the document, and you can easily browse through the classes and change stuff.

I won't bother writing all the code of my enemy, but I'll tell you roughly what I've done so far. So, I wanted enemies to spawn in the air and fall down to the ground and attack/follow the player. This is done by telling the enemy that if it's value of X is greater that the players, it is to reduce the X value by diminishing the value. In other words, the enemy stive to have the same X vale as the player. This is the most basic enemy AI you can get. But it is enough. At least for me :)
Finally I had to add object detection, wich means that the enemy doesn't go through walls. I did this more or less the same way I added gravity and hitTestPoint to the player. This means that when the enemy hits the ground, he doesn't go through it.

Here's a preview of the game so far.


Case 07 by ~Elr0hiR on deviantART

Monday, November 2, 2009

Case 07

Short about the case:
Case seven is about classes and how we can work with more than one .as file to get more organized. To test this out I'm going to create an enemy class and hopefully make the enemy follow the main character/player.

Sunday, November 1, 2009

Case 06

Game development/design.
The previous week's I've been pondering about the design of the game. Basically figuring out the story behind the game, and the scope.
It's not final but I think I got the disgn pretty much down. The game is going to be a pretty much straightforward platform game, where you gotta pick up points and save the world(nothing less!) :D

Friday, October 23, 2009

Case 05 - Final

Hey ho.

Been a while now. Hasn't really happened that much since I posted last time. I fixed the landscape and background but other than that I didn't see the point of changing too much stuff.

I'm going to eplain briefly how I went about with this case.

  • First I added two variables, one for gravity and one for velocity. These two wil decide the height and speed of jumps.
  • Then I added a function that, while also checking if the player hits the ground, enables you to jump. This is done by adding the gravity and velocity from the variables. Then I also specify an hit test that checks the players collision point hits the ground. In the line I've added true, this means that it tests the actual pixels and not the boundingbox of the ground movieclip. This enables me to have varied landscapes in stead of just a flat one.
  • Still in the same function I add a conditional that cancels out any attempts to jump while in air and already in a jump.
  • Lastly I add a function for the velocity of the jump.
You've already seen the result in the previous post, but I'll add the updated one :)



Case 05 - Revised by ~Elr0hiR on deviantART

Thursday, October 15, 2009

Case 05 - pt. 1

Hello there!

Today we had the lab at school where the assistants go through the case and explains the new concepts we're supposed to implement. In this case physics and collision detection. I pretty much uderstood most of it, but I wan't sure as of how to put the stuff in my code. After a couple of tries, I ended up screwing things up so they didn't work at all.. When i compiled the code I didn't get any errors, but my character didn't show up on the scene. After some fiddling I got the character back, but I was unable to move it. So I decided to rewrite the code from scratch using my own code from previous cases. Then I got some help from Steffen to add the functions in the correct oreder.

So what I have now is a rough example I'm going to tweak a bit.


Case 05 by ~Elr0hiR on deviantART

Tuesday, October 13, 2009

Case 05

So yesterday we got our fifth case. In this case we're basically making the movement of the character more advanced. Now in stead of just walking back and forth, the character is actually affected by physics, like gravitation that keeps the character to the ground, and also limits the jumps so it doesn't just fly off the screen.

I've checked out the example code and tried to implement the physics stuff, but to no use. So I really don't have much to write about just yet. I'll keep you posted over the next week, so stay tuned! :)

Over and out.

Friday, October 9, 2009

Case 04 - Final

Hello.

This is the final report about the fourth case. I haven't had so many posts for the third and this case, this is because I don't really feel the need of writing about stuffe every other day. As it is getting more difficult, and me not being a born programmer I don't have breakthroughs every day. So I feel it's better is I make an inital post for every case and the sum up how it all went at the end of the week when I've (hopefully) managed to get to the geal :)

So about this case. I'm still having a hard time understanding all the stuff we're going through. Apparently I'm not the born programmer ^^
Anyway, with help from classmates I've managed to get things done. I may not yet fully understand everything, but it feels like I'm slowly learning stuff. I now know that I gotta have a package, I gotta have variables, functions that define the variables, and umm... yeah :)
I'm going to try to explain to you what I've done so far and give you a view of my product so you can test it out for yourself, beacause, yes I was able to make my FlashBob controlable with the arrowkeys :p

First of all I copied my previous case files into an new folder wich I called Case 04. Next up I got rid of fragments of the code that made FlashBob move by himself. Then I had to make new variables. This is what I did:
  • I left the variable for my character be. Then I made variable Booleans (wich basically checks if something is true or not later on). Then I made a variable to define the speed of FlashBob's movement. Set it to 15, wich again means he'll move by 15 pixels, unless I define something else in the function later on.
  • Next up i had to add Event Listeners, these "listen" if any buttons are pressed. And I set it the to check if a KeyIsDown and if a KeyIsUp.
  • Then I added a function that basically stops FlashBob from running out of the stage. This is done by adding conditionals wich ask a question. And the answer decieds what to be done. In this case I told AS that if the position of FlashBob is greater og smaller than the stage width it has to block him.
  • I made a function that decides how FlashBob moves. This is done again by adding coditionals. Since I'll have FlashBob run both to the right and the left I have to add to coditionals, one for each direction. So I got one called leftKeyIsDown and righKeyIsDown.
    • Then I define on what axis I want FlashBob to move, on this case the X axis and then the speed. Since I already have made a variable for that I just refer to it by writing += speed and -=speed. This states that if the left key is down FlashBob will move to the left since it's -= speed, and move to the right if the right key is down because the speed is set to += speed.
    • In the same contitional I also define what frame in my sprite I want to play, my running animation is on the second frame so I tell AS to gotoAndPlay(2).
    • Now, I don't want him to run forward and backward, I want him to always face the direction he's running. This is done by adding another line under the gotoAndPlay. Here I tell AS that then he is running to the left I want to flip FlashBob on the X axis, I do that by writing scaleX = -1. When running to the right i write scaleX = 1. The reason I don't have a + sign is that the original animation of FlashBob is running to the right, so there's no need to flip him over or change his scale.
  • Now I need a function that checks if the keys are pressed. To do this I first make a function that checks if the keys are pressed. And another one to check if the keys arent pressed. I then add the keys I want to use by adding the Key Code of each button. Key Code Overview 
And that's about it. I had a great deal of help on this one... again. I was already having some problems on the previous case, and this was by no means easier. But I've learned a great deal already.
Finally you can check out the product of my hard work here.


Case 04 by ~Elr0hiR on deviantART

On a side note I figured out to add music. You won't hear it it in the preview though. I'm saving this one for the finished game :)

Monday, September 28, 2009

Case 04

Hello.

Today we got our fourth case. So what I'm going to try to do the next week is to write a code that lets me control my character by pressing buttons on my keyboard.
I really don't have much to say at this point since I'm still just reading and watching some tutorials. But I'll be sure to post something interresting the next few days.

Stay tuned! =)

Saturday, September 26, 2009

Case 03 - Final

This is the last post about the third case. As mentioned earlier the scope was to use ActionScript to program the sprite, making it move back and forth in the picture "bouncing" off the edges.

It wasn't really before thursday that I figured out how to do it, all my other trys the days before failed as said. But when we were going through the case with the teacher and a lab assistant they got the same problem I had struggled with the last three days. This was a good thing, at least for me, 'cause then the teacher and assistant had to figure out what was wrong, and by doing that, they showed how to sovle the problem I'd been having.

So when I finally had succeeded in writing a code that made a box bounce off the walls, I changed the code so that my character would replace the box. This was pretty nice because for the first time that week I felt that I managed to get something right.  ^___^
Steffen aslo showed my how to flip the character so it wouldn't run backwards. That's pretty easy, you basically just add the if command and tell the character to .scaleX = -1 one way, and .scaleX = +1 the other way.

Anyway, now I'll tell you more specifically what I did to make this work and complete the third case.
  • First of all I created a new folder and called it "Case 03". This folder was my container for the animation (.fla file) and the script file (.as file).
  • Then I copied my flash file with the animations and my sprite into the folder.
  • Next thing to was was to open Flash and create an ActionScript File. That was the file in wich I wrote the code. Then I savd it as "Document.as" in the Case 03 folder. For this to work the .as file and the .fla file must be in the same folder, otherwise the script can't access the objects in the flash library and make the magic happen.
  • Next up was to ensure that the script file could associate with the .fla file, to do this I went to the properties of my flash document and named the Class of the file to Document - but without the .as at the end. As far as I've understood this has to be done if not the files won't communicate correctly and you'll encounter problems when the script is trying to use ojects from the library.
  • The last thing that had to be done before starting to write the code was to make sure the oject you plan on using can be accessed by the actionscript. To do this I went to the properties page of my walk animation (wich I had decided to use for the experiment) and made sure that:
  • The type of the objetct was Movie Clip.
  • It was ready to get exported for ActionScript.
  • Aslo export in frame 1.
  • Check that the the Class was Walk (the name of the animation).
  • Check that the base class is flash.display.MovieClip.
  • And finally choose the source almost on the bottom of the properties page. To do this I pressed "Browse", and found the .fla file I was working with. When I chose it a new window popped up with the objects in the library, I simply then marked Walk and clicked "Ok".
    • Now all the preparations was done and I could start to write the code.
    • What I did was to follow what the teacher told during the lab while the assistant showed what he wrote on a projector. I tried to write stuff by myself also, to see if I could remember anything from the books I read. Wasn't much though. It's still pretty overwhelming stuff for me :)
    • After writing the code, I added a shadow and made it follow the character while it moved from side to side. But took it away, and made the character turn around each time it reached a border instead, thanks to Steffen ;)
    You're probably getting bored of reading my post now, so I'll add a preview of the flash file with the character running back and forth.



    Case 03 by ~Elr0hiR on deviantART

    Friday, September 25, 2009

    Case 03

    Sorry I'm a little late on this case.
    Here's the first thoughts about my third case :)
    And it's all about ActionScript 3.0. My third case is to move a character on the screen without leaving it, only using AS3.

    My first thoughts about this were that it was going to get interresting. I didn't have any experience with programming, so I had absolutely no clue how it works. I mean, at the time I didn't even know what a code looked like..

    So on monday we got the case, and being eager to take on the new case I spent a couple of hours after school trying to figure out things. I read through the first chapter of Oriley's Learning ActionScript 3.0 A beginners Guide without understand much. It went over the basics, so at least I understood what some of the functions of the code does. Gotta read it again though. Anyway, after reading a bit I looked at the exaple files provided by the teacher and lab assistants and tried to figure out what went on. I tried to implement the example code to my own character, but it failed. After a couple of trys I figured I needed a break so I let it rest for the day.


    The following days I still failed miserably at programming the character to move forth and back on the screen.

    Here's what I was able to do the first couple of days:


    HALP by ~Elr0hiR on deviantART

    Tuesday, September 22, 2009

    Case 02 - Final

    Hey, sorry I'm a bit late on this update :)

    This is the last post about the second case. As you probably know the objective was to animate the character from the first case and make a complete sprite with a running, idle and jumping animation/cycle.

    I spent a lot of last week's evenings and nights with friends from class to complete the case. Even though it seemed quite simple and straightforward at the start, it was far from the truth.
    Making a sprite takes some planning, and you have to know what to do to plan out and do things in the right order.

    This is how I went about doing it:
    • I started out with my character in flash with all the parts on seperate layers.
    • Then by using the Bone Tool I started connecting them by building a skeleton on top of the character. This took some time because when I applied bones the Armature layer was place above the other layers.
    • After I had turned all the parts into movie clips and connected them with the Bone Tool I selected everything and made it into one movie clip. Now the character was done and ready to be animated.
    • Since I now had the character as an movie clip containing the parts and bones, I cleared the scene of everthing and deleted the layers with used to contain the bodyparts.
    • Now with a clean slate I started with the running animation, and after a couple of hours I had it done.
    • Now I created a new movie clip in the library and called it "Sprite", this was the contatainer for the animations. Then I opened the movie clip and dragged my running animation into the Sprite movie clip on the first keyframe.
    • To complete the sprite I did the same as above with the animations; I made a new keyframe inside my sprite and copyed the next animation into it. All in all my sprite contains four keyframs with four animations, one for running left, one for running right, one for jumping and a last one for the idle.
    And that's how it's done kids :)
    I'm pretty satisfied with the character but I've decided to change pretty much everything. New character new game idea etc.
    The reason for this is that I made a pretty complicated character now, and I've learned how to make a sprite and animate. So I want to make something more simplified and stylish, concentrate more on the game as a whole.
    So what am I going to make you may ask. Well, if you continue to follow my blog you'll find out ;)

    And that's all for this case! Oh, by the way, a litte preview of the jump animation(it's cycled so it may look a little wierd).


    Jumping cycle by ~Elr0hiR on deviantART

    Sunday, September 20, 2009

    Case 02 - pt. 2

    It's sunday now, and I'm pretty beat. I've spent almost every day(and night!) animating my character with some friends from the class, and some guys from the 2nd year.
    Don't know what to say actually, except that the guys who've been working with me and the ones from the 2nd class has been very helpful. I managed to make the four animations and put them together into a sprite.

    My conclusion in all of this is that I'm not really the animator type. I mean, it can be fun, but tweaking quirks and perfecting the movements of the character isn't exactly something I enjoy to be honest.

    Anyway now, the animations are done and I can relax for half a day, and then the programming starts. This is going to get interresting :)

    Monday, September 14, 2009

    Case 02 - pt. 1

    Being pretty exited about all that animation stuff, I'm still sitting at school and messing around with my character. After a lot of failures with the bone tool (as you might have read in previews posts) I finally figured it out and was able to apply the bones, thanks to some tips from Steffen and Joachim :)

    And I must say, animating is a lot of work. Getting the rough animation takes no time, but the tweaking to make it look fluid and nice takes a lot of work. I've already started with a running animation of my character, but even though I think I've nailed the basic movement, there's still a lot to do before I can say it's finished.


    First Flash Animation by ~Elr0hiR on deviantART

    Case 02

    New week - new case :)

    In this case I have to animate the character I've made. There are four animations I have to complete; moving to the sides i.e. walking/running left and right, idle standing position and a jump.

    Thursday, September 10, 2009

    Case 01 - pt. 2

    So, as I said, I'm supposed to design a character for a flash game. I really don't have any idea yet of how the animation process works, and because of that I feel a litte unsecure about how to draw the character.
    The only thing I know is that each movable part is supposed to go a layer of it's own, but apart from that I don't really know if there is anything I should do - or try to avoid.

    Well, now I've started to make the base of the character with some simple shading. What I've done is that I've imported the concept art of the character to flash and by using the pen tool traced the drawing, with each bodypart on a different layer. The head on one, the torso on another and so forth.
    The only annoying thing is that flash seem to work in it's own pace, sometimes it cooperates and other times it doesn't... wich can be frustrating, probably it's only my own fault. With some practice hopefully I'll master more stuff :)

    Here's a litte sneakpeek of what I'm working with so far:



    The one to the left is the concept drawn in PhotoShop, and the other one is drawn in Flash.

    Wednesday, September 9, 2009

    Case 01 - pt. 1

    So, now I've tried a couple of things. A bit of drawing, animating a ball using the different tweening methods. All I can say is that I gotta lay down som work hours on this since I'm not used to the interface and don't really have an effective workflow.. But I guess that's something that will develop as long as I keep working with Flash.
    Gotta admit though, drawing in flash isn't quite the same as say.. drawing in PhotoShop. At first I was kinda linke "Ewww". But, I'm getting a little more used to it by now :)

    Monday, September 7, 2009

    Case 01

    The first case revolves around creating the hero/main character for a platform game in flash. Also the character should be designed in a way that doesn't make the animating process too hard.