• Create Account

# Vaerydian

## Lighting, Tile Maps, and Data Driven Development!

Posted by , 31 May 2013 - · 1,087 views
Vaerydian, Tile Lighting and 1 more...
I've recently implemented my new tile based lighting system with tile shadowing too! You can see the nice results in the video below:

Its nothing fancy, just a simple implementation of a Shadow Casting algorithm It gets the job done.

Additionally, i've converted my map generation tech to use map defs now. So now maps defined like so:
```{
"name":"DUNGEON_DEFAULT",
"map_type":"DUNGEON",
"tile_maps":[
{
"map_to":"WALL",
"tiles":[
{"name":"DUNGEON_WALL","prob":100}
]
},
{
"map_to":"FLOOR",
"tiles":[
{"name":"DUNGEON_FLOOR","prob":100}
]
},
{
"map_to":"DOOR",
"tiles":[
{"name":"DUNGEON_DOOR","prob":100}
]
}
{
"map_to":"CORRIDOR",
"tiles":[
{"name":"DUNGEON_CORRIDOR","prob":100}
]
}
{
"map_to":"EARTH",
"tiles":[
{"name":"DUNGEON_EARTH","prob":100}
]
}
{
"map_to":"BEDROCK",
"tiles":[
{"name":"DUNGEON_BEDROCK","prob":100}
]
}
]
}```
can be used to generate maps in the game.

It works by setting tile definitions that are referenced in code like so for an east room construction:
```case EAST:
//space enough to build it?
for (int dy = (y-ylen/2); dy < (y+(ylen+1)/2); dy++){
if (dy < 0 || dy > map.YSize) return false;
for (int dx = x; dx < (x+xlen); dx++){
if (dx < 0 || dx > map.XSize) return false;
if (!MapHelper.isOfTileType(map, map.Terrain[dx,dy], "EARTH")) return false;
}
}

//ok to build room
for (int dy = (y-ylen/2); dy < (y+(ylen+1)/2); dy++){
for (int dx = x; dx < (x+xlen); dx++){
if (dx == x) MapHelper.setTerrain(map.Terrain[dx,dy], map.MapDef.Name, "WALL");
else if (dx == (x+xlen-1)) MapHelper.setTerrain(map.Terrain[dx,dy], map.MapDef.Name, "WALL");
else if (dy == (y-ylen/2)) MapHelper.setTerrain(map.Terrain[dx,dy], map.MapDef.Name, "WALL");
else if (dy == (y+(ylen-1)/2)) MapHelper.setTerrain(map.Terrain[dx,dy], map.MapDef.Name, "WALL");
else{ MapHelper.setTerrain(map.Terrain[dx,dy], map.MapDef.Name, "FLOOR");}
}
}

break;
```
and these particular helpers reference definition structs that are loaded in and constructed at runtime based on the definition files from the previous reference.

Combining all of this together can be shown in this video where i create a quick face png texture and add it to my game.

Anyway, thats all for now!

## Musings on Data Configs

Posted by , 04 May 2013 - · 912 views
JSON, Data Driven Games and 1 more...
Haven't done too much over this week. Mainly just working on concepts surrounding creature definition files and ideas on how i'll make map configs work.

Here is how the creatures.v file is forming up so far:
```{
"creature_defs":[
{
"name":"BAT",
"character_def":"BAT",
"behavior_def":"DEFAULT_ENEMY",
"acb_def":"DEFAULT_ENEMY",
"skill_level":0,
"information":{
"name":"Bat",
"general_group":"BAT",
"variation_group":"NONE",
"unique_group":"NONE"
},
"interactions_def":"DEFAULT_ENEMY",
"equipment":{
"weapon_def":"BAT_SONIC",
"armor_def":"BAT_ARMOR"
},
"knowledges":{
},
"statistics":{
},
"health":{
},
"skills":{
},
"factions":{
}
}
]
}

```

not much to see yet, but it captures most of the non derived/generated component definitions.

The maps are a different affair.

some early configs just for generation parameters looked like so:
```{
"WORLD" :{
"x" : 0,
"y" : 0,
"dx" : 854,
"dy" : 480,
"z" : 5.0,
"xsize" : 854,
"ysize" : 480,
"seed" : 42
},
"CAVE" :{
"x" : 100,
"y" : 100,
"prob" : 45,
"cell_op_spec" : true,
"iter" : 50000,
"neighbors" : 4,
"seed" : 42
}
}

```

but those just tell the generation routines what to use as defaults. So i thought of how i may start clustering like-minded information together and came up with my maps.v
```{
"map_types":{
"CAVE": 0,
"DUNGEON": 1,
"TOWN": 2,
"CITY": 3,
"TOWER": 4,
"OUTPOST": 5,
"FORT": 6,
"NEXUS": 7,
"WORLD": 8,
"WILDERNESS": 9
},
"map_defs":[
{"name":"NONE", "id":0},
{"name":"CAVE", "id":1}
],
"map_params":{
"WORLD" :{
"world_params_x" : 0,
"world_params_y" : 0,
"world_params_dx" : 854,
"world_params_dy" : 480,
"world_params_z" : 5.0,
"world_params_xsize" : 854,
"world_params_ysize" : 480,
"world_params_seed" : null
},
"CAVE" :{
"cave_params_x" : 100,
"cave_params_y" : 100,
"cave_params_prob" : 45,
"cave_params_cell_op_spec" : true,
"cave_params_iter" : 50000,
"cave_params_neighbors" : 4,
"cave_params_seed" : null
}
}
}

```
here you can see i took the params file and just shoved it in an object def location. I also think the config defs like "cave_params_cell_op_spec" need to be shortened, but we'll see if i end up calling it enough times for it to matter. The new sections are just a listing of the types of maps i want to players to know they can generate and a definitions section where the maps will be defined. What i'm thinking of doing is having some default, yet tweakable parameters for each map definition, maybe not for the world, but definitely for the other maps. The idea would be that the map would expect one-to-many terrain definitions to be set in certain list definitions in the json, it would then choose them during run-time to set the tiles and data structures. so you would have definitions like:
```"walls":[
"TERRAIN_GRANITE",
"TERRAIN_CARVED_STONE",
"TERRAIN_STONE_WALL_TORCH"
],
"floors":[
"TERRAIN_STONE_FLOOR",
"TERRAIN_TILED_STONE",
"TERRAIN_CRACKED_STONE_FLOOR"
]
```
and each of those definitions would be defined in the terrain.v config file like so:
```{
"name" : "BASE_LAND",
"id" : 1,
"texture" : "terrain\\default",
"texture_offset" : [
0,
0
],
"color" : [
255,
255,
255
],
"passible" : true,
"effect" : "NONE",
"type" : "FLOOR"
}
```

This way the game would know to randomly select "floor" terrain during generation that is defined in its data structures using the specs defined in the terrain.v files. To increase variety i may add some additional info like probability of occurrence based on either pure randomness or maybe depth of the player. So you start out in more wilderness-y like maps then move into caves then move into small dungeons then into underground cities, etc. Not sure how i want to approach that or if it should just be added to my back-log of things to do after alpha 2 is complete.

Anyway, I think that'll give me a fun and flexible map system to work with.

That's all for now!

S M T W T F S
1234
567891011
12131415161718
19202122232425
262728293031