Wednesday, May 18, 2011

Space War Pew Pew

Space War is kind of convoluted. It's not the worst code I've seen by far, and it's got pretty good comments, but there is so much mixed in. At times, I feel like I am spending more time figuring out how the game code works than focusing on the networking aspect. Anywho, enough complaining though. Yesterday, I decided to clean up the code before going any further with my queue and networking. I deleted the retro version of the game, the sun and gravity. Now, I need to delete the upgrades and ship selection screens, as well as smoothing out the edges between the changes I make. Cutting things out wasn't bad, but I realize more and more that I need to rewrite more and more code. This is definitely a big project and I'm very glad that we still have several weeks and I've already been. I'm totally baby stepping it now. I don't have anything huge to declare at this point, but I'm happy to report that everything is on track and going well. 

Wednesday, May 11, 2011

Continuation of Queuing it up

I worked a lot on converting the game to a queued format today. Looking back on last night's code, I noticed that I had been passing some unnecessary data so I ended up cutting that out and cleaning it up. I then added another event for creating the player ships and began to work on an event for when an asteroid collides with a ship. I might have mentioned this before but the most challenging thing in this assignment is not the coding-- instead, it is getting through the convoluted aspects of the design and knowing what and when to abstract. Any who, I don't have much time to blog about what I did now because I am working on my independent study project. Ever since I got to working on this, I have become a little obsessed with the assignment since I have a tendency to really immerse myself in a code project. Now, I need to shift gears and work on other things, especially since I have the luxury and challenge of no hard deadlines. Off to code away the night then!

Monday, May 9, 2011

An Epiphany

There has been a lot of debugging going on today. I am exhausted, both physically and mentally but very excited about my newfound understanding of this project. I thought I got it before, then I really didn't get it, then I realized I really, really didn't get it, panic and frustration set in, followed by lots of debugging and discussing of general concepts-- then came understanding. I have sketches galore littering my desk and a successful shift-over of the asteroids to my Game Queue. I'm excited, happy, and ready to go! Tomorrow morning that is...now it is time to rest a little, even though I know my dreams will be full of floating points and abstract methods. Details to ensue when I have more strength to type and think.

Friday, May 6, 2011

Belated Update on PA3, my Happiest Assignment

I can't believe that I forgot to post about my successful completion of PA3, the networked packets, because it was my most happiness inducing completion yet! I had never networked anything before and to see this work made me squeal! It's funny because it's nowhere near as difficult as a lot of other things I've worked on, and yet it was so new and ominous when I started, and such a relief and feeling of pride when I finished. I even tried it out on two machines to really see it in action! I know that this sounds really cheesy, especially to all of the overqualified networking gurus in this class, but I don't care! That is why I am here, to learn to network-- not show off what I already know.

On to the Big Ships!

Logging on, I realized how log it's been since I've last written in this blog. I have three blogs to keep for my classes so I keep on bouncing back and forth between all of them, but it's easy to forget which one is updated and which isn't. After being out of commission last week due to being sick, I jumped back on the train but really focused my efforts on my Independent Study. I missed the deadline for PA4 Data Driven and kind of left it on the back burner, knowing that I would get to it when I had to progress on my final project. I normally don't miss deadlines, in fact this is the first in a very long time, but with everything crashing down on my head after falling behind a little, I needed to prioritize and pick my battles. Fortunately though, PA4 is now complete. 


To be honest, it was significantly easier than I expected. At first, I was really confused by the instructions in the PDF. The first issue that I had was in terms of doWork(). Initially, I thought that Keenan wanted us to implement a generic type function, like a template, to take in any data type. However, I did not see how I could call the necessary methods for that data if I didn't know what types I could be dealing with. After speaking to a classmate, I realized that we were meant to know the type we were using, the caveat was just that it had to be user defined. This cleared things up and really made things easier. 


