Thursday, March 11, 2010

Milestone achieved !

The Proof
Well I finally have something to show as a proof of concept:

Isn't that awesome ? Megaman standing on a map full of road and grass ! I made the image extra large so you all could see it. The simplicity of this piece of program is more complex than you can image. I will deploy a few images to explain what code I used to piece this up.

First I used both the "ArrayMap" and the "GridMatrix" technique from earlier posts. I have two arrays - BasicRoad and SpriteMap, that contains the values of which tile and sprite to apply in which position of the matrix ( as seen on the left ).

Then I created a method to take the values in the BasicRoad array to decide which image to place in the tiles matrix.
Afterwards I took the images from the matrix and put them inside a picturebox-like class and placed the tile on the form.
Next I had to do the same with the sprites, but unfortunately I had a problem. My idea was to place the sprite in a picturebox and put that picturebox on top of the tile he's resting on. But there is no opacity property on pictureboxes so wherever I put the sprite he was hiding the tile under him. Making an ugly hole in the map. to solve this problem I used the backgroundImage property and took the image of the tile he's resting on and applied it as background.

I created two classed derived from picturebox: GridTile and SpriteTile so when I scrolled through the form I could use their type to get only the tiles or only the sprites.
 
You can see that I am passing quite a few parameters to these classes, instead of giving them their values after I created them. I made a New() so I could give them their values directly when created. Much cleaner that way. You can see where I use the me.backgroundImage property and used the coordinates from the matrix. 

I'd like to stress that this is NOT a representation of the final project. This is from the vbProject that I made to explore the mechanism that I will use in my game. I still haven't done a single line of code regarding the game itself. The sprite I used are not mine and property of their respective owner. But I can take credit for the tiles since I made them, and they are awesome.

No comments:

Post a Comment