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 :)