Tuesday, September 25, 2012

Day 22 - Another 8 Hours

Here's another full day of programming for me. I started to put in the star power up when I realized that I had already coded most of it! The file just wasn't included in my solution! Once imported I changed it to work with my new framework and bam, another new object. Getting Mario to actually become invincible was another matter though. It got me thinking again about collision detection and how to do it better. When 2 things on screen collide they both call the OnStomp, OnHeadbutt, or OnSideCollision functions depending on where each object is located on screen. Then each thing checks what it collided with and does the appropriate action... The thing is this collision detection really only needs run on objects which are moving (as un-moving objects will never collide with anything.) So for example if Mario headbutts a block it would enter the Mario class via OnHeadbutt(Block block), then Mario would react appropriately by stopping his upward movement, and finally it would call block.Activate() and the block would take whatever action it needs. This will be another setback because most of my classes will need re-written.

Then again, I could just leave it and continue on my merry way.

I also dug up a spikey enemy that I previously coded and got him working. Then I decided to add that invisible block which holds a 1-up in the middle of level 1-1. Currently it's just a regular block which isn't drawn on screen. Mario can still stand on it and it also blocks his horizontal movement... Yet another reason why I want to rewrite my collision detection...

I fixed a few other bugs and as a finish for the day I added all the objects to the first level. Aside from the special area through the pipe I almost have the first level completely finished!

No video for today...

Monday, September 24, 2012

Day 21 - 8 Hours a Day

What a day for programming! I had a great time working out some bugs and adding new content to my game! I swear if I could work like this everyday, then I would be finished with this game in under a month.

I started out by adding a loading screen which shows the level number and how many lives the player has. Then I thought "You know what I'm missing? A heads up display!" So I implemented that as well! It's printed on top of everything else and simply shows the player's score, coins, and level. I might use it later for debugging as well.

At that point, I added points for all the enemies and then figured I should fix the bugs with how enemies interact. The turtle shell now properly kills other enemies only when it's moving, Mario's fireballs explode when they hit enemies, and Mario can properly die now! He still has some issues moving from big Mario to little Mario but that's for another day.

Finally, I added the flagpole and a second level. The end animation is kinda janky and I didn't have a flag sprite in my spritesheet (so I just used a coin instead,) but it works and moves onto the next level.

I think I need to start tracking bugs and new features to prevent myself from getting sidetracked. It's hard to keep track of everything. Once I finish adding a feature, I often forget where to go next and spend time browsing Facebook or playing my game looking for bugs.

Here's a video of me screwing around with enemies!

Thursday, September 20, 2012

Day 20 - Game State Management

Game State Management is perhaps the most fundamental thing about game programming. I've been avoiding it until now, but I need to start implementing lives and new levels soon. To do this the game needs to transition between different "states". For example, one state would be a title screen, one state would be the actual gameplay, and finally a game over state. To make all this happen, all the logic needs to reside on screens. When one screen exits, it will destroy all the images and things it was using before the next screen is loaded.

There is a great example about GSM in the XNA tutorials. It contains a bare-bones screen manager with a bunch of example screens. In about an hour I merged this code with my game and got it working. Now there is a menu screen which transitions to the first level when the user hits enter on their keyboard! Whooooo!

Things to do from here:

  1. Spruce up the title screen
  2. Add a level transition screen which shows the level number and number of lives left
    1. When the level starts or Mario dies the level transition screen should be shown and the level should be restarted
  3. Add a transition to the next level
  4. Add a Game Over screen which routes back to the menu screen
I've been super busy this week (getting home around 7pm everyday!) so I haven't had much time to work on this. I'm gone for the weekend but have nothing to do Monday and Tuesday so hopefully I'll get a lot done then!

No video for today...

Thursday, September 13, 2012

Day 19 - A Good Day

Some days my code just comes together and I can get tons of work done. Other days I can stare at my screen for hours and only get a few lines in. Today was the former.

I got my collision detection all finished up. Now I'm working on writing interactions between different game objects. For example, only Mario can break blocks and hit question blocks. Enemies need to bounce off each other and walls. Mario needs to power down or die when he hits an enemy. Everything needs to be accounted for.

This was also the first time I tested my Koopa Troopa enemy since I wrote it a week ago. I was surprised that it worked fairly well when I first loaded it up. Just a few more tweaks and we're in business!

Here's me playing around in the world.

Wednesday, September 12, 2012

Day 18 - Collision Woes

Now that I've changed blocks into game objects instead of tiles it completely changes the way my collision needs to work. Previously since all the tiles were laid out on a grid I could quickly retrieve a tile given any position on screen. Now since the blocks could theoretically be placed anywhere, I need to iterate through them and then each object needs to figure out what to do when it collides with it. This sounds like a lot of work and... It is.

No big changes and no video for today. My brain isn't working.

Tuesday, September 11, 2012

Day 17 - Adding and Removing

I finished up my level builder! All the game objects are added and removed from the screen as the player moves around it.

Next up is dealing with collision detection. I commented out everything that I had in place before because I need to come up with a better system. I'm thinking of making a "moving object" class since the only moving things can collide with other things. I don't need to check if one stationary block hits another stationary block because that will never happen; It's just wasting CPU cycles. I'll need to sleep on it.

Anyway, here's my awsome changes in action!


Friday, September 7, 2012

Day 15 and 16 - Branching and Merging

I had to branch my code for the first time not because I was trying to implement crazy new features, but simply because I forgot to sync my code! I've been working on the level builder but when I went to work I realized all my changes were on my home PC. I didn't want to re-write that code so I made a branch and went along creating some new enemies. They haven't been tested yet but theoretically should work with a little more tweaking.

I merged the branch and master code together once home and continued working. The level builder is starting to come together! As Mario moves forward, new rows of blocks (and enemies in the future) are added to the screen. My FPS shot up from 1500 to 5000+ just with this change! Next up is removing the blocks and game objects once they pass a certain threshold outside the viewable screen. Then I just need to revise my collision detection algorithms and we'll be back in business!