Thursday, June 3, 2010

integers, not bytes

Our first take at creating a multi-player, networked game will be done by starting with a sample chat client/server code base (included in Luke Escude's tutorial) and adding more functionality to it.

In the chat console, we have added a walled region where a user can move a character (using the arrow keys) around and see other characters who are in the chat room.

We designed the workflow for how this would be accomplished and then implemented the code. After walking through the code at least 5 times, we ran it and it worked... sort of. I was using writebyte() for sending the tcp id and the x,y coordinates for the characters and the x,y max values well exceeded the value 256, which is the maximum numeric value that can be represented with a byte. That accounted for the strange behavior we were seeing -- the user could see their own character bounded in the walls, but the other characters were outside and to the left. Furthermore, the other characters would suddenly jump to the left side of the screen when their owners moved too far to the right.

I couldn't find logging functions in GameMaker (well, there is an error logging method, but I wasn't logging errors), so I created my own using GM's file and time methods. I used the resulting log file to help me better see what was going on. Along with helping me locate my 'byte' issue, I also realized some extra looping that I want to get rid of.

The solution in fixing the 'byte' issue was to change those particular writebyte()/readbyte() calls to writeint()/readint(). Since my game board is no bigger than 640 x 480, integers are all that I will need.

While debugging the code, I found myself wishing there were better debugging tools. Perhaps I don't yet know how to take better advantage of the debug mode in GM; I found my code walk-throughs and the new logging capability to be more useful so far. I also like putting my source code under source control, but since the scripts are all inside a GM file, I don't get the full advantage I would like. It would be nice if there was a way to export all scripts, no matter where they showed up, and to likewise import all scripts from a directory of files. That way I could easily see where changes were last made. Perhaps there is a GM function that can be used to do this and I simply don't know about it yet.

Thursday, May 27, 2010

multi-player games with my son

My son and I have been educating ourselves on making multi-player games using GameMaker 8. It's a wonderful platform for novices to get their feet wet in the field of video game creation. It's also been a great way to introduce my son to computer programming. I mean, what young boy doesn't get a thrill at the idea of creating their own video games?!

A free version of GameMaker is available from the folks at YoYo.com. Advanced features become available once you register for a small fee. There are tons of people in the wiki, forums, and game submissions, which means tons of support.

If you wish to play some of the submitted games, YoYo has made it very easy using a web browser plugin. For those of us Firefox 3.6.3 users, however, the process of installing that plugin is somewhat more involved, but not difficult at all. This is a great way to get some ideas for your own games.

Getting started with creating multi-player games does require a registered copy of GameMaker. Next, it really helps to have a decent tutorial, especially if you are new to the GameMaker language (GML). A library is used to supply the needed functionality for programming multi-player games, specifically the socket handling. There are still tutorials floating around that use an other library called (I think) mplay. This one is old and tends to be flaky, especially where firewalls are concerned. The preferred library of choice is called '39dll'.

A great tutorial for using 39dll has been put out by Luke Escude. Many thanks, Luke! The code is clean, documented and he does a great job explaining the various parameters and providing diagrams to give a big picture view on the matter.

I was able to have success, modifying the example code to have the client send a message to the server and then from the server to the client. Then I modified the sample chat client and server applications so that one could input the ip address of the server and the port number. I ran these on my LAN between my Windows laptop and my iMac with VMFusion (Windows) with great success.

My next step is to have my son connect up with me from outside our LAN. I configured my router to do this, opening up a port for the purpose and forwarding requests on it to my iMac. To make sure that this was done correctly, I tested the newly opened port through CanYouSeeMe.org. Again, success. Once we have tested successfully across the Internet, then it will be time to actually put a real game together. My son has already created several games; we'll see how difficult it would be to retrofit one of those games in a multi-player environment.

Wednesday, May 12, 2010

why did I wait so long...

It is said that the path to hell is laid with good intentions. Three months ago I decided it was time to change the oil in my car. My car has taken quite a bit of abuse and is running very well all things considered. It has survived over 160, 000 miles and 120 miles of daily commuting. However, the car is showing signs of neglect. It now buzzes at me when I make turns, suggesting to me that the steering fluid must be getting low. I am imagining there might only be a couple tablespoons of oil left in the engine block. So I decided it was time to take it to the shop.

Another thing that recently broke was the cigarette lighter. I use my iPod daily to listen to music and audio books, thanks to that power supply. It really bothers me that it's not functioning right now. The mechanic said that it might be a fuse that is out. Sometimes the metal sheeting actually comes out of the power socket when I remove my appliances. He said that perhaps I shorted the circuit when that happened. We'll see.

I also admitted that I've been living off of a prayer in regards to the timing belt, which, to my knowledge, has never been replaced. Now we're talking more money. So it's time to consult Quicken and see if I can afford the expense this month.

I really did think that I could take care of my car on my own. It's not so much a question of ability as is time. So I should not be embarrassed or think it's wasteful to take my car to the shop. With only 24 hours in a day, one must ask himself, "where will my efforts be best placed?"

Sunday, January 3, 2010

We have a GMC Yukon and we love it! It certainly seems to have a decent stock sound system, which has been a good plus. Recently, we received a Eonon multi-media/GPS system and tried to install it. So far, I haven't been impressed -- it's difficult to say whether there are enough hurdles that GMC puts up or whether Eonon devices tend to be flaky. The first three units (all Eonon e0851) all extended their displays, stopping before they should have folded up in the viewing position when they were first plugged in. My installer claimed they must have been defective from the beginning.

I should mention that I tried to install the unit myself. I followed the instructions to a T, called up my electrical engineering brother to ask for assistance, and I got the same results as my installer buddy. I thought I had fried the unit or something. I needed to purchase some converter cables (GMOS-04) in order to connect the new radio in. The culmination of all the necessary cables was so tremendous I was not able to find a way to easily store all the cables behind the radio.

I have a different Eonon model my friend installed and everything seems to work... except the sound. I had purchased a GMOS-04 to provide the right conversion connections between the car and the new Eonon radio unit. I let my installer hack away at the GMOS-04 wiring (against my better judgement; that's another story for another time); he thought that the unit was superfluous and attempted to hard-wire the radio in. It didn't seem to work.

So now, I'm left with my old radio and a unit that only sort of works. I will most likely put the old one back in. There are other problems with the Eonon for our Yukon. The screen that does the fancy slide out and turn up will run into the shifter when it's in the park position. There is a cavity currently occupied by the multi-disc changer that we rarely use; installing the radio there would be better in terms of avoiding mechanical collisions. I will try changing a couple of things, but in the end I imagine I will end up going to Best Buy to purchase a GPS and ask for someone to install it for me. I just don't have the time or interest to deal with these issues myself.

Samsung printer drivers for Mac

Recently, I got a MacBook (and I love it!). I found myself going through the process of setting up its environment to have support for my wireless printers. I didn't know when I bought my Samsungs that they wouldn't be supported so well for Mac. But someone has been looking out for us Mac users. Linux Foundation has a great resource and their installers are very good at guiding you. You will need to install 3 components; I have Snow Leopard and the installs worked like a charm.