Wednesday, July 26, 2006

What's up with me

So, my previous contained all my update logs(And this one will contain a little bit aswell, including a screenshot).

First of all, the new place I'm in rocks: It's air-conditioned, we got a dishwasher, a large kitchen and it's not housemates.

Also, since I'm currently having vacation from college, I'm spending most of my time working. I got a vacation job as foreman. We travel through the country and install TFT monitors at all locations of a company. It are a few thousand monitors, so I'm sure I have at least 6 weeks of work.

The pay is ok and I get to drive the truck. While that's ok, it's a horrible job aswell: The installation locations are ALWAYS in the middle of the city, and the streets are usually thight, crowded and shit to maneuver a huge truck in without too much experience and a drivers license for driving trucks. I'm not illegal driving this truck, on paper it's a car. However, it handles as a truck. Due to this, I damaged the truck twice(GAAH!!). My girlfriend told me it was the risk they took, but that didn't do much about the guilty feelings.

So, today I was home early, so I took a nap and when I woke up(I had a muscle cramp in my leg, not a funny way to wake up), I decided it was time to code. So I finished off my debug log and log console. It was quite easy to work out. The log itself stores lines, and can flush them to disk aswell, and the console is the visual part. It takes it's own height, calculates how much lines fit in it(It first calls a MeasureString()), minus one, and then takes the last x lines from the log.

It's rendered to an alpha blended texture only when the log updates. That way, it's cheap to render. I still need to make it re-sizable at runtime(Perhaps turn it into a GUI widget or place it on a GUI widget, such as a re-sizeable panel). Also, I need to make use of it in the actual game code.

I didn't mention it in my previous log entry, but I also optimized the map rendering, and it gave me a 30 fps performance boost. Which is nice. And I made the tile reserving/occupucation work properly. So, when I have time again(Which is probably friday), I fix the drag selection which I disabled, do some work on actually making sure device lost events are properly handled and then really start working on the harvester(Well, after I made a new map).

Internet is back up: More updates!

I've been without internet for a full 3 weeks, and I have a vacation job, so I don't have an awfull lot of time to spent coding. However, I did keep track of my development log while I was offline, so here are my notes for the past 3 weeks(Not a lot, since I didn't have much time to code):

Sunday 16th july 22:33 :
I've done more coding today and I've ran into a few problems, did a few changes and gave stuff some thoughts.

I have to work out movement a bit better, because at the moment units are constantly calculating a new path to follow when entering a tile after reserving it.

Also, I ran into a trouble when rendering the selection: When the position has numbers after the dot, the selection marker will be (partially) faded. Solving this is quite simple: Make sure the X,Y positions of the marker don't have any numbers after the dot. That's not very difficult, but adds some more pointless information, and I don't wanna resort of a new Vector3 every render loop.

It all takes more time than I anticipated, so I think it's gonna take ages before I can start adding buildings, and/or UI components.

Sunday 16th july 00:43:
I haven't had much time to code friday and most of the saturday I've been away, but tonight, I finally managed to get movement working properly.

It involved quite some changes, such as adding a SceneManager to maintain all objects on the map, and coordinate them. At this moment, movement is veru rudimentary: The unit itself moves to the middle of the last tile in it's path without actually facing the correct direction or reserving tiles.

That is my next step: Have units rotate their nose in the correct direction, and then move. After that, I need to have the SceneManager(SM) update the tiles correctly, and allow units to mark a specific tile are 'reserved'. A reserved tile means that a unit marked the tile to move to it. Not doing this might result in multiple units occupying the same tile.

After that works, I'll do a new commit and start working on optimizing map rendering a bit. After that, I'm not sure what I'm gonna do first: Harvesting and weapons. I probably go with harvesting, because the harvester is really cool, esp. with the sand falling out of it in the back ^_^.

Anyway, a bit back to work and then I'm off to bed again.

Thursday 13 July 23:30:
I've decided to write a development log offline until I have internet access on tuesday next week, and then publish these notes in 1 single blog entry.

OVer the past days, I've done quite some work, and it payed it off. New additions to the game at this moment in time are(Taken from this morning's SVN commit log):
- Added PathFinding
- Added a test map for pathfinding
- Added batch file to extract current Revision
- In-game now FPS and current revision is visible
- Added a GameObject class
- Derived Unit from GameObject
- PlayState now keeps track of all units
- Added a UnitFactory which spawns new units
- Added the graphics for quad, trike, harvester, light tank and siege tank.
- Created a rules.ini to contain definitions for units
- Re-organized DuneRemake project
- Added hotspot to mouse

Over the day, I also added the graphics for the Devastator, Deviator, Sonic Wave Tank, MCV and Rocket Launcher. Due to some errors in the spacing, I had to re-do the Devastator image, but everything works fine now.

Also, I added a new class called TurretedUnit, which is basicly a tank with a turret(Duh, like you couldn't figure that out). It relies on the base Unit class to draw the tank base, and then draws the turret on top of it.

Now that I added the graphics, I'm thinking off a way to store the units in the map so they can move properly. My main problem is that I currently can't think of a way to store both units and aircraft/sandworms in a tile. Because, there can be a carry-all hovering above a unit to pick it up, and a sand worm underneath preparing to have lunch. I gave an ArrayList or List a thought, but I'm not sure. It would cause a lot of additional overhead, which isn't very good for performance.

I am planning on adding a global GameObject list to keep track off all game objects, and using that to update them all. Having to walk a 200x200 map just to update a total of 8 objects isn't very efficient.

I technically COULD walk the list twice, check if said object is within the viewport, and if it is, render it. Or while updating all game objects, place the objects that are within the viewport in a 2nd list and when rendering, only render those objects.

On the matter of pre-mature optimizations: After I got units moving over the map fine, I'm going to change the code for the rendering of the map. I'm going to render the visible viewport map to a texture, and only when it changes, I render it again to the texture. At the current screen size, rendering it tile-by-tile, it takes 1200 render calls. Changing that to only 1 call will increase performance a bit.

That's it for tonight. It's 23:47 now, and I think I'm going to take a shower and crawl against my girlfriend in bed. No screenies for today, sorry!

Saturday, July 08, 2006

Pathfinding works

I've successfully implemented A* pathfinding. A* is pretty simple to implement, once you understand how it works. Here are 2 screenshots:Click to enlarge

The next step now is to actually have my mouse cursor support a 'hotspot', so that changing the cursor doesn't alter the general behaviour(Right now, the attack cursor will show as long as it's hovering over a unit, even if this includes the bounds of the cursor). So, when I use a hotspot, changing the cursor doesn't show unnatural.

Also, when that works, I'll work on adding the selection thingies around the units and making them actually move.

However, for the coming week, or perhaps 2 weeks, I won't be able to post new updates, as I'm moving and my phoneline/DSL line haven't been transferred to the new location. Let's hope I get to live at least 6 months at that new location before I have to move again.

Sunday, July 02, 2006

We're developing again!

Finally, after almost 2 months of no updates, I have time again to code on the game. In the past 2 months, I've been too busy with school and other projects, so I had to put this project in the fridge for a little while.

In the past days I've coded quite a bit, and I did the following:
  • Fixed a mouse related bug
  • Fixed a bug in the map editor where the 3x3 tile brush wasn't working properly
  • Added a base unit class
  • Added a Drag Selection rectangle to the game
  • Added unit selection to the game
  • Coughed up a map for pathfinding
The next step for me is to actually show unit selection and after that, implement movement and pathfinding algorythm.

I can't show any screenshots at the moment, because there isn't anything special to see, unless you like seeing a screenshot with nothing but sand and a unit standing on it...

I hope I can show a little big of screenshots for movement in 2 or 3 days.