Made rendering more interesting
parent
deaaf43db9
commit
f0c3035a5f
|
@ -43,6 +43,9 @@ window/stretch/aspect="expand"
|
||||||
view=false
|
view=false
|
||||||
android=false
|
android=false
|
||||||
export=false
|
export=false
|
||||||
|
environ=false
|
||||||
|
clear=false
|
||||||
|
clear_color=false
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
@ -82,5 +85,5 @@ common/enable_pause_aware_picking=true
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
environment/default_clear_color=Color( 0.0745098, 0.388235, 0.576471, 1 )
|
environment/default_clear_color=Color( 0.027451, 0.133333, 0.34902, 1 )
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/default_environment="res://default_env.tres"
|
||||||
|
|
|
@ -3,7 +3,8 @@ extends Node2D
|
||||||
enum TileType {
|
enum TileType {
|
||||||
None,
|
None,
|
||||||
Sand,
|
Sand,
|
||||||
Grass
|
Grass,
|
||||||
|
DeepGrass
|
||||||
}
|
}
|
||||||
|
|
||||||
var TileTypeFromString = { "None": TileType.None, "Sand": TileType.Sand, "Grass": TileType.Grass }
|
var TileTypeFromString = { "None": TileType.None, "Sand": TileType.Sand, "Grass": TileType.Grass }
|
||||||
|
@ -30,11 +31,13 @@ func set_hex_scale(scale):
|
||||||
var NoneColors = create_color_array ("#885555")
|
var NoneColors = create_color_array ("#885555")
|
||||||
var SandColors = create_color_array ("#ffa106")
|
var SandColors = create_color_array ("#ffa106")
|
||||||
var GrassColors = create_color_array ("#4b9635")
|
var GrassColors = create_color_array ("#4b9635")
|
||||||
|
var DeepGrassColors = create_color_array ("#2b5d1d")
|
||||||
|
|
||||||
HexColors = {
|
HexColors = {
|
||||||
TileType.None: NoneColors,
|
TileType.None: NoneColors,
|
||||||
TileType.Sand: SandColors,
|
TileType.Sand: SandColors,
|
||||||
TileType.Grass: GrassColors
|
TileType.Grass: GrassColors,
|
||||||
|
TileType.DeepGrass: DeepGrassColors
|
||||||
}
|
}
|
||||||
|
|
||||||
func create_color_array(color: Color):
|
func create_color_array(color: Color):
|
||||||
|
@ -50,4 +53,5 @@ func get_tile_color (type_name: String):
|
||||||
"None": return HexColors[TileType.None]
|
"None": return HexColors[TileType.None]
|
||||||
"Sand": return HexColors[TileType.Sand]
|
"Sand": return HexColors[TileType.Sand]
|
||||||
"Grass": return HexColors[TileType.Grass]
|
"Grass": return HexColors[TileType.Grass]
|
||||||
|
"DeepGrass": return HexColors[TileType.DeepGrass]
|
||||||
_ : return null
|
_ : return null
|
||||||
|
|
|
@ -95,12 +95,38 @@ func mark_grass():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func mark_deep_grass():
|
||||||
|
var old_tiles = tiles
|
||||||
|
tiles = {}
|
||||||
|
|
||||||
|
for tile in old_tiles:
|
||||||
|
if old_tiles[tile] != "Grass":
|
||||||
|
tiles[tile] = old_tiles[tile]
|
||||||
|
continue
|
||||||
|
|
||||||
|
var hex_coord = Globals.WorldToHex(tile)
|
||||||
|
|
||||||
|
var neighbours = Globals.HexGrid.get_hex_at(hex_coord).get_all_adjacent()
|
||||||
|
var is_center_cell = true
|
||||||
|
for cell in neighbours:
|
||||||
|
var world_coord = Globals.HexToWorld(hex_coord + cell.axial_coords)
|
||||||
|
if world_coord in old_tiles.keys() and old_tiles[world_coord] != "Grass":
|
||||||
|
is_center_cell = false
|
||||||
|
break
|
||||||
|
|
||||||
|
if is_center_cell:
|
||||||
|
tiles[tile] = "DeepGrass"
|
||||||
|
else:
|
||||||
|
tiles[tile] = "Grass"
|
||||||
|
|
||||||
|
|
||||||
func generate():
|
func generate():
|
||||||
var size = 62
|
var size = 62
|
||||||
|
|
||||||
generate_random_walk(size)
|
generate_random_walk(size)
|
||||||
extrude_island()
|
extrude_island()
|
||||||
mark_grass()
|
mark_grass()
|
||||||
|
mark_deep_grass()
|
||||||
|
|
||||||
calc_bbox()
|
calc_bbox()
|
||||||
update()
|
update()
|
||||||
|
@ -231,10 +257,44 @@ func draw_bsphere():
|
||||||
func _draw():
|
func _draw():
|
||||||
var transform = get_transform()
|
var transform = get_transform()
|
||||||
|
|
||||||
|
# draw transitions beach to deep water
|
||||||
|
for coord in tiles.keys():
|
||||||
|
var color_array = null
|
||||||
|
|
||||||
|
if tiles[coord] == "Sand":
|
||||||
|
draw_set_transform (coord + offset_world, 0, Vector2.ONE * 6)
|
||||||
|
color_array = HexTileDrawer.create_color_array(Color("#10479bcd"))
|
||||||
|
draw_polygon(HexTileDrawer.HexPoints, color_array)
|
||||||
|
|
||||||
|
draw_set_transform (coord + offset_world, 0, Vector2.ONE * 4)
|
||||||
|
color_array = HexTileDrawer.create_color_array(Color("#10479bcd"))
|
||||||
|
draw_polygon(HexTileDrawer.HexPoints, color_array)
|
||||||
|
|
||||||
|
draw_set_transform (coord + offset_world, 0, Vector2.ONE * 2)
|
||||||
|
color_array = HexTileDrawer.create_color_array(Color("#10479bcd"))
|
||||||
|
draw_polygon(HexTileDrawer.HexPoints, color_array)
|
||||||
|
|
||||||
|
# draw white line around island as breaking waves
|
||||||
|
for coord in tiles.keys():
|
||||||
|
if tiles[coord] == "Sand":
|
||||||
|
draw_set_transform (coord + offset_world, 0, Vector2.ONE * 1.05)
|
||||||
|
var color_array = HexTileDrawer.create_color_array(Color("#ffffffff"))
|
||||||
|
draw_polygon(HexTileDrawer.HexPoints, color_array)
|
||||||
|
|
||||||
|
# regular tile drawing
|
||||||
for coord in tiles.keys():
|
for coord in tiles.keys():
|
||||||
draw_set_transform (coord + offset_world, 0, Vector2.ONE)
|
draw_set_transform (coord + offset_world, 0, Vector2.ONE)
|
||||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.get_tile_color(tiles[coord]))
|
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.get_tile_color(tiles[coord]))
|
||||||
|
|
||||||
|
# make grass tiles a bit more irregular
|
||||||
|
for coord in tiles.keys():
|
||||||
|
var color_array = null
|
||||||
|
if tiles[coord] == "Grass":
|
||||||
|
draw_set_transform (coord + offset_world, 0, Vector2.ONE * 2)
|
||||||
|
color_array = HexTileDrawer.create_color_array(Color("#4f4b9635"))
|
||||||
|
draw_polygon(HexTileDrawer.HexPoints, color_array)
|
||||||
|
|
||||||
|
|
||||||
if highlight_treasure and treasure_local_coords:
|
if highlight_treasure and treasure_local_coords:
|
||||||
draw_set_transform (treasure_local_coords + offset_world, 0, Vector2.ONE)
|
draw_set_transform (treasure_local_coords + offset_world, 0, Vector2.ONE)
|
||||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.create_color_array("#922"))
|
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.create_color_array("#922"))
|
||||||
|
|
Loading…
Reference in New Issue