33
assets/SpaceMono-Bold.ttf.import
Normal file
33
assets/SpaceMono-Bold.ttf.import
Normal file
@@ -0,0 +1,33 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://dmitg6232hytb"
|
||||
path="res://.godot/imported/SpaceMono-Bold.ttf-a0599d1b2f2dabf2e3ca851caf1baa92.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/SpaceMono-Bold.ttf"
|
||||
dest_files=["res://.godot/imported/SpaceMono-Bold.ttf-a0599d1b2f2dabf2e3ca851caf1baa92.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
33
assets/SpaceMono-BoldItalic.ttf.import
Normal file
33
assets/SpaceMono-BoldItalic.ttf.import
Normal file
@@ -0,0 +1,33 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://d2edhb701t42t"
|
||||
path="res://.godot/imported/SpaceMono-BoldItalic.ttf-f7b46e55b1271856b01bb8cddc5a12ab.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/SpaceMono-BoldItalic.ttf"
|
||||
dest_files=["res://.godot/imported/SpaceMono-BoldItalic.ttf-f7b46e55b1271856b01bb8cddc5a12ab.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
33
assets/SpaceMono-Italic.ttf.import
Normal file
33
assets/SpaceMono-Italic.ttf.import
Normal file
@@ -0,0 +1,33 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontFile"
|
||||
uid="uid://cjyu63kdviglf"
|
||||
path="res://.godot/imported/SpaceMono-Italic.ttf-c3b45ba693c1f9c8acc44c6917acf7a0.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/SpaceMono-Italic.ttf"
|
||||
dest_files=["res://.godot/imported/SpaceMono-Italic.ttf-c3b45ba693c1f9c8acc44c6917acf7a0.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
Rendering=null
|
||||
antialiasing=1
|
||||
generate_mipmaps=false
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
allow_system_fallback=true
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
oversampling=0.0
|
||||
Fallbacks=null
|
||||
fallbacks=[]
|
||||
Compress=null
|
||||
compress=true
|
||||
preload=[]
|
||||
language_support={}
|
||||
script_support={}
|
||||
opentype_features={}
|
||||
@@ -15,6 +15,10 @@ run/main_scene="res://scene/world.tscn"
|
||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/untyped_declaration=1
|
||||
|
||||
[gui]
|
||||
|
||||
theme/custom="res://data/world_theme.tres"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bbsaqy4xm1ldf"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Base.gd" id="1_0nxag"]
|
||||
[ext_resource type="Script" path="res://scripts/base.gd" id="1_5hpho"]
|
||||
|
||||
[node name="Base" type="Node2D"]
|
||||
script = ExtResource("1_0nxag")
|
||||
script = ExtResource("1_5hpho")
|
||||
|
||||
[node name="ExpandTimer" type="Timer" parent="."]
|
||||
autostart = true
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://m0us5xqa3gnk"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://m0us5xqa3gnk"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/world.gd" id="1_yf6q1"]
|
||||
[ext_resource type="TileSet" uid="uid://d1sh6dy2w10b0" path="res://data/scifi_tileset.tres" id="2_sa7dm"]
|
||||
[ext_resource type="Script" path="res://scripts/Window.gd" id="3_bfjot"]
|
||||
[ext_resource type="Script" path="res://scripts/BuildingManager.gd" id="4_61js3"]
|
||||
[ext_resource type="Script" path="res://scripts/window.gd" id="3_bfjot"]
|
||||
[ext_resource type="Script" path="res://scripts/building_manager.gd" id="4_61js3"]
|
||||
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="5_qhth7"]
|
||||
|
||||
[sub_resource type="FastNoiseLite" id="FastNoiseLite_teaou"]
|
||||
|
||||
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_8pjar"]
|
||||
noise = SubResource("FastNoiseLite_teaou")
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_m3qlj"]
|
||||
atlas = ExtResource("5_qhth7")
|
||||
region = Rect2(640, 768, 128, 128)
|
||||
@@ -21,7 +16,6 @@ region = Rect2(640, 384, 128, 128)
|
||||
|
||||
[node name="world" type="Node2D"]
|
||||
script = ExtResource("1_yf6q1")
|
||||
noise_texture = SubResource("NoiseTexture2D_8pjar")
|
||||
|
||||
[node name="world_grid" type="TileMap" parent="."]
|
||||
tile_set = ExtResource("2_sa7dm")
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
extends Node2D
|
||||
class_name Base
|
||||
|
||||
@export var world_grid: TileMap
|
||||
var grid_loc
|
||||
var i = 1
|
||||
@export var world: World
|
||||
var grid_loc: Vector2i
|
||||
|
||||
const curruption_directions := [Vector2i.LEFT, Vector2i.RIGHT, Vector2i.UP, Vector2i.DOWN]
|
||||
var corruption_tiles: Array[Vector2i] = []
|
||||
|
||||
func _ready():
|
||||
grid_loc = world_grid.local_to_map(position)
|
||||
func _ready() -> void:
|
||||
grid_loc = world.grid_location(position)
|
||||
world.change_location_data(grid_loc, Constants.TilemapLayers.BUILDINGS, Vector2i(17,7))
|
||||
corruption_tiles.append(grid_loc)
|
||||
world_grid.set_cell(Constants.TilemapLayers.BUILDINGS, grid_loc, 0, Vector2i(17,7))
|
||||
world.corrupt_location(grid_loc)
|
||||
|
||||
|
||||
func _on_expand_timer_timeout():
|
||||
var corrupt_tile = corruption_tiles.pick_random() + self.curruption_directions.pick_random()
|
||||
func _on_expand_timer_timeout() -> void:
|
||||
var corrupt_tile: Vector2i = corruption_tiles.pick_random() + self.curruption_directions.pick_random()
|
||||
while corruption_tiles.has(corrupt_tile):
|
||||
corrupt_tile = corruption_tiles.pick_random() + self.curruption_directions.pick_random()
|
||||
corruption_tiles.append(corrupt_tile)
|
||||
world_grid.set_cells_terrain_connect(Constants.TilemapLayers.CORRUPTION, corruption_tiles, 0, 0)
|
||||
i += 1
|
||||
world.corrupt_location(corrupt_tile)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var world_grid = $"../world_grid"
|
||||
@onready var world: World = $".."
|
||||
var base = preload("res://scene/base.tscn")
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
var build = base.instantiate()
|
||||
build.position = get_global_mouse_position()
|
||||
build.world_grid = world_grid
|
||||
build.world = world
|
||||
add_child(build)
|
||||
#world_grid.set_cell(2, world_grid.local_to_map(get_global_mouse_position()), 0, Vector2i(16,2))
|
||||
16
scripts/cell_data.gd
Normal file
16
scripts/cell_data.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
class_name CellData
|
||||
extends Node
|
||||
|
||||
@export var layer_info: Dictionary = {
|
||||
Constants.TilemapLayers.CORRUPTION: false
|
||||
}
|
||||
var _pos: Vector2i
|
||||
|
||||
func _init(pos: Vector2i) -> void:
|
||||
_pos = pos
|
||||
|
||||
func change_layer(layer: int, data: Variant) -> void:
|
||||
layer_info[layer] = data
|
||||
|
||||
func is_corrupted() -> bool:
|
||||
return layer_info[Constants.TilemapLayers.CORRUPTION]
|
||||
@@ -1,12 +1,10 @@
|
||||
extends Node2D
|
||||
class_name World extends Node2D
|
||||
|
||||
@export var noise_texture: NoiseTexture2D
|
||||
var noise_values
|
||||
@onready var world_grid = $world_grid
|
||||
|
||||
var resource_texture: Noise = FastNoiseLite.new()
|
||||
@export var resoure_quantity = 0.4
|
||||
|
||||
var terrain_noise := FastNoiseLite.new()
|
||||
var resource_noise: Noise = FastNoiseLite.new()
|
||||
|
||||
var temp_size = 150
|
||||
var temp_noise_val = []
|
||||
var temp_noise_reg = []
|
||||
@@ -14,11 +12,15 @@ var temp_noise_reg = []
|
||||
var noise_regions = [-999,10,150,200,999]
|
||||
var atlas_regions = [Vector2i(0,1),Vector2i(0,0),Vector2i(2,0),Vector2i(0,2)]
|
||||
|
||||
var world_data: Dictionary = {}
|
||||
|
||||
@onready var world_grid: TileMap = $world_grid
|
||||
|
||||
func get_noise_value(x: int, y: int):
|
||||
return noise_values.get_noise_2d(x,y) * 500
|
||||
return terrain_noise.get_noise_2d(x,y) * 500
|
||||
|
||||
func is_resource_tile(x: int, y: int) -> bool:
|
||||
return resource_texture.get_noise_2d(x, y) > resoure_quantity
|
||||
return resource_noise.get_noise_2d(x, y) > resoure_quantity
|
||||
|
||||
func get_noise_region(x,y):
|
||||
var noise_val = get_noise_value(x,y)
|
||||
@@ -27,22 +29,35 @@ func get_noise_region(x,y):
|
||||
return i
|
||||
|
||||
func _ready():
|
||||
resource_texture.seed = randi()
|
||||
#await resource_texture.changed
|
||||
noise_values = noise_texture.noise
|
||||
terrain_noise.seed = randi()
|
||||
resource_noise.seed = randi()
|
||||
|
||||
for x in range(-temp_size, temp_size):
|
||||
for y in range(-temp_size, temp_size):
|
||||
world_grid.set_cell(Constants.TilemapLayers.GROUND, Vector2i(x,y),0,atlas_regions[get_noise_region(x,y)])
|
||||
change_location_data(Vector2i(x,y), Constants.TilemapLayers.GROUND, atlas_regions[get_noise_region(x,y)])
|
||||
if is_resource_tile(x,y):
|
||||
world_grid.set_cell(Constants.TilemapLayers.ENVIRONMENT, Vector2i(x,y), 0, Vector2i(5,6))
|
||||
change_location_data(Vector2i(x,y), Constants.TilemapLayers.ENVIRONMENT, Vector2i(5,6))
|
||||
temp_noise_val.append(get_noise_value(x,y))
|
||||
temp_noise_reg.append(get_noise_region(x,y))
|
||||
prints(temp_noise_val.min(), temp_noise_val.max())
|
||||
for region in noise_regions.size():
|
||||
prints(region, noise_regions[region], temp_noise_reg.count(region))
|
||||
#get_tree().quit()
|
||||
|
||||
func _process(delta):
|
||||
var mouse_pos = world_grid.local_to_map(get_local_mouse_position())
|
||||
world_grid.clear_layer(Constants.TilemapLayers.CURSOR)
|
||||
world_grid.set_cell(Constants.TilemapLayers.CURSOR, mouse_pos,0,Vector2i(0,7))
|
||||
|
||||
func corrupt_location(loc: Vector2i):
|
||||
world_data[loc].change_layer(Constants.TilemapLayers.CORRUPTION, true)
|
||||
var corrupted_cells := world_data.values().filter(func(cell: CellData): return cell.is_corrupted()).map(func(cell: CellData) -> Vector2i: return cell._pos)
|
||||
world_grid.set_cells_terrain_connect(Constants.TilemapLayers.CORRUPTION, corrupted_cells, 0, 0)
|
||||
|
||||
func grid_location(global_pos: Vector2) -> Vector2i:
|
||||
return world_grid.local_to_map(global_pos)
|
||||
|
||||
func change_location_data(pos: Vector2i, layer: int, data: Vector2i) -> void:
|
||||
if not world_data.has(pos):
|
||||
world_data[pos] = CellData.new(pos)
|
||||
world_data[pos].change_layer(layer, data)
|
||||
world_grid.set_cell(layer, pos, 0, data)
|
||||
|
||||
Reference in New Issue
Block a user