James's profileElroymanBlogListsGuestbookMore ![]() | Help |
|
|
April 19 Chuck Norris PongSo I haven't done any serious coding this week...too busy with school. But I did sit down one day, while I was bored and wrap up a couple of changes to the Pong game that I finished last weekend. I went online and collected a couple of Chuck Norris images, put it all together with Paint.net, and voila! Here you have it, the Chuck Norris Pong Game. Code is posted in my SkyDrive for public download, though the only thing that's really different from my original is the naming within the code and the images. ~enjoy:) April 12 Pong (from chapter 2 of Nitschke's book)Well, I have finally finished the Pong Chapter from Benjamin Nitschke's book, Professional XNA Programming. I was very nearly completely disappointed with it. It opens by telling you that it is possible to code the game completely from the book, but the code in the book doesn't have the correct code. To to it off, the source code that the book points you to isn't even the most recent version, though the book is very recently published and is supposed to support XNA 2.0. Anyway, after a week and a half of tinkering around on my free time, I have finally finished it. Without the unit tests that cause so many other people problems with the book. If you would like to take a look at the code, feel free to download it from the SkyDrive. I have included both the source, changed as I went along, and the installation files from when I published it. It works with both the keyboard and the 360 controller. I'll be putting together my own tutorial during the next couple of weeks. Working on a soccer and hockey version as well, just changing the artwork and sounds mostly. April 08 XNA Programming Chapter 2As I was going through chapter 2 in my XNA book (the one by Nitschke) I found some things that were overlooked (or not put in until the Troubleshooting section at the end of the chapter instead of when you need it), and some others things that really weren't spelled out explicitly but that I thought should have been. To begin, it really helps out in the long run if you go back to chapter one and add in the commands that allow you to exit your program by pressing the Escape key. I didn't do it the first time I went through, and it really irked me. 1.) When entering the code in initially the background is loaded using the standard SpriteBatch methods. The code in the book uses two integers here (width and height). These were not previously initialized and should have been. The assignment of values to these variables is not as straightforward as it could be, either. They should be assigned within the initialize method by: width = graphics.GraphicsDevice.Viewport.Width; (and height is handled in a similar way) If this is not done then all you get is the background color specified elsewhere in the Draw method, with your background image loaded and initialized with a size of width 0 and height 0. 2.) In order to get the menu to render you have to go fishing around for the code in the source files. It turns out to be a pretty simple problem. When loading the menu items one of the rectangle RenderSprite methods is called, one that doesn't do anything. I ended up cutting and pasting the method that follows:
The method that was initially called was commented out so this one could do its work, doesn't seem to matter though because it didn't do anything anyway. The result now matches figure 2-5 3.)The code in the book for rendering the lives, ball, and paddles is pretty straightforward. The unit testing doesn't seem to be working though. I have decided that it will be easier to simply convert the code given in the book to just go about adding the code into the game itself. I have been getting good results from this. So, I will not be finishing this post as originally planned (though I have obviously posted what was already written). However, I will be finishing the pong clone. I guess I will just reduce the code to the game itself without the extraneous unit testing code, and then put together a Tutorial explaining its creation step by step, for the exercise and to help anyone who cares to read it. I know there are a few out there, but maybe I can add a little something to the stuff that is already out there. I'll make my code available as well. |
|
|