Showing posts with label breakout. Show all posts
Showing posts with label breakout. Show all posts

Sunday, June 21, 2009

Breakout (XNA) - Update 7: Level Creator

Remember that level creator I kept mentioning would be cool, but never actually got around to creating? Well, that's history now, because I've finally managed to build one. Ok, so it's a little basic, but a person can now go in and click where they would like to place the bricks. Then it saves it to an XML file to be used later. Right now only one level can be saved at a time, so creating a new level will kill the old one, but I hope to fix that at some point and allow the player to choose which level they'd like to use.

Creating this level creator actually wasn't too difficult... saving it was a bit of a pain though. Luckily this tutorial was there to make things a little easier. It helped a lot with reading the XML files. Then I happened across this blog that taught me how to write the XML files. Of course I was still having problems since I wanted to store a number of bricks and the information in each file. At first I was passing the individual array fields to the serializer, but that wasn't working. Then I tried passing the entire array, and that was much better, but still wasn't giving me a readable array type (you'll see what I mean if you look at the XML file and the pages I gave you). Finally, I passed a list as the parameter. For some reason, it took me way longer than it should have to figure that out, but at least now it's working. And it turns out that working with XML in XNA really isn't too much of a problem in the first place. If you find you still need help with the XML after reading those two pages and checking out my code, let me know. I'll do what I can.

So, check out the code and have a look. Maybe you can make some improvements. Maybe put in some file handling to create new files for each level, or maybe even a way to edit previous levels. Hmm, sounds like fun! Either way, I think my time with Breakout is winding down. Maybe I'll do a few more things like figure out the file handling aspect, but other than that, it may be time to move on to bigger and better things. Please let me know what you think or if you have any suggestions. I really haven't been getting much feedback and even a "what's up?" is nice sometimes! Have a good one and, good luck with the coding!

Thursday, June 18, 2009

Breakout (XNA) - Update 6: Adding Sound

I finished my 3D tutorial which was really cool. I'm starting to think that the move from 2D to 3D won't be too bad. My 3D modeling skills with Blender still aren't the greatest, but maybe they'll come along. Hopefully I'll run into someone with artistic ability before that though, since mine is certainly a long way away.

Anyway, other than being cool, the 3D tutorial taught me how to use sound with XNA Game Studio. It's really quite simple... at least for the basics. Just open up the Cross-Platform Audio Creation Tool (using the correct version), start a new project and save it in the audio content folder of your XNA project, create a new sound and wave bank, add .wav files to the wave bank, and then just copy and drag them to the sound bank. Then you just basically load them into your XNA project much like you would image files. Simple as that. If you want to know how to load sound, but don't care for the 3D aspect of game programming yet, just check out the sound section of the 3D tutorial.

I've also made a few other small improvements to how the game works. I added separate screens for the title screen, pause screen and game over screen. I also had to create class that inherits the EventArgs class so I could pass arguments (which was necessary so the game knew whether the pause button 'P' was pressed or the game was over). That took a while to figure out, but a decent example can be found in here in the MSDN Library.

Other than that, I've come across another problem. When the ball hits the top, it kind of just doesn't come back down. I think I need to find a better way to work the collision detection... actually I know I do. Maybe I'll look into that in the next little while.

Oh, and sorry the sound is kind of dull. At least it's a sound that works.

Tuesday, June 16, 2009

Breakout (XNA) - Update 5

Well, my progress through the XNA 3D tutorial was halted abruptly today as the XNA Creators Club site went down for maintenance. So, it was back to the Breakout game I've been working on for the past little while. It turns out it was worth it. I learned to create a title screen for the game... well actually, I can now create any number of screens for the game. It's really pretty cool, and quite simple if you understand how to use new class objects. The person who posted the tutorial, George Clingerman, called it changing states with "Polymorphism". I haven't really read up on polymorphism, so I'm not really sure what that means yet, but I was still able to work my way through the tutorial and understand it all. Though, now that my interest is sparked, I think I might check out a few pages on the subject anyway. Mr. Clingerman also gives a couple of other simpler ways to change states, along with a number of other helpful tutorials on XNA, so definitely give his site a look if you're interested.

As for the Breakout game, I was hoping to put in some sound effects, but that was tied directly into the 3D game tutorial since they explain it there. Needless to say, that didn't get done. I'm also thinking I'm going to create a sort of point and click level creator or something. Or maybe I'll just start making a cooler game... who knows? Check out the source here and figure out how the state changing works. It's really not to complicated.

Sunday, June 14, 2009

Breakout (XNA) - Update 4

Just a small update today. I managed to have the ball speed up to a certain point. Of course this doesn't make the game extremely interesting, though it does create a little bit more of a challenge. Changing the angle at which the ball bounces would also be nice in my opinion. I'm just not sure how to go about doing this. What I mean is, I don't know what should effect the angle the ball moves. I'm thinking it will have to have something to do with the location the ball strikes the brick or the paddle. I'll figure it out soon enough.

I've also been playing around with getting some sound going. I don't think it'll be too difficult, but I got kind of lazy while reading through the help at the XNA Developer Center. It'll get done eventually since I have to learn about XACT anyway, but probably not today. I'll keep you updated. (A little .wav file is included in this file version if you're interested in trying yourself)

Finally, I created initial rectangles for the paddle and the ball. Previously, I was creating new rectangles on every update, however, I thought this might be the cause of the game getting choppy. Now, I just change the position of the rectangles on every update. Unfortunately, that didn't fix anything... at least as far as I can tell. I'll probably have to learn how to debug properly or something to figure this out. And that's it for this update. Check out the source code, and I'll keep updating the progress of the game.

Thursday, June 11, 2009

Breakout (XNA) - Update 3

So, I've managed to get a little more completed. Seriously, I'm really liking this whole XNA thing. It makes everything so easy. The coding appears to be much like Java, so for me, that's a bonus. Though I don't think it would be difficult for anyone to learn. As for what I've got done, I added some different color bricks with the color changing every time the brick is hit. This is how we can indicate how many hits are left to break the brick. I've also stopped the ball from bouncing off of the bottom. Now, it just goes back to a starting point. The game also ends now when you run out of lives, though I don't have it set up to restart yet. Of course, I doubt anyone would get that far in the game because it gets boring fast.

Things left to do:
  • build cooler levels (and a way to build cooler levels)
  • change angle and velocity of the ball
  • allow game restart
  • stop the game from getting choppy about 30 seconds in
  • sound effects
Of course there is more to do as well, but that's a start. I'm starting to think a game is never truly complete. No matter how simple it is, there's always something left to do. It seems as though when I finish one task, I think of another one that needs to be done. Anyway, go here for the source as usual.

Wednesday, June 10, 2009

Breakout (XNA) - Update 2

Well, the breakout game is coming along. Now, we've got some points and lives. The cool thing is, I've been able to make it this far, pretty much by simply watching the 2D tutorial for XNA, so it's obvious that the framework has a lot to offer for people who are just starting. Of course, no one these days dreams of developing a game like Breakout, but it's a start. I can't wait to get on to the 3D graphics. Then again, I will still need someone to design the graphics. Either way, we'll cross that bridge when we come to it.

Back to the Breakout game, there are still a bunch of things that need to be taken care of. For example the ball doesn't go through the bottom yet. It just removes a point if it hits the bottom. I've got it now so that bricks can take more than one hit before they disappear, and the more hits they require, the more points they are worth. This is cool, except right now it's totally random, and there is no way to distinguish how many hits a brick has remaining. It would also be great if I had some way to design levels. Right now, it's just a simple grid and bricks are placed side by side and on top of each other. That's really boring. Finally, I think the game slows down part way through. I don't know if it's just my computer or not, so if you have the same experience, let me know, and we'll have to figure out what's clogging it up!

And, that's about it... check out the game at the Open Games For Beginners download site!

Monday, June 8, 2009

Breakout (XNA) - Update 1

I've added a little more functionality to the Breakout game. Now the ball moves around the screen and kills the bricks. It just bounces of every wall though at 90 degree angles and it even bounces off of the bottom instead of killing a life. This is kind of dull and gets quite boring after some time. Maybe it would be nice if the ball sped up or at least changed angle. I guess this is where a little more math would come into play. Another problem is that the ball doesn't always properly bounch off the paddle if it hits the side. Though, I'm sure this can easily be fixed. There must be better methods to detect collision than rectangular collision.

Other than that, there are still obviously some improvements that can be made. Obviously keeping score and some new levels would be nice. I'll keep you posted if I make any improvements or if anyone else makes improvements to the code.

**I also haven't gotten around to explaining any of the Java Pong code yet, but I will. I just have to get this XNA stuff out of the way for my university course first.**

Sunday, June 7, 2009

Breakout (XNA)

So, I've started up a Breakout game. I know I said before I'd try it in C++, and I may still yet, however, I got going with XNA and well, I figured I'd try Breakout with that. It's probably because I'm not the most creative person in the world at times. Anyway, it's going fairly well. I've got some bricks to break as well as a moving paddle. XNA is really fun to learn and I imagine it will only get better. So check out the code from my Google site and play around with it. Let me know if you make any cool changes and I'll put them up along with credit. If many people start to be interested, I'll toss it up as open source. As for some possible changes to the game, here's a short list:
  • a moving ball is necessary
  • score keeper
  • collisions with bricks and paddles
  • different levels/layouts
  • level creator would be nice
  • life tracker
  • opening screen
Obviously there can be much more added, but these things would definitely make the game much better. Just a little side note about the XNA Creators Club... it's a really cool place, but in order to share and play with each others' games, you need to be a premium member, which means you need to pay. I'm not really about paying for stuff, especially when I'm just beginning, so I'll just be posting my games on my site and then if people start becoming more interested, I'll post them on an open source site. Making some open source games for Xbox360 would probably be pretty cool anyway, so lets see how this goes.