Thursday, June 25, 2009

Pacman (XNA) - Update 1

I've made a little progress with the Pacman XNA game. I managed to create the Pacman character, move him, animate him and rotate him according to the direction he is going. Now, moving the character wasn't a big deal since I've done that before, but animating and rotating was new to me. I don't have much else to say, so I'll briefly run though how each works:

Animation
This is done using a sprite sheet, which I've recently learned is multiple related images all in one image file. Simply search sprite sheet on google and you'll see many examples. Of course mine wasn't as complicated as some of the others out there as it only has four different positions (though I could have gotten away with three). Anyway, basically all you have to do is organize the sheet into rectangles around each individual sprite and loop through them. There is a parameter to the draw method that asks which rectangle you'd like to display from the sheet. Check out my code, or just read some tutorials. It's not too hard to figure out.

Rotation
Rotation was also fairly easy. In the same draw method, there is a parameter for rotation. It asks for a float value and works in radians. So I just kept track of the rotation of the character, so that when it moved in a different direction the character faced in that direction as well. The MathHelper class was helpful for this, particularly since Pacman really only ever faces up, down, left or right. You'll also have to find the center around which to rotate. This can simply be done by finding the width and height of each sprite (not the entire sheet) and then dividing each by 2, and using those values as the x and y parameters of a Vector2. It's simple.

If you have any questions, just ask. Maybe one day I'll actually get the energy to put up some tutorials, but that might take a while if no one is asking for them. If you check out the code, you might find what you're looking for in there anyway. At the very least, you'll have an animated Pacman moving around your screen.

Tuesday, June 23, 2009

Pacman (XNA)

So, I haven't totally decided to give up on the Breakout game or the Pong game yet, but unless I get some feedback asking for more Breakout or Pong (which I doubt will happen) I think I'm going to move on to the next game. The previous games certainly aren't at the release stage yet, and may never will be. But my goal here wasn't to create a super-awesome Breakout game. It was to learn to program video games (and contribute to open source software). Breakout and Pong really taught me a lot about XNA and Java game creation respectively. And, when I finally hit up C++, I may have to return to these games to teach me that as well. However, since I'm staying with XNA for a while, I'm going to step it up a little and create a Pacman style game. I hear the excitement brewing.

Actually, this decision wasn't entirely my own. Personally I figured by now I am fully capable of making a decent Call of Duty replica game, however, I read this article by Geoff Howland on the gamedev.net site which goes through the steps you should take to become a decent game programmer. He says to start with Tetris and then move to Breakout. I figure Pong works well enough in place of Tetris, and I have Breakout "done". So, his next step is Pacman. Many aspects will be the same of course such as user input, collisions and sound. However, there will be a few differences like basic AI and using a map with boundaries other than a square. I think the map will be the trickiest thing to work out. Anyway, I'll let you know how it goes.

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.

Wednesday, June 17, 2009

3D Modeling with Blender

To quote myself in a previous post, I said, "I highly doubt 3D graphics will be any easier to create than the 2D ones." Well, I'm not necessarily going to retract that statement, but I now believe that making 3D graphics may be easier than it seems... with some practice of course. This is where I introduce to you Blender, "the free open source 3D content creation suite." I stumbled upon it as I was looking for a "free, open source" program to create 3D graphics for the 3D game I'm going to develop at some point. I must say, I am impressed. Not that I know much about 3D graphics creation software, but Blender seems to be quite easy to use. At least the tutorials make me believe so. I even managed to whip up a snowman in a snow scene. Alright, it's not perfect, but remember I'm far from an artist, and that was my first try... even if I did follow a tutorial word for word. Either way, if you're interested in 3D graphics or 3D games, Blender is definitely worth checking out.

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.

Monday, June 15, 2009

XNA - 3D Tutorial

I've been having difficulty remaining interested in the games I create. Fortunately, I think it has more to do with the fact that I've been creating boring games than actually being bored with creating games. Either way, I figured I'd step things up a notch and try out the XNA 3D tutorial. So far, it's going quite well and is interesting. It really makes me want to jump right in and start creating complex games right away. Of course this isn't going to happen. You've gotta pour the foundation before you start building the house... or something like that. So, I'm going to go through the rest of this tutorial and then I'll start seeing if I want to work on some 3D games. Unfortunately, I highly doubt 3D graphics will be any easier to create than the 2D ones. So, who knows what I'll do... now that I think of it, maybe a neat little 2D sidescroller would be cool... you know, for 2D.

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.

Saturday, June 6, 2009

XNA - 2D Tutorial

Just a quick note about my progress with XNA. On the creators club website they have a 2D tutorial for absolute beginners. And, since I've never used it before, I considered myself a beginner and followed along with the tutorial. It was very thorough... at least as thorough as a beginners game can be. It is definitely worth checking out if you want to learn to program with XNA, though if you're familiar with programming, it does get a little slow at times. But, have a look anyway, and I think that when you're through, you'll see that XNA just might be a very useful tool for creating video games. I'm looking forward to trying some of my own stuff... and maybe I'll even have a look at the 3D tutorial as well. Now, if only I could draw...

