Jump to content
  • Advertisement
  • entries
    740
  • comments
    957
  • views
    732152

Done for the day!

Sign in to follow this  
Gaiiden

125 views

Sweet, a solid 5 hours of work and I've completed all the tasks I listed in my previous entry. The three bugs and the first three tasks took me only an hour to get through. I was right about the first bug - the code I was using to determine if the mouse had been clicked on the map was buggy. I was doing

%tile = $gameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).pickTile(%worldPosition);
if(%tile)
$gameMap.addPlanet(%tile, %type);

Therefore if %tile were to equal "0 0" or "0 1", which is the first column of the map, the statement would evaluate to false. Henceforth

%tile = $gameMap.map.getTileLayer($TILE_SYSTEMS_LAYER).pickTile(%worldPosition);
if(%tile !$= "")
$gameMap.addPlanet(%tile, %type);

This is the way it should be done to properly evaluate a bad return to %tile.

The second bug was also a stupid n00b mistake. When I went to store the ring count I did

setWord(%tileInfo, $TILE_INFO_RING_COUNT, %ringCount);

BZZZZZZTTTT!!! Wrong-o. I assumed that setWord would take %tileInfo and modify it within the function. Stupid me never realized that - hey, this is a local variable I'm passing in. How the hell is it supposed to be modified? It wasn't until I looked it up in the docs and saw it used in an example that I slapped my head and groaned. Here's the way it should be done

%tileInfo = setWord(%tileInfo, $TILE_INFO_RING_COUNT, %ringCount);

Simple fix, stupid bug. But such is the case with most bugs...

The third bug took a bit longer to track down than the other two but it was a simple fix as well. I was just passing the wrong variable to a function. That's what you get when you name variables %type and %tileType and keep forgetting which is which.

After running through the first two tasks (as I thought, task #3 was solved with the bug fixes) working out how I was going to do the territory shading and implementing it took up the majority of my time today. I had already set up the map with a layer beneath the systems for setting shaded tiles, so it was just a matter of adding the tiles and the interface with which to do it. I managed to keep it all in a single function, GameMap::setTileTerritory. The sole purpose of this function is to add a shade of the proper color beneath a planet or special system. Here are the results:


Placing a planet on the map creates a territory shade beneath the planet as well as the 4 adjacent squares. This is what happens in -game, which is why the extra territories don't have any systems automatically created for them


Here we've selected the empty system brush and filled in the territory. If we hadn't done this, upon loading the map in the game those territories would have existed, but since no empty systems were created, they wouldn't have been shown


Holding the Ctrl key you can left-click to add more territories of a selected planet color, or right-click to remove territories of any color. You can't, however, remove a territory if a planet still occupies that system. The empty systems were also added manually, Ctrl-left-click only adds the shade, you'll see why later


Pretty! Here's a map with all 5 planets placed and their territories defined. Since there are only 4 players per game, any fifth planet is treated as a neutral player. Also, not all the tiles in the map need to be assigned a territory as they are here


Finally, here's some special systems thrown on for some spice. Notice how the territory shade remains? Yes, players can control special systems in their territory, which is why Ctrl-click only adds and removes the shade.

Well, that does it for me today. My ToDo list for tomorrow:

  1. Implement the Clear Map and Fill Map buttons

  2. Implement brush shapes

  3. Modify bottom editor panel - shrink it width-wise to remove all that empty space between Map Sizes and Map Name from some removed features

  4. Remove the New Map button. New maps are now created by selecting a new map size

  5. Implement map saves

  6. Implement map loads

  7. Implement help text


If I can get that all done tomorrow I will have finished the map editor!!

Until tomorrow...
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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!