Today I was mostly working on getting the shopping cart up and running, but I also worked a little bit on the garbage generation system. While I was doing a test run I noticed that I was sometimes getting ten or more bad garbage in a row. I found this became frustrating and boring very quickly so I knew I had to make it so that a good garbage would drop every few bad garbage, making sure there was always a goal on screen for the player to work towards. I had to partly rebuild my garbage generation system but it's defiantly for the better now. I was using a while loop to try and generate a piece of garbage, if the garbage selected was too expensive then it tried again. One problem with this was that only the good garbage had a chance of being rejected since the bad garbage doesn't take away from the remaining points for the current level. I fixed this issue by moving the while loop to inside the good garbage generation inside the general garbage generation function. This way if the good garbage was too expensive it would try for another good garbage instead of possibley spawning a bad garbage instead. I also put in a counter that, after four bad garbage have spawn makes it so it automatically spawns a good garbage next, just in case the random numbers keep coming back bad garbage.
For the shopping cart I have it so if your at the front and it hit, the cart bouncing back some and your rubbish is pushed the other way for a second. It also takes away one health when it hits. I get around having to make giant leaps over the whole cart I added in that if you land on the top of the cart it bounces you up to near the top of the screen, you can't jump any more after that but you can fall quickly if the down arrow is pressed. In the video that's posted the bouncing off the top of the cart hadn't been added yet.
The last thing I add is that once a jump is started you can only travel in one direction. After coding it though I didn't think it was as fun to jump around so I've commented it out for the time being, however I might change my mind after I've tweaked with the jumping some more.
This blog reflects my progress that I make on different projects as I work my way though them :D Wish me luck
Showing posts with label code. Show all posts
Showing posts with label code. Show all posts
Thursday, 6 September 2012
Carts hurt
Thursday, 30 August 2012
Book flipping
Today I spent a little bit of time working on getting my book for the instructions page up and running. I had to finish the final book section animation and then copy and reverse all the page flips so the pages can be flipped both back and forth. I then created a book class that contains all the functionality for the book so on the instructions page all I have to do is create it and call it's setUp function.
I'm quite happy with how the coding went, I was able to sit down and get almost all the coding done without needing to test it much, the only thing I forgot to add the first time were if statements checking to make sure that when you went to move forward you weren't on the last page in that section, or when you went to move back that you weren't on the first page of that section. I'll come back and fill in the instructions once I more of the game completed. I built how it changes pages and sections so adding more of either wouldn't be too much work, if I want another section I'll have to do a little more rough drawing for page and section flipping.
Wednesday, 29 August 2012
Mini me
I've been working on getting the mousetraps to work, killing a rat if it's ready when the rat walks past it. I also have it so once the trap has been released, a counter starts that doesn't allow the trap to be rearmed until a given amount of time has passed, which can be reduced by upgrading the mouse trap speed stat.
Another thing that I worked on is getting it so the hit detection area for the garbage isn't based upon hard-coded numbers, but instead based upon where I place the top and right hit points, the bottom and left are based off the origin. This allowed me to remove the generic background I had been using as the basic hit box, and instead have the invisible hit box suited for each different shaped garbage. I also scaled down the size of just about everything, from the garbage and mousetrap, to the rubbish and rats.
Lastly I've added in a background to the level that changes depending on which level the user is currently playing.
This is a video taken before most of the work was done described in this post.
This is a rough animation I did for the instructions book.
This is a video taken before most of the work was done described in this post.
This is a rough animation I did for the instructions book.
Friday, 24 August 2012
SO MANY RATS
So I've made some major strides with my Rubbish game over the past few days. I had a lovely fatal error that was causing my flash program to crash whenever it encountered the problem, the really annoying part was it was randomly happening and since it was crashing flash I couldn't even read the traces to find out where the error was located.
Luckily I had time and process of elimination by my side and after commenting out large, then progressively smaller chunks of code, I was able to find where the problem was located....i can only assume. The strange part was it had to do with my garbage spawning however the problem shouldn't have been one. To decide wither the garbage that was spawned was going to be good or dangerous I had a random number chosen, 1 or 2, using my randomNumber function. Then if the number was 1 I would make my isBad Boolean false, else i would make it true, I would then pass this along to my garbage class and it would use the Boolean to choose from the correct array of items. This should mean even if for some strange reason the randomNumber function was wrong and I got a number that wasn't 1 or 2, a garbage would still be created. If I always spawned a good garbage, flash wouldn't crash, and if I always spawned a bad garbage flash wouldn't crash, I just commented out the if statements and the randomNumber generation and hard coded in the true or flash in the setUp function of my garbage.
I was finally able to fix my problem by simply having the same code, but in my garbage class so the playScreen class would just spawn a garbage and then the garbage would figure out if it was good or bad, using the same method I was trying to use on the play screen. For some reason I haven't had a crash since even though it shouldn't make a difference wither I do the randomNumber and Boolean assignment inside garbage or outside and pass it in.
I was able to get rats added, with different amounts and types spawning depending on the current level the player is on. The rats move forwards and can only be killed if the rubbish jumps and falls on them. If a rat makes it all the way to your garbage pile alive, it takes the last item you caught, along with the number of points it's worth and runs off screen. Soon I'll be able to add a few more btns to the level select screen and I'll have my basic first five levels complete.
Luckily I had time and process of elimination by my side and after commenting out large, then progressively smaller chunks of code, I was able to find where the problem was located....i can only assume. The strange part was it had to do with my garbage spawning however the problem shouldn't have been one. To decide wither the garbage that was spawned was going to be good or dangerous I had a random number chosen, 1 or 2, using my randomNumber function. Then if the number was 1 I would make my isBad Boolean false, else i would make it true, I would then pass this along to my garbage class and it would use the Boolean to choose from the correct array of items. This should mean even if for some strange reason the randomNumber function was wrong and I got a number that wasn't 1 or 2, a garbage would still be created. If I always spawned a good garbage, flash wouldn't crash, and if I always spawned a bad garbage flash wouldn't crash, I just commented out the if statements and the randomNumber generation and hard coded in the true or flash in the setUp function of my garbage.
I was finally able to fix my problem by simply having the same code, but in my garbage class so the playScreen class would just spawn a garbage and then the garbage would figure out if it was good or bad, using the same method I was trying to use on the play screen. For some reason I haven't had a crash since even though it shouldn't make a difference wither I do the randomNumber and Boolean assignment inside garbage or outside and pass it in.
I was able to get rats added, with different amounts and types spawning depending on the current level the player is on. The rats move forwards and can only be killed if the rubbish jumps and falls on them. If a rat makes it all the way to your garbage pile alive, it takes the last item you caught, along with the number of points it's worth and runs off screen. Soon I'll be able to add a few more btns to the level select screen and I'll have my basic first five levels complete.
Friday, 17 August 2012
Let the trash collecting begin!
Over the past few days I've finished up the shop screen for now, adding in a pop-up window for buying your lives, stats and equipment. This shows what your saving if you've bought the bargaining chip and what the total cost is going to be. I've also made quite a lot or progress on the main game, the rubbish can now jump, can only move between two boundaries that I've set up, and he also has has health. Good and bad garbage falls from the top of the screen, so many good garbage fall on each different level, and the number of bad garbage that can fall is based upon that number. It currently counts down the number of good garbage left to fall, the amount you've caught and the ones you missed. Also when you get hit by a bad garbage your health goes down.
The level is finished once you either get hit and lose your last health, or once you've collected the last good garbage/let it fall to the ground. If you died or didn't meet the required good garbage points/ catches for that level then it only shows a 'try again' option and a 'level select' option, other wise if you've beaten the level then it shows a 'shop' and 'inventory' button as well.
I've also gotten some rough art done for the good and bad garbage, so it's easier to tell whats dropping while I'm building the game.
I'll update with pictures later.
The level is finished once you either get hit and lose your last health, or once you've collected the last good garbage/let it fall to the ground. If you died or didn't meet the required good garbage points/ catches for that level then it only shows a 'try again' option and a 'level select' option, other wise if you've beaten the level then it shows a 'shop' and 'inventory' button as well.
I've also gotten some rough art done for the good and bad garbage, so it's easier to tell whats dropping while I'm building the game.
I'll update with pictures later.
Labels:
as3,
code,
creating,
development,
fun,
game,
health,
interesting,
ken,
new,
popular,
rubbish,
spawning,
top,
wheadon
Tuesday, 10 April 2012
The fights are starting to look fair :D
I've been able to get most of the combat done today. I added in the blood effects for the pistol, sub and shots along with adding in ammo for the sub and shot. I've decided that the player has unlimited pistol ammo, don't ask why or how just be thankful, this was mostly to get around the difficulty of some zombies and how both attacks were needed to get past some tougher zombies healing. I fixed the exp bar at the top and the addition of the exp for the final zombie kill. I also was able to greatly improve the zombie AI along with it's stats generating around a more reasonable level. I also added a combat stats screen that shows up once all zombies have been defeated, this shows you the exp you have, still need along with the ammo and money you've found and how much you now current now have. I have just a few finishing touches like adding a finished button to the combat stats screen. I also have to clean up some of the animations and attacks.
Subscribe to:
Posts (Atom)