Friday, June 5, 2009

XNA

So, the plan has changed a little bit. It turns out I have a research project to complete on XNA for a university course. From what I can tell (I'm somewhat of a beginner too don't forget), XNA is a framwork that works on top of Microsoft Visual Studio or Microsoft Visual Express C#. It is specially designed to develop games for Windows, Xbox360 and the Zune. For more information check out the XNA Creators Club. It's a website devoted to XNA game creation, as well as game testing and sharing. I've just signed up under the creator name osiris003, so you can check out my (currently empty) profile if you wish. By the way, developing games with XNA is totally free, but it will cost you $99 USD per year if you want to get them working on Xbox360.

Anyway, I figure the best way to research XNA is to jump right in and start programming with it. Now, I know very little about XNA and C# at this point, so there will probably be quite the learning curve, but I'll certainly keep you updated. Maybe I'll even end up with some sort of game when I'm finished. I just hope it'll be a little more entertaining than Pong. In case you're wondering, I haven't given up on the C++. I still think it is an important language to learn for game development. I just have to put it on the backburner for a few weeks as I learn a little XNA and finish up a university assignment in the process.

Wednesday, June 3, 2009

Pong (Java) - Update 3

I've played around a little more with the Pong (Paddle Ball) game and it can now be restarted using a JMenuBar. It seems a little choppy, but it works. Maybe someone can come up with a better implementation. Either way, it's updated on my Google Site so check it out!

Something else I was thinking about was tossing up some information on how I actually made the game and how it works. I'm not 100% sure about some things, but I'm sure I can explain most of it. Then, maybe someone else can explain to me the things I don't understand perfectly. So, maybe within the next few weeks, I'll actually post some code with explanations (particularly since I don't think my commenting is overly helpful yet).

Other than that, I think it's about it. I still have some more ideas that I'd like to implement with the game such as a start-up/options screen and some sound effects. If anyone is interested in giving that a shot, please go right ahead. There's no better way to learn than doing.

Tuesday, June 2, 2009

Game Programming in C++

As I said before, I decided I would have a look at trying to create a game in C++. Maybe Breakout since it is quite similar to Pong and would therefore be quite easy. Well, I'm nowhere near that stage yet. It turns out C++ is a little more complicated than I expected. At least the graphical aspects are. Maybe it's because I've used Java Swing before or something, but the C++ way of opening a window seems like a lot of work. I haven't even started adding a few components to the screen yet, so that should be fun. Of course there seems as though there is a lot of flexibility with C++ and I'm hoping that it will only get easier as times goes on.

A good thing about learning C++ though, is that there are a million tutorials out there on it. Of course most of them are about the basics, which is pretty annoying since I know all about loops and conditional statements and whatnot, but I still have to read all about it because I don't know the syntax. One group of tutorials that I have found quite useful are the ZeusCMD tutorials. They let me kind of just jump into creating a GUI in C++. If you're interested, check it out, because I found that simply searching "C++ GUI" on Google wasn't much help.

Sunday, May 31, 2009

Development Tools

Depending how advanced you are with programming, you may not yet have determined the best tools to get the job done. I'm still kind of in that boat myself, but I am starting to get a feel for different tools and what their capabilities and limitations are. So, I figured it's probably a good idea to let everyone else in on what I am using (or plan to use) to program some of these games. By the way, they're all free.
  • Eclipse - I use Eclipse for all of my Java programming. There are also a bunch of plugins available if you wish to use it for other programming languages as well such as PHP, HTML, and I think there is even one for C++. I actually use the Aptana plugin quite often for web development and it seems to work quite well.
  • Dev-C++ - Alright, so I haven't used this yet really since I haven't ever really programmed in C++. I think Microsoft Visual Studio may be a better option for C++ (as well as C# and Basic) but Dev-C++ seems a little more basic and a better way to learn the language. Maybe I'll migrate to Visual Studio (or the free Express version) later when I am more experienced.
Alright, so those are basically the only tools I use so far. Maybe there'll be more to come eventually, and there are certainly more specifics I could go into about my use of these programs. However, if you have any questions or suggestions, just drop me a line or leave a comment.

Friday, May 29, 2009

Pong (Java) - Update 2

This is just a quick one to mention a couple things:
  1. I was a bit of a dummy and uploaded a zip file of the pong game, however I didn't include the background image, the new version has it.
  2. I've updated the game to have a winner (seems pretty important). The only thing is, I didn't know how to display it very well. I'd like to be able to remove the background, ball and paddles completely and have the text in the middle. Any ideas?
  3. Being able to restart the game would also be nice.
So, that's it for now with the Pong game. I'll continuously be updating it until it gets to a decent point, or boring. I am also thinking about starting another game, however, this time, using C++. I have very little experience with C++, so that should be interesting. Though, a simple game shouldn't be too bad. I'm thinking Breakout right now to get a feel for it, but that could change. I'll keep you posted. 

Wednesday, May 27, 2009

Pong (Java) - Update 1

It's been a few days since I last posted about the pong game, so I figured it is probably time for a little update. I've made a few changes to knock some items off the list. I added a background image, so it looks a little more like Pong and I've changed the way the score is displayed (and the right score is on the right side). I've come across a couple of new problems:
  1. The background image constantly repaints with the game. I don't know if this can be changed or not, but it seems rather inefficient, and may actually be slowing down the game some.
  2. The path to the image will probably change for others compiling the game. It would be nice if that weren't the case, however, I'd like to be able to keep images and the src code separate
However, other than that, things are pretty much the same. Check out the original post to see what else can be taken care of. I also smartened up and uploaded a zip file containing the src files. I don't know why that didn't occur to me before, but I'll do one for each update I make so people can see how the progress was made if interested. That's all at my Open Games for Beginners Google Site. Until next time...

Monday, May 25, 2009

Ideas

Here is a list of ideas for games that should be simple enough to accomplish in the near future:
Alright, so those ideas are pretty lame right now, but like I said they're simple, and at least that's what I need. I also think that maybe after those are completed, we will probably be ready to move on to some easy side scrollers or something.

Of course, if you have any other game ideas feel free to let me know. Even if you come up with the concept on your own, I'll certainly do a post detailing it. Who knows, maybe it will be the next blockbuster. 

Sunday, May 24, 2009

Pong (Java)

So, the first game will be Pong. It's a java game because I'm more familiar with Java than C++. Though if you want to try a C++ version (or any other language) go ahead and I can have a it posted. I've called it Paddle Ball because I don't know if I'm allowed to call it Pong, but the name is irrelevant, at least for now. It's the first game I've ever created, so it's quite simple, though there are many flaws. I don't have it posted up on Google Code yet simply because I'm waiting to see the interest in learning to make the game. Instead, you can go to my Google Site which has the java source files you'll need to compile and play with.

So, please have a look, if you have any comments or suggestions let me know. If you happen to make any improvements, let me know that as well. I'll keep a list of the contributers.

As for things I can think of to improve (or new features to create) here is a list:
  • background image
  • sound effects
  • intro screen with options
  • AI player
  • score positioned on correct side
  • smoother gameplay
  • nicer graphics
  • network gameplay
  • 3D graphics
**Feel free to add to this list!

Go to the Pong game here.

The Game Plan

I'm a beginner/intermediate programmer. I mean I've learned a lot about programming, but I haven't really applied it before, so that's why the beginner tag is still there. I also want to make video games and contribute to open source software, but I really don't know how. For some reason, I don't think I'm the only one in this boat. So, why not kill two birds with one stone and do both at the same time? I'm hoping others will want to do the same...

So, here's the plan (at least tentatively):
  • I'll start a game (they'll be simple at first) and post it to a Google code account. I've never done this before, so who knows how it will work out. The game may or may not be functional, but in any case, there'll be plenty of improvements that can be made... though some imagination may be required.
  • I'll try and list some ideas I have for improvements that can be made, but anyone can come up with their own ideas, who knows where it will take the game. I think that's the fun of open source.
  • Anyone can check out the game code, learn from it, make improvements to it, whatever. As I've mentioned before, I'm not professional, so everything may be totally wrong, but that's the point. I want to learn too, so constructive criticism is appreciated. Just don't be an ass about it... to me or anyone else. We're all here to learn.
  • I'm not sure how the check in process works, so we'll kind of have to figure that out as time goes on. Any info on that would be great.
  • If you have a game started that you want posted, let me know. You can create a Google code account too and put it there (SourceForge.net is another popular one which can be used). I'll make a post about it, link to it, and keep people updated.
  • Also, if you even have an idea for a game let me know. If it's within the scope of our abilities, I'll post it up in an ideas section, which will be updated regularly. This will give people an idea to work with if they'd like to attempt a game from scratch.
  • Commenting and documentation is also important (so I hear) but I hate doing it, like many others I'm sure. However, learning to do both properly is probably a good idea, so we should really focus on doing it as much as possible. I don't imagine they created Call of Duty or Crysis without at least a few UML diagrams and use cases. Search for that stuff on Google if you'd like to learn more.
  • I don't care what language is used. I've always learned Java throughout my education, but C++ is apparently the game programming language of choice. So, if you want to put up a C++ game (or even flash, C#, or some other language) that's cool. I don't think anyone is opposed to learning different languages and each language certainly has its followers.
  • Eventually, maybe we can end up with an open game community with regular contributers, articles and the whole works so I won't be the only one updating the site. Maybe we'll even end up with a decent 3D game out if it at some point. But, for now, a simple blog will do. Though if anyone is interested in developing a site, let me know.
  • Any suggestions, comments or questions are welcome. The plan will also be updated at times, so who knows what this will turn into, but input from others is what will enable everyone to learn and contribute even more.