As for Interleaved, the confusion arose when I compared the instructions to the function calls made in Tests.cs which didn't quite match up. I really did not understand why and how there were two separate queues that were then congealed into one. After reading forums though, I learned that it was not necessary to implement it exactly that way-- so long as the data was processed in the same way. Perhaps Keenan knows something about C# queues that I don't and has a better reasoning for using them the way he did but the way I implemented it is much easier for me to understand. 


I went back to the way I had done it last year for my Capstone game, creating a single Object queue since all of the objects go back to the Object base type. I then looped through the queue, dequeuing object by object, checking its type, casting it to that type, and calling the necessary methods on it.  


Now, I can start working on the final project. This is going to be a busy weekend with my hours spread out between the final project for this class, my Independent Study, and the animation converter for Engine. Time for another day (or lots of days) of hard work!

Friday, April 8, 2011

Packed and Serialized!

I just completed Assignment 2- Serialization and am very happy. It feels great to finish something so early and not have to worry about it hanging over your head. My goal this quarter is to really stay on top of my work, and this is a step in the right direction.


Overall, this assignment took me just under three hours to complete. At first, I wasn't quite sure about serialization in practice, because I didn't understand if we had to manually create "headers" and block the data off in the buffer, or if that was the larger picture used to describe it. In the first examples, with Dog and Cat, serialization was very straightforward and simple. Even though my tests for those passed, I thought that I was misunderstanding something because it seemed so easy, so I debugged and stepped through it, making sure that everything made sense. Then, I began working on Bird, and this is where things got ugly. A little.


I had to go back and look at the slides to make sure that we were indeed supposed to section off the data. Once I understood that we were allowed to, and in fact supposed to do that, I used placement new to create a temporary pointer to the buffer, and then incremented this pointer as I memcpy'd everything I needed in a step by step way. In Bird, the thing that gave me the most trouble was the char * because I knew how to serialize it, but when it came to deserializing it, I could not get a hold of its length. Then, I remembered the "header" suggestion, and in serializing, placed the strlen of the char * into the buffer at the very beginning. At that point, I could easily pull it out in my deserialize the same way and use it. After I had coded all of this, the test was still failing on the strncmp. I debugged and saw the string in my data field had extra junk on its end, so I went back and memset it to 0x00 in my constructors. This solved the problem and the test passed. I also added print statements to my constructors and destructors to print out the pointers, in order to check that everything was working correctly. 


Finally, in Fish, I realized that I could serialize the apple and orange structs as wholes, rather than going inside of them and individually blocking out all of their data. The serialize worked off the bat, but the deserialize caused a crash. It turned out that I had forgotten to actually initialize my apple and orange, was trying to write to them when they were null. Similarly to the previous situation in Bird, I went back to the constructor and initialized them which solved the problem. 


I like this class because it's teaching me something I've never even broached in other classes. I've done data alignment before but networking is literally a new world for me-- like a programming expansion pack. I'm really excited about learning more and applying to making an actual networked game, but I'm also glad to be done with this assignment. I'd say that having 4 teeth drilled and then completing this assignment makes for a good day's work. Tomorrow: Independent Study and Engine 2.

Sunday, April 3, 2011

Just Gave It a Go

I just finished playing Space War with myself. I tried to control both ships simultaneously, which did not work out very well strategically but demonstrated to me that everything works successfully! The initial controls are strange though. I had to press 'f' to get the control screen to pop up, and a 'g' to start the game. I could not figure out how to select "Retro" or "Modern" on my machine via keyboard, and based on what I played, it looks like it defaults to "Retro". When I start working on this, I'll use XBOX controllers to make my life easier, but beyond that, it looks great!


I finished the programming assignment shortly after writing my post, but as I just mapped the depot into a new workspace for this class, I submitted it tonight. Looks like everything is done, and I am ready to continue with learning about networking games! Sounds like fun, can't wait! In the meantime, I am off to work on my Engine 2 + Independent Study -- converting an FBX to binary and integrating this into my code to read in the model data and use the model. Wish me luck because I sure will need it!