• Advertisement
  • entries
    740
  • comments
    957
  • views
    731273

A Fine Days Work...

Sign in to follow this  

95 views

Sunday, Dec 18

Well I knocked off tasks 1-4 from my previous entry, which is the least I wanted to get done today. I figured getting the brushes to work properly would take some time, and it did. Task #1 took me less than 20 minutes, and tasks #3 & 4 took me about an hour, I'm still not that good at Photoshop and a bad GUI file save made me go back and reposition the controls again. The rest of the day while I was working was spent getting the brushes to cooperate. I had thought up the design last night and I'm glad it worked out as well as I had hoped.

The brushes are dynamic, and I can change their shape without having to recompile anything, thanks to the TorqueDB. Here's one of my brush DB entries:


-text=null
-value=11
-data=0 1 0 0 1 0 1 -1
-desc=null


The data field holds the brush shape, which in this case would be

+
++
+

It works by defining tiles around the mouse cursor's location using offsets. There are 8 numbers for this brush, which join up to form 4 pairs, and each pair is a tile location offset. Therefore my code is simply thus:

function showBrush(%tilePosition)
{
// get the data
%tempData = TorqueDB.searchByInstanceWithClass("brush", "value", $gameData.brushSelection);
%brushData = %tempData.contents[$DATA_FIELD];
%homeTile = %tilePosition;

// clear away previous brush image
$gameMap.map.getTileLayer($TILE_OVERLAY_LAYER).clearLayer();

// loop through the data pairs and set the tile(s)
for (%pair = 0; %pair < getWordCount(%brushData) / 2; %pair++)
{
// get the pair
%brushPair = getWord(%brushData, %pair * 2) SPC getWord(%brushData, (%pair * 2) + 1);

// update the location
%tilePosition = getWord(%homeTile, 0) + getWord(%brushPair, 0) SPC getWord(%homeTile, 1) + getWord(%brushPair, 1);

// set the tile
$gameMap.setMapTile($TILE_OVERLAY_LAYER, %tilePosition, highlightImageMap, 5, 0, $NO_DATA);
}

} // end showBrush



This function is called everytime the mouse moves into a new tile on the map and highlights the tiles to show the user what tiles will be affected by the brush.

So the brushes now all work, although there is one catch... there's no way to get back to the single one-tile brush! For now I've just linked that function to a hotkey ("x"), but in the future I'd like to include a button somewhere that will deselect the brush buttons and let you place tiles one at a time again.

Okay okay, time for pretty screens, cause I know that's all you're really here for [smile]


Here's just a look at the new bottom panel. Much better.


Oooh highlighted tile


That brush was boring. Ooh! Let's make Tetris-shaped maps!!


One click, and presto!


Adding some planets with a new brush

So yey! This is fun, creating maps and all. Too bad I can't save em yet. DOH! But I'll be remedying that problem tomorrow. My remaining tasks:

  1. Implement map saves

  2. Implement map loads

  3. Implement help text


Yup. I've decided that after I complete the map editor, I'm going to take the rest of the year off from GC development, heck game dev in general. For one thing my girl will be back home for winter break in a few days, plus GDNet's ramping up the GDC prep, and GI is finally moving again on my new project. So plenty to keep me busy. After New Years I'll begin to work on the actual gameplay. call it Phase 2 if you will [smile]

So okay that's all for me tonight! I'm gonna keep rockin out to the Trans-siberian Orchestra - gets me in that holiday spirit hardcore know what I mean? Yea... right.... sooooo

bye!
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