• entries
    109
  • comments
    175
  • views
    116754

OK, I give up...

Sign in to follow this  
Emmanuel Deloget

367 views

I mean, this GeForce FX 5600TX is just too lame, and I just can't accept that anymore. So I went to Staurn in the Stuttgart town center and I bought an AGP GeForce 7600 GS (the one by MSI, with 256MB DDR2; see here for the benchmark results). It was cheap, and it's supposed to be good enough - at leat it will help me to wait for the end of the year.

I also decided to buy a Xbox360 pad for my PC (because I plan to write an article about XNA input systems for my blog in a few weeks). I first wanted to get the normal one but it was unavailable - so I bought the cordless controller. Hopefully, I will get some fun with that.

Speaking of XNA, I decided to test my implementation of the C# project 1 in a XNA program (2d, top view). This proved to be tricky - not on the maze part, on the rendering part. I'm writing a series of XNA tutorials for ny blog, so I decided that I should use my own sprite library (pawn) and give it a test. My design is quite effective... for a C++ program. I'm pretty sure that a C# program should NOT be designed this way, but my knowledge of C# is still too limited and disallow me to write something better. Wait, it's not uterly slow. It's just not as fast as it could be.

The maze is implemented as a specific kind of tiled background layer. My library allows me to create a background with an unlimited number of layer (hello mister parralax scrolling). Layers have to inherit the IBackgroundLayer interface and are then free to do whatever they want. I have three implemented types of background layer:
* a "simple image" layer: an image which I directly copy to the position the user specified
* a scrolling image: an image in which you can freely scroll. It's up to the client application to describe the scrolling by specifying the visible area in this image.
* a tiled background: a background which is made of tiles (really?). This is the most interesting one in our case. It only implements how to scroll in the background and the high level rendering operations (ie choice of tiles you want to render and so on). Tile storage is implemented in a IBackgroundLayerTiledStorage interface (which inherit IBackgroundLayerStorage). The library contains a specialized implementation of this interface to load the data from a XML file. I then decided to store the maze in another implementation of this interface to see how it would work.

Well, from a design point of view it works great. From a speed point of view, it works not so bad - but there is so much dumb code executed that I'm sure I can do far better.

To ease the rendering and to limit the number of needed tiles, each cell of the maze is divided in four quadrants - topleft, topright, bottomleft, bottomright. As a result, I only have to deal with 12 tiles (13 if I use my "big rooms" feature while building the maze). Getting the corret tile for a particular quadrant in a particular cell was quite annoying. I finally got everything right (after, say, 1h or 2h of debug... :/).

Then I decided to implement "fog of war". As another background layer. Oh. This is inneficient (as some invisible tiles are drawn twice: once when I render the maze and once when I draw a solid black tile onto them). Given the fact that I just did something very similar (the maze), it only took me one hour to get it running. I also had to mess with the tiles but that was a bit eaier (now thT I had a working scheme).

Implementing the player movement was quite easy, but I had a stupid problem when I tried to update the fog of war w.r.t visited tiles. Well, each cell in the maze have a "bool visited" member - but the cell is a struct, meaning that anytime I got the cell struct from outside the maze, I got a copy of the struct - and not a reference. Well, a struct is a value type in C#. Changing it to a class fixed the problem (but forced me to do a bunch of new allocations, ok, that's not really a problem). Once I got that, everything was working.

I have a perfect maze which is displayed in an XNA program. I find this damn cool, given the fact that I started C# 3 month ago.

Last but not least, I decided to display a minimap of the maze in the top right corner of the screen. It was the easiest part: I just had to specify that the whole bakground was visible and that it should be drawn in a small rectangle in the top right corner. 1 minute later, I had my minimap.

Screenies on monday if you're nice ;)

And now I go back to home ('m again in a cybercafe) - and I'll give a try to these two brand new pieces of hardware.


Cya! (not at home, I mean)
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now