Added blocky game WIP

master
Marc Gilleron 2020-07-26 01:35:53 +01:00
parent cb2cb5283a
commit 8b9cb5b70f
65 changed files with 2009 additions and 1 deletions

View File

@ -0,0 +1,121 @@
extends Resource
const ROTATION_TYPE_NONE = 0
const ROTATION_TYPE_AXIAL = 1
const ROOT = "res://blocky_game/blocks"
class Block:
var id := 0
var name := ""
var gui_model_path := ""
var directory := ""
var rotation_type := ROTATION_TYPE_NONE
var sprite_texture : Texture
var transparent := false
var backface_culling := true
var voxels := []
class RawMapping:
var block_id := 0
var variant_index := 0
var _voxel_library := preload("res://blocky_game/blocks/voxel_library.tres")
var _blocks = []
var _raw_mappings = []
func _init():
_create_block({
"name": "air",
"directory": "",
"gui_model": "",
"rotation_type": ROTATION_TYPE_NONE,
"voxels": [0],
"transparent": true
})
_create_block({
"name": "dirt",
"gui_model": "dirt.obj",
"rotation_type": ROTATION_TYPE_NONE,
"voxels": [1],
"transparent": false
})
_create_block({
"name": "grass",
"gui_model": "grass.obj",
"rotation_type": ROTATION_TYPE_NONE,
"voxels": [2],
"transparent": false
})
_create_block({
"name": "log",
"gui_model": "log_y.obj",
"rotation_type": ROTATION_TYPE_NONE,
"voxels": [3],
"transparent": false
})
_create_block({
"name": "planks",
"gui_model": "planks.obj",
"rotation_type": ROTATION_TYPE_NONE,
"voxels": [7],
"transparent": false
})
_create_block({
"name": "stairs",
"gui_model": "stairs_nx.obj",
"rotation_type": ROTATION_TYPE_NONE,
"voxels": [6],
"transparent": false
})
_create_block({
"name": "tall_grass",
"gui_model": "tall_grass.obj",
"rotation_type": ROTATION_TYPE_NONE,
"voxels": [8],
"transparent": true,
"backface_culling": false
})
func get_block(id: int) -> Block:
assert(id >= 0)
return _blocks[id]
func get_block_count() -> int:
return len(_blocks)
func _create_block(params: Dictionary):
_defaults(params, {
"rotation_type": ROTATION_TYPE_NONE,
"transparent": false,
"backface_culling": true,
"directory": params.name
})
var block = Block.new()
block.id = len(_blocks)
block.name = params.name
block.directory = params.directory
block.rotation_type = params.rotation_type
block.voxels = params.voxels
block.transparent = params.transparent
block.backface_culling = params.backface_culling
if block.directory != "":
block.gui_model_path = str(ROOT, "/", params.directory, "/", params.gui_model)
var sprite_path = str(ROOT, "/", params.directory, "/", params.name, "_sprite.png")
block.sprite_texture = load(sprite_path)
_blocks.append(block)
func _defaults(d, defaults):
for k in defaults:
if not d.has(k):
d[k] = defaults[k]

View File

@ -0,0 +1,6 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://blocky_game/blocks/blocks.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )

View File

@ -0,0 +1,44 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Dirt_Cube.005
v 1.000000 1.000000 1.000000
v 1.000000 0.000000 1.000000
v 0.000000 1.000000 1.000000
v 0.000000 0.000000 1.000000
v 1.000000 1.000000 0.000000
v 1.000000 0.000000 0.000000
v 0.000000 1.000000 0.000000
v 0.000000 0.000000 0.000000
vt 0.062500 0.937500
vt 0.125000 0.937500
vt 0.125000 1.000000
vt 0.062500 1.000000
vt 0.125000 0.937500
vt 0.125000 1.000000
vt 0.062500 1.000000
vt 0.062500 0.937500
vt 0.125000 0.937500
vt 0.062500 1.000000
vt 0.062500 0.937500
vt 0.125000 0.937500
vt 0.125000 1.000000
vt 0.062500 1.000000
vt 0.125000 1.000000
vt 0.062500 0.937500
vt 0.125000 0.937500
vt 0.125000 1.000000
vt 0.062500 1.000000
vt 0.062500 0.937500
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 0.0000
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/6/2 7/7/2 8/8/2
f 8/9/3 7/3/3 5/10/3 6/11/3
f 6/11/4 2/12/4 4/13/4 8/14/4
f 2/12/5 1/15/5 3/4/5 4/16/5
f 6/17/6 5/18/6 1/19/6 2/20/6

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/dirt.obj-1fef06bf6d07871529ff16021884561b.mesh"
[deps]
files=[ "res://.import/dirt.obj-1fef06bf6d07871529ff16021884561b.mesh" ]
source_file="res://blocky_game/blocks/dirt/dirt.obj"
dest_files=[ "res://.import/dirt.obj-1fef06bf6d07871529ff16021884561b.mesh", "res://.import/dirt.obj-1fef06bf6d07871529ff16021884561b.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/dirt_sprite.png-8fd4927699c8dbc7bb0d8794df6c0c23.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/blocks/dirt/dirt_sprite.png"
dest_files=[ "res://.import/dirt_sprite.png-8fd4927699c8dbc7bb0d8794df6c0c23.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,46 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Grass_Cube.004
v 1.000000 1.000000 1.000000
v 1.000000 0.000000 1.000000
v 0.000000 1.000000 1.000000
v 0.000000 0.000000 1.000000
v 1.000000 1.000000 0.000000
v 1.000000 0.000000 0.000000
v 0.000000 1.000000 0.000000
v 0.000000 0.000000 0.000000
vt -0.000000 0.937500
vt 0.062500 0.937500
vt 0.062500 1.000000
vt -0.000000 1.000000
vt 0.062500 0.875000
vt 0.062500 0.937500
vt 0.000000 0.937500
vt 0.000000 0.875000
vt 0.062500 0.875000
vt 0.062500 0.937500
vt 0.000000 0.937500
vt 0.000000 0.875000
vt 0.062500 0.937500
vt 0.125000 0.937500
vt 0.125000 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.062500 0.937500
vt 0.000000 0.937500
vt 0.000000 0.875000
vt 0.062500 0.875000
vt 0.000000 0.875000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 0.0000
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/6/2 7/7/2 8/8/2
f 8/9/3 7/10/3 5/11/3 6/12/3
f 6/13/4 2/14/4 4/15/4 8/16/4
f 2/17/5 1/18/5 3/19/5 4/20/5
f 6/21/6 5/2/6 1/1/6 2/22/6

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/grass.obj-a1fa19b4f082b287d3c924253fd7a375.mesh"
[deps]
files=[ "res://.import/grass.obj-a1fa19b4f082b287d3c924253fd7a375.mesh" ]
source_file="res://blocky_game/blocks/grass/grass.obj"
dest_files=[ "res://.import/grass.obj-a1fa19b4f082b287d3c924253fd7a375.mesh", "res://.import/grass.obj-a1fa19b4f082b287d3c924253fd7a375.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/grass_sprite.png-58d10c2898ee65a9ba889f38113c0e34.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/blocks/grass/grass_sprite.png"
dest_files=[ "res://.import/grass_sprite.png-58d10c2898ee65a9ba889f38113c0e34.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/log_sprite.png-f3d68ec34eea3e704896509a9cdc7833.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/blocks/log/log_sprite.png"
dest_files=[ "res://.import/log_sprite.png-f3d68ec34eea3e704896509a9cdc7833.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,46 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Log_X_Cube.002
v 1.000000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 1.000000 0.000000 1.000000
v 0.000000 0.000000 1.000000
v 1.000000 1.000000 0.000000
v 0.000000 1.000000 0.000000
v 1.000000 1.000000 1.000000
v 0.000000 1.000000 1.000000
vt 0.187500 0.937500
vt 0.250000 0.937500
vt 0.250000 1.000000
vt 0.187500 1.000000
vt 0.187500 0.937500
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 0.937500
vt 0.250000 0.937500
vt 0.250000 1.000000
vt 0.187500 1.000000
vt 0.187500 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn -0.0000 -1.0000 0.0000
vn -0.0000 0.0000 -1.0000
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/14/4 8/15/4
f 2/16/5 1/17/5 3/18/5 4/19/5
f 6/12/6 5/20/6 1/21/6 2/22/6

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/log_x.obj-29077f217973cbd7322f33a253576917.mesh"
[deps]
files=[ "res://.import/log_x.obj-29077f217973cbd7322f33a253576917.mesh" ]
source_file="res://blocky_game/blocks/log/log_x.obj"
dest_files=[ "res://.import/log_x.obj-29077f217973cbd7322f33a253576917.mesh", "res://.import/log_x.obj-29077f217973cbd7322f33a253576917.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

View File

@ -0,0 +1,46 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Log_Y_Cube
v 1.000000 1.000000 1.000000
v 1.000000 0.000000 1.000000
v 0.000000 1.000000 1.000000
v 0.000000 0.000000 1.000000
v 1.000000 1.000000 0.000000
v 1.000000 0.000000 0.000000
v 0.000000 1.000000 0.000000
v 0.000000 0.000000 0.000000
vt 0.187500 0.937500
vt 0.250000 0.937500
vt 0.250000 1.000000
vt 0.187500 1.000000
vt 0.187500 0.937500
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 0.937500
vt 0.250000 0.937500
vt 0.250000 1.000000
vt 0.187500 1.000000
vt 0.187500 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 0.0000
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/14/4 8/15/4
f 2/16/5 1/17/5 3/18/5 4/19/5
f 6/12/6 5/20/6 1/21/6 2/22/6

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/log_y.obj-98954c97d7fdf0d4cbad0b4e10c9e609.mesh"
[deps]
files=[ "res://.import/log_y.obj-98954c97d7fdf0d4cbad0b4e10c9e609.mesh" ]
source_file="res://blocky_game/blocks/log/log_y.obj"
dest_files=[ "res://.import/log_y.obj-98954c97d7fdf0d4cbad0b4e10c9e609.mesh", "res://.import/log_y.obj-98954c97d7fdf0d4cbad0b4e10c9e609.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

View File

@ -0,0 +1,46 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Log_Z_Cube.001
v 1.000000 0.000000 1.000000
v 1.000000 0.000000 0.000000
v 0.000000 0.000000 1.000000
v 0.000000 0.000000 0.000000
v 1.000000 1.000000 1.000000
v 1.000000 1.000000 0.000000
v 0.000000 1.000000 1.000000
v 0.000000 1.000000 0.000000
vt 0.187500 0.937500
vt 0.250000 0.937500
vt 0.250000 1.000000
vt 0.187500 1.000000
vt 0.187500 0.937500
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 0.937500
vt 0.250000 0.937500
vt 0.250000 1.000000
vt 0.187500 1.000000
vt 0.187500 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vt 0.187500 1.000000
vt 0.125000 1.000000
vt 0.125000 0.937500
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 -0.0000
vn 1.0000 0.0000 0.0000
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/14/4 8/15/4
f 2/16/5 1/17/5 3/18/5 4/19/5
f 6/12/6 5/20/6 1/21/6 2/22/6

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/log_z.obj-4aeb2b6c7e1d0919274b657c126ddc84.mesh"
[deps]
files=[ "res://.import/log_z.obj-4aeb2b6c7e1d0919274b657c126ddc84.mesh" ]
source_file="res://blocky_game/blocks/log/log_z.obj"
dest_files=[ "res://.import/log_z.obj-4aeb2b6c7e1d0919274b657c126ddc84.mesh", "res://.import/log_z.obj-4aeb2b6c7e1d0919274b657c126ddc84.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

View File

@ -0,0 +1,46 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Planks_Cube.010
v 1.000000 1.000000 1.000000
v 1.000000 0.000000 1.000000
v 0.000000 1.000000 1.000000
v 0.000000 0.000000 1.000000
v 1.000000 1.000000 0.000000
v 1.000000 0.000000 0.000000
v 0.000000 1.000000 0.000000
v 0.000000 0.000000 0.000000
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.937500
vt 0.250000 0.937500
vt 0.250000 0.875000
vt 0.187500 0.937500
vt 0.187500 0.875000
vt 0.250000 0.875000
vt 0.250000 0.937500
vt 0.187500 0.937500
vt 0.187500 0.875000
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.937500
vt 0.250000 0.937500
vt 0.250000 0.875000
vt 0.250000 0.937500
vt 0.187500 0.937500
vt 0.187500 0.875000
vt 0.250000 0.937500
vt 0.187500 0.937500
vt 0.187500 0.875000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 0.0000
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/14/4 8/15/4
f 2/16/5 1/17/5 3/18/5 4/19/5
f 6/12/6 5/20/6 1/21/6 2/22/6

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/planks.obj-d824fc3f8de0eb8dd170ec627845a579.mesh"
[deps]
files=[ "res://.import/planks.obj-d824fc3f8de0eb8dd170ec627845a579.mesh" ]
source_file="res://blocky_game/blocks/planks/planks.obj"
dest_files=[ "res://.import/planks.obj-d824fc3f8de0eb8dd170ec627845a579.mesh", "res://.import/planks.obj-d824fc3f8de0eb8dd170ec627845a579.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/planks_sprite.png-a667da5e452c5f4f4d851e580b8ee1a2.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/blocks/planks/planks_sprite.png"
dest_files=[ "res://.import/planks_sprite.png-a667da5e452c5f4f4d851e580b8ee1a2.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,70 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Stairs_NX_Cube.014
v 1.000000 0.000000 0.000000
v 1.000000 0.000000 1.000000
v 0.000000 1.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 1.000000 1.000000
v 0.000000 0.000000 1.000000
v 0.500000 1.000000 1.000000
v 0.500000 0.000000 1.000000
v 0.500000 1.000000 0.000000
v 1.000000 0.500000 0.000000
v 0.000000 0.500000 1.000000
v 1.000000 0.500000 1.000000
v 0.500000 0.500000 0.000000
v 0.500000 0.500000 1.000000
vt 0.250000 0.906250
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.187500 0.875000
vt 0.250000 0.875000
vt 0.250000 0.937500
vt 0.187500 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.937500
vt 0.250000 0.937500
vt 0.250000 0.875000
vt 0.250000 0.875000
vt 0.250000 0.906250
vt 0.218750 0.906250
vt 0.187500 0.937500
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.218750 0.906250
vt 0.250000 0.906250
vt 0.187500 0.906250
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.250000 0.906250
vt 0.312500 0.937500
vt 0.250000 0.937500
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 -0.0000
s off
f 9/1/1 3/2/1 5/3/1 7/4/1
f 4/5/2 6/6/2 5/7/2 3/8/2
f 4/9/3 1/10/3 2/11/3 6/12/3
f 1/13/4 4/5/4 3/8/4
f 2/14/5 12/15/5 14/16/5
f 5/17/5 6/18/5 2/14/5
f 9/19/4 13/20/4 3/8/4
f 10/21/4 1/13/4 13/20/4
f 1/13/6 10/21/6 12/22/6 2/23/6
f 5/17/5 14/16/5 7/24/5
f 12/25/1 10/26/1 13/27/1 14/28/1
f 9/29/6 7/30/6 14/28/6 13/27/6
l 11 5
l 8 2
l 6 8
l 6 11

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/stairs_nx.obj-2f792e892935646091f5f0ce0c769acc.mesh"
[deps]
files=[ "res://.import/stairs_nx.obj-2f792e892935646091f5f0ce0c769acc.mesh" ]
source_file="res://blocky_game/blocks/stairs/stairs_nx.obj"
dest_files=[ "res://.import/stairs_nx.obj-2f792e892935646091f5f0ce0c769acc.mesh", "res://.import/stairs_nx.obj-2f792e892935646091f5f0ce0c769acc.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

View File

@ -0,0 +1,70 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Stairs_NZ_Cube.013
v 1.000000 0.000000 1.000000
v 0.000000 0.000000 1.000000
v 1.000000 1.000000 0.000000
v 1.000000 0.000000 0.000000
v 0.000000 1.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 1.000000 0.500000
v 0.000000 0.000000 0.500000
v 1.000000 1.000000 0.500000
v 1.000000 0.500000 1.000000
v 0.000000 0.500000 0.000000
v 0.000000 0.500000 1.000000
v 1.000000 0.500000 0.500000
v 0.000000 0.500000 0.500000
vt 0.250000 0.906250
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.187500 0.875000
vt 0.250000 0.875000
vt 0.250000 0.937500
vt 0.187500 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.937500
vt 0.250000 0.937500
vt 0.250000 0.875000
vt 0.250000 0.875000
vt 0.250000 0.906250
vt 0.218750 0.906250
vt 0.187500 0.937500
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.218750 0.906250
vt 0.250000 0.906250
vt 0.187500 0.906250
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.250000 0.906250
vt 0.312500 0.937500
vt 0.250000 0.937500
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
s off
f 9/1/1 3/2/1 5/3/1 7/4/1
f 4/5/2 6/6/2 5/7/2 3/8/2
f 4/9/3 1/10/3 2/11/3 6/12/3
f 1/13/4 4/5/4 3/8/4
f 2/14/5 12/15/5 14/16/5
f 5/17/5 6/18/5 2/14/5
f 9/19/4 13/20/4 3/8/4
f 10/21/4 1/13/4 13/20/4
f 1/13/6 10/21/6 12/22/6 2/23/6
f 5/17/5 14/16/5 7/24/5
f 12/25/1 10/26/1 13/27/1 14/28/1
f 9/29/6 7/30/6 14/28/6 13/27/6
l 11 5
l 8 2
l 6 8
l 6 11

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/stairs_nz.obj-f1157de6da15363dafb0f6c1bd9be93d.mesh"
[deps]
files=[ "res://.import/stairs_nz.obj-f1157de6da15363dafb0f6c1bd9be93d.mesh" ]
source_file="res://blocky_game/blocks/stairs/stairs_nz.obj"
dest_files=[ "res://.import/stairs_nz.obj-f1157de6da15363dafb0f6c1bd9be93d.mesh", "res://.import/stairs_nz.obj-f1157de6da15363dafb0f6c1bd9be93d.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

View File

@ -0,0 +1,70 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Stairs_PX_Cube.016
v 0.000000 0.000000 1.000000
v 0.000000 0.000000 0.000000
v 1.000000 1.000000 1.000000
v 1.000000 0.000000 1.000000
v 1.000000 1.000000 0.000000
v 1.000000 0.000000 0.000000
v 0.500000 1.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 1.000000 1.000000
v 0.000000 0.500000 1.000000
v 1.000000 0.500000 0.000000
v 0.000000 0.500000 0.000000
v 0.500000 0.500000 1.000000
v 0.500000 0.500000 0.000000
vt 0.250000 0.906250
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.187500 0.875000
vt 0.250000 0.875000
vt 0.250000 0.937500
vt 0.187500 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.937500
vt 0.250000 0.937500
vt 0.250000 0.875000
vt 0.250000 0.875000
vt 0.250000 0.906250
vt 0.218750 0.906250
vt 0.187500 0.937500
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.218750 0.906250
vt 0.250000 0.906250
vt 0.187500 0.906250
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.250000 0.906250
vt 0.312500 0.937500
vt 0.250000 0.937500
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 0.0000
s off
f 9/1/1 3/2/1 5/3/1 7/4/1
f 4/5/2 6/6/2 5/7/2 3/8/2
f 4/9/3 1/10/3 2/11/3 6/12/3
f 1/13/4 4/5/4 3/8/4
f 2/14/5 12/15/5 14/16/5
f 5/17/5 6/18/5 2/14/5
f 9/19/4 13/20/4 3/8/4
f 10/21/4 1/13/4 13/20/4
f 1/13/6 10/21/6 12/22/6 2/23/6
f 5/17/5 14/16/5 7/24/5
f 12/25/1 10/26/1 13/27/1 14/28/1
f 9/29/6 7/30/6 14/28/6 13/27/6
l 11 5
l 8 2
l 6 8
l 6 11

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/stairs_px.obj-67ec7076bfe79cc04f9b0a32c2014344.mesh"
[deps]
files=[ "res://.import/stairs_px.obj-67ec7076bfe79cc04f9b0a32c2014344.mesh" ]
source_file="res://blocky_game/blocks/stairs/stairs_px.obj"
dest_files=[ "res://.import/stairs_px.obj-67ec7076bfe79cc04f9b0a32c2014344.mesh", "res://.import/stairs_px.obj-67ec7076bfe79cc04f9b0a32c2014344.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

View File

@ -0,0 +1,70 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o Stairs_PZ_Cube.015
v 0.000000 0.000000 0.000000
v 1.000000 0.000000 0.000000
v 0.000000 1.000000 1.000000
v 0.000000 0.000000 1.000000
v 1.000000 1.000000 1.000000
v 1.000000 0.000000 1.000000
v 1.000000 1.000000 0.500000
v 1.000000 0.000000 0.500000
v 0.000000 1.000000 0.500000
v 0.000000 0.500000 0.000000
v 1.000000 0.500000 1.000000
v 1.000000 0.500000 0.000000
v 0.000000 0.500000 0.500000
v 1.000000 0.500000 0.500000
vt 0.250000 0.906250
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.187500 0.875000
vt 0.250000 0.875000
vt 0.250000 0.937500
vt 0.187500 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.937500
vt 0.250000 0.937500
vt 0.250000 0.875000
vt 0.250000 0.875000
vt 0.250000 0.906250
vt 0.218750 0.906250
vt 0.187500 0.937500
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.218750 0.906250
vt 0.250000 0.906250
vt 0.187500 0.906250
vt 0.187500 0.875000
vt 0.218750 0.937500
vt 0.250000 0.875000
vt 0.312500 0.875000
vt 0.312500 0.906250
vt 0.250000 0.906250
vt 0.312500 0.937500
vt 0.250000 0.937500
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
s off
f 9/1/1 3/2/1 5/3/1 7/4/1
f 4/5/2 6/6/2 5/7/2 3/8/2
f 4/9/3 1/10/3 2/11/3 6/12/3
f 1/13/4 4/5/4 3/8/4
f 2/14/5 12/15/5 14/16/5
f 5/17/5 6/18/5 2/14/5
f 9/19/4 13/20/4 3/8/4
f 10/21/4 1/13/4 13/20/4
f 1/13/6 10/21/6 12/22/6 2/23/6
f 5/17/5 14/16/5 7/24/5
f 12/25/1 10/26/1 13/27/1 14/28/1
f 9/29/6 7/30/6 14/28/6 13/27/6
l 11 5
l 8 2
l 6 8
l 6 11

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/stairs_pz.obj-ebec5cdfd182578d91434779e4f73a2e.mesh"
[deps]
files=[ "res://.import/stairs_pz.obj-ebec5cdfd182578d91434779e4f73a2e.mesh" ]
source_file="res://blocky_game/blocks/stairs/stairs_pz.obj"
dest_files=[ "res://.import/stairs_pz.obj-ebec5cdfd182578d91434779e4f73a2e.mesh", "res://.import/stairs_pz.obj-ebec5cdfd182578d91434779e4f73a2e.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/stairs_sprite.png-f1745976e8d342a50030ccc6ec5644d4.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/blocks/stairs/stairs_sprite.png"
dest_files=[ "res://.import/stairs_sprite.png-f1745976e8d342a50030ccc6ec5644d4.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,24 @@
# Blender v2.83.0 OBJ File: 'blocks.blend'
# www.blender.org
o TallGrass_Cube.007
v 0.887023 0.784557 0.887023
v 0.887023 0.000000 0.887023
v 0.112977 0.784557 0.887023
v 0.112977 0.000000 0.887023
v 0.887023 0.784557 0.112977
v 0.887023 0.000000 0.112977
v 0.112977 0.784557 0.112977
v 0.112977 0.000000 0.112977
vt 0.062500 0.875000
vt 0.125000 0.875000
vt 0.125000 0.925781
vt 0.062500 0.925781
vt 0.125000 0.925781
vt 0.062500 0.925781
vt 0.062500 0.875000
vt 0.125000 0.875000
vn 0.7071 0.0000 0.7071
vn -0.7071 0.0000 0.7071
s off
f 4/1/1 6/2/1 5/3/1 3/4/1
f 1/5/2 7/6/2 8/7/2 2/8/2

View File

@ -0,0 +1,19 @@
[remap]
importer="wavefront_obj"
type="Mesh"
path="res://.import/tall_grass.obj-5feedaa80f104046e6e5697ec67dccb5.mesh"
[deps]
files=[ "res://.import/tall_grass.obj-5feedaa80f104046e6e5697ec67dccb5.mesh" ]
source_file="res://blocky_game/blocks/tall_grass/tall_grass.obj"
dest_files=[ "res://.import/tall_grass.obj-5feedaa80f104046e6e5697ec67dccb5.mesh", "res://.import/tall_grass.obj-5feedaa80f104046e6e5697ec67dccb5.mesh" ]
[params]
generate_tangents=true
scale_mesh=Vector3( 1, 1, 1 )
offset_mesh=Vector3( 0, 0, 0 )
optimize_mesh=true

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/tall_grass_sprite.png-de9d82cf417578f2a6f7e45a5245ed1e.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/blocks/tall_grass/tall_grass_sprite.png"
dest_files=[ "res://.import/tall_grass_sprite.png-de9d82cf417578f2a6f7e45a5245ed1e.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/terrain.png-9534a2f39c9550059e42b00bbe77d3d0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/blocks/terrain.png"
dest_files=[ "res://.import/terrain.png-9534a2f39c9550059e42b00bbe77d3d0.stex" ]
[params]
compress/mode=3
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=1
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@ -0,0 +1,8 @@
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
[ext_resource path="res://blocky_game/blocks/terrain.png" type="Texture" id=1]
[resource]
vertex_color_use_as_albedo = true
albedo_texture = ExtResource( 1 )
metallic_specular = 0.0

View File

@ -0,0 +1,9 @@
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
[ext_resource path="res://blocky_game/blocks/terrain.png" type="Texture" id=1]
[resource]
params_cull_mode = 2
params_use_alpha_scissor = true
params_alpha_scissor_threshold = 0.98
albedo_texture = ExtResource( 1 )

View File

@ -0,0 +1,9 @@
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
[ext_resource path="res://blocky_game/blocks/terrain.png" type="Texture" id=1]
[resource]
flags_transparent = true
albedo_color = Color( 0.7, 0.7, 0.7, 1 )
albedo_texture = ExtResource( 1 )
roughness = 0.0

View File

@ -0,0 +1,72 @@
[gd_resource type="VoxelLibrary" load_steps=18 format=2]
[ext_resource path="res://blocky_game/blocks/grass/grass.obj" type="ArrayMesh" id=1]
[ext_resource path="res://blocky_game/blocks/dirt/dirt.obj" type="ArrayMesh" id=2]
[ext_resource path="res://blocky_game/blocks/log/log_y.obj" type="ArrayMesh" id=3]
[ext_resource path="res://blocky_game/blocks/log/log_x.obj" type="ArrayMesh" id=4]
[ext_resource path="res://blocky_game/blocks/log/log_z.obj" type="ArrayMesh" id=5]
[ext_resource path="res://blocky_game/blocks/stairs/stairs_nx.obj" type="ArrayMesh" id=6]
[ext_resource path="res://blocky_game/blocks/planks/planks.obj" type="ArrayMesh" id=7]
[ext_resource path="res://blocky_game/blocks/tall_grass/tall_grass.obj" type="ArrayMesh" id=8]
[sub_resource type="Voxel" id=1]
voxel_name = "air"
[sub_resource type="Voxel" id=2]
voxel_name = "dirt"
geometry_type = 2
custom_mesh = ExtResource( 2 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
[sub_resource type="Voxel" id=3]
voxel_name = "grass"
geometry_type = 2
custom_mesh = ExtResource( 1 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
[sub_resource type="Voxel" id=4]
voxel_name = "log_x"
geometry_type = 2
custom_mesh = ExtResource( 4 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
[sub_resource type="Voxel" id=5]
voxel_name = "log_y"
geometry_type = 2
custom_mesh = ExtResource( 3 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
[sub_resource type="Voxel" id=6]
voxel_name = "log_z"
geometry_type = 2
custom_mesh = ExtResource( 5 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
[sub_resource type="Voxel" id=7]
voxel_name = "stairs_nx"
geometry_type = 2
custom_mesh = ExtResource( 6 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
[sub_resource type="Voxel" id=8]
voxel_name = "planks"
geometry_type = 2
custom_mesh = ExtResource( 7 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]
[sub_resource type="Voxel" id=9]
voxel_name = "tall_grass"
material_id = 2
geometry_type = 2
custom_mesh = ExtResource( 8 )
[resource]
voxels/0 = SubResource( 1 )
voxels/1 = SubResource( 2 )
voxels/2 = SubResource( 3 )
voxels/3 = SubResource( 4 )
voxels/4 = SubResource( 5 )
voxels/5 = SubResource( 6 )
voxels/6 = SubResource( 7 )
voxels/7 = SubResource( 8 )
voxels/8 = SubResource( 9 )

View File

@ -0,0 +1,12 @@
extends Node
onready var _light = $DirectionalLight
func _unhandled_input(event):
# TODO Make a pause menu with options?
if event is InputEventKey:
if event.pressed:
if event.scancode == KEY_L:
# Toggle shadows
_light.shadow_enabled = not _light.shadow_enabled

View File

@ -0,0 +1,76 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://blocky_game/blocks/voxel_library.tres" type="VoxelLibrary" id=1]
[ext_resource path="res://blocky_game/blocks/terrain_material.tres" type="Material" id=2]
[ext_resource path="res://blocky_game/blocks/terrain_material_transparent.tres" type="Material" id=3]
[ext_resource path="res://blocky_game/voxel_generator_noise_2d_blocky.tres" type="VoxelGeneratorNoise2D" id=4]
[ext_resource path="res://blocky_game/blocky_game.gd" type="Script" id=5]
[ext_resource path="res://blocky_game/player/character_avatar.tscn" type="PackedScene" id=6]
[ext_resource path="res://blocky_game/blocks/stairs/stairs_nx.obj" type="ArrayMesh" id=7]
[ext_resource path="res://blocky_terrain/debug_info.gd" type="Script" id=8]
[ext_resource path="res://blocky_game/blocks/terrain_material_foliage.tres" type="Material" id=9]
[sub_resource type="ProceduralSky" id=1]
sky_top_color = Color( 0.268204, 0.522478, 0.847656, 1 )
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
sky_curve = 0.25
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
ground_curve = 0.01
sun_curve = 0.0176777
sun_energy = 16.0
[sub_resource type="Environment" id=2]
background_mode = 2
background_sky = SubResource( 1 )
ambient_light_color = Color( 0.0546875, 0.0546875, 0.0546875, 1 )
ambient_light_sky_contribution = 0.7
fog_enabled = true
fog_color = Color( 0.552734, 0.818359, 0.908691, 1 )
fog_depth_begin = 50.0
fog_depth_end = 300.0
fog_height_min = -100.0
fog_height_max = -50.0
fog_height_curve = 0.965937
ssao_blur = 1
dof_blur_far_distance = 128.0
dof_blur_far_transition = 10.0
glow_hdr_threshold = 0.5
[sub_resource type="VoxelStreamRegionFiles" id=3]
fallback_stream = ExtResource( 4 )
save_fallback_output = false
directory = "res://blocky_game/save"
[node name="Main" type="Node"]
script = ExtResource( 5 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 2 )
[node name="VoxelTerrain" type="VoxelTerrain" parent="."]
stream = SubResource( 3 )
voxel_library = ExtResource( 1 )
viewer_path = NodePath("../CharacterAvatar")
material/0 = ExtResource( 2 )
material/1 = ExtResource( 3 )
material/2 = ExtResource( 9 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( -0.97321, 0.172326, -0.152203, -0.0478236, 0.495785, 0.867127, 0.224888, 0.851176, -0.474262, 1.51966, 19.7004, 14.0879 )
directional_shadow_normal_bias = 0.1
[node name="DebugInfo" type="Node" parent="."]
script = ExtResource( 8 )
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 7.3175 )
mesh = ExtResource( 7 )
material/0 = null
[node name="CharacterAvatar" parent="." instance=ExtResource( 6 )]
speed = 6.0
gravity = 40.0
jump_force = 8.0
head = NodePath("../CharacterAvatar/Camera")
terrain = NodePath("../VoxelTerrain")

View File

@ -0,0 +1,27 @@
extends Node
onready var _terrain = get_parent().get_node("VoxelTerrain")
func _process(delta):
var dm = OS.get_dynamic_memory_usage()
var sm = OS.get_static_memory_usage()
var stats = _terrain.get_statistics()
DDD.set_text("Dynamic memory", _format_memory(dm))
DDD.set_text("Static memory", _format_memory(sm))
for i in len(stats.stream.remaining_blocks_per_thread):
DDD.set_text(str("Stream[", i, "]"), stats.stream.remaining_blocks_per_thread[i])
for i in len(stats.updater.remaining_blocks_per_thread):
DDD.set_text(str("Updater[", i, "]"), stats.updater.remaining_blocks_per_thread[i])
DDD.set_text("Main thread block updates", stats.remaining_main_thread_blocks)
static func _format_memory(m):
var mb = m / 1000000
var mbr = m % 1000000
return str(mb, ".", mbr, " Mb")

View File

@ -0,0 +1,50 @@
extends Node
const Blocks = preload("../blocks/blocks.gd")
const BlocksAtlasTexture = preload("../blocks/terrain.png")
onready var _viewport : Viewport = $Viewport
onready var _mesh_instance : MeshInstance = $Viewport/MeshInstance
var _current_block_id := -1
var _blocks := Blocks.new()
func _process(_delta):
print("Block ", _current_block_id)
if _current_block_id != -1:
var block : Blocks.Block = _blocks.get_block(_current_block_id)
if block.directory != "":
# Grab result of previous render
var viewport_texture := _viewport.get_texture()
var im := viewport_texture.get_data()
im.convert(Image.FORMAT_RGBA8)
var fpath := \
str(Blocks.ROOT, "/", block.directory, "/", block.name, "_sprite.png")
var err = im.save_png(fpath)
if err != OK:
push_error(str("Could not save ", fpath, ", error ", err))
else:
print("Saved ", fpath)
_current_block_id += 1
if _current_block_id < _blocks.get_block_count():
# Setup next block for rendering
var block = _blocks.get_block(_current_block_id)
if block.directory != "":
var gui_mesh = load(block.gui_model_path)
_mesh_instance.mesh = gui_mesh
var mat = SpatialMaterial.new()
mat.albedo_texture = BlocksAtlasTexture
_mesh_instance.material_override = mat
if block.transparent:
mat.params_use_alpha_scissor = true
if not block.backface_culling:
mat.params_cull_mode = SpatialMaterial.CULL_DISABLED
else:
set_process(false)
print("Done!")

View File

@ -0,0 +1,30 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://blocky_game/gui/block_sprite_generator.gd" type="Script" id=1]
[node name="Node" type="Node"]
script = ExtResource( 1 )
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 128, 128 )
transparent_bg = true
render_target_v_flip = true
render_target_update_mode = 3
[node name="Camera" type="Camera" parent="Viewport"]
transform = Transform( -0.467119, 0.447433, -0.76263, 0, 0.862514, 0.506034, 0.884195, 0.236378, -0.402896, -0.530722, 1.19951, -0.0522263 )
projection = 1
current = true
size = 1.62453
[node name="MeshInstance" type="MeshInstance" parent="Viewport"]
[node name="CSGBox" type="CSGBox" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0.5, 0.5 )
visible = false
width = 1.0
height = 1.0
depth = 1.0
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.90295, -0.173518, -0.393157, 0.424509, 0.502534, 0.753162, 0.0668873, -0.846966, 0.527423, 3.45617, 1.75451, 0 )

View File

@ -0,0 +1,8 @@
extends Sprite
# TODO Get rid if this once viewport modes get fixed!
func _process(delta):
var rect = get_viewport().get_visible_rect()
position = rect.size/2.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/crosshair.png-23d846f52541fa603810178ccd7b4803.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/gui/crosshair.png"
dest_files=[ "res://.import/crosshair.png-23d846f52541fa603810178ccd7b4803.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=false
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,37 @@
extends CenterContainer
const Blocks = preload("../blocks/blocks.tres")
onready var _selected_frame = $HBoxContainer/HotbarSlot/HotbarSlotSelect
onready var _slot_container = $HBoxContainer
var _inventory = [1, 2, 3, 4, 5, 6, -1, -1, -1]
var _inventory_index = 0
func _ready():
assert(len(_inventory) == _slot_container.get_child_count())
for i in len(_inventory):
var block_id = _inventory[i]
var slot = _slot_container.get_child(i)
slot.set_block_id(block_id)
func select_slot(i: int):
if _inventory_index == i:
return
_inventory_index = i
var block_id = _inventory[_inventory_index]
if block_id != -1:
var block = Blocks.get_block(block_id)
print("Inventory select ", block.name)
_selected_frame.get_parent().remove_child(_selected_frame)
var slot = _slot_container.get_child(i)
slot.add_child(_selected_frame)
func get_selected_block_type() -> int:
return _inventory[_inventory_index]

View File

@ -0,0 +1,61 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://blocky_game/gui/hotbar_slot.tscn" type="PackedScene" id=1]
[ext_resource path="res://blocky_game/gui/hotbar.gd" type="Script" id=2]
[ext_resource path="res://blocky_game/gui/hotbar_slot_select.tscn" type="PackedScene" id=3]
[node name="HotBar" type="CenterContainer"]
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -97.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_left = 208.0
margin_top = 16.0
margin_right = 816.0
margin_bottom = 80.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HotbarSlot" parent="HBoxContainer" instance=ExtResource( 1 )]
[node name="HotbarSlotSelect" parent="HBoxContainer/HotbarSlot" instance=ExtResource( 3 )]
show_behind_parent = true
[node name="HotbarSlot2" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 68.0
margin_right = 132.0
[node name="HotbarSlot3" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 136.0
margin_right = 200.0
[node name="HotbarSlot4" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 204.0
margin_right = 268.0
[node name="HotbarSlot5" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 272.0
margin_right = 336.0
[node name="HotbarSlot6" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 340.0
margin_right = 404.0
[node name="HotbarSlot7" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 408.0
margin_right = 472.0
[node name="HotbarSlot8" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 476.0
margin_right = 540.0
[node name="HotbarSlot9" parent="HBoxContainer" instance=ExtResource( 1 )]
margin_left = 544.0
margin_right = 608.0

View File

@ -0,0 +1,15 @@
extends Control
const Blocks = preload("../blocks/blocks.tres")
onready var _texture_rect = $TextureRect
func set_block_id(id: int):
if id == -1:
_texture_rect.texture = null
else:
var block = Blocks.get_block(id)
_texture_rect.texture = block.sprite_texture

View File

@ -0,0 +1,38 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://blocky_game/blocks/dirt/dirt_sprite.png" type="Texture" id=1]
[ext_resource path="res://blocky_game/gui/hotbar_slot.gd" type="Script" id=2]
[ext_resource path="res://blocky_game/gui/hotbar_slot_bg.png" type="Texture" id=3]
[node name="HotbarSlot" type="Control"]
margin_right = 64.0
margin_bottom = 64.0
rect_min_size = Vector2( 64, 64 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="BG" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
texture = ExtResource( 3 )
expand = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 4.0
margin_right = -4.0
margin_bottom = -4.0
texture = ExtResource( 1 )
expand = true
stretch_mode = 1
__meta__ = {
"_edit_use_anchors_": false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/hotbar_slot_bg.png-eb24d44793c7da8542043740acc9ea2f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/gui/hotbar_slot_bg.png"
dest_files=[ "res://.import/hotbar_slot_bg.png-eb24d44793c7da8542043740acc9ea2f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/hotbar_slot_select.png-d1839f7ebeb26f284be4e0064b0730af.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://blocky_game/gui/hotbar_slot_select.png"
dest_files=[ "res://.import/hotbar_slot_select.png-d1839f7ebeb26f284be4e0064b0730af.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,26 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://blocky_game/gui/hotbar_slot_select.png" type="Texture" id=1]
[node name="HotbarSlotSelect" type="TextureRect"]
margin_right = 64.0
margin_bottom = 64.0
rect_min_size = Vector2( 64, 64 )
texture = ExtResource( 1 )
expand = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Shadow" type="TextureRect" parent="."]
modulate = Color( 0.12549, 0.12549, 0.12549, 1 )
show_behind_parent = true
margin_left = 2.0
margin_top = 2.0
margin_right = 66.0
margin_bottom = 66.0
texture = ExtResource( 1 )
expand = true
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -0,0 +1,138 @@
extends Node
const Util = preload("res://common/util.gd")
const Blocks = preload("../blocks/blocks.tres")
const COLLISION_LAYER_AVATAR = 2
const _hotbar_keys = {
KEY_1: 0,
KEY_2: 1,
KEY_3: 2,
KEY_4: 3,
KEY_5: 4,
KEY_6: 5,
KEY_7: 6,
KEY_8: 7,
KEY_9: 8
}
export(NodePath) var terrain_path = null
export(Material) var cursor_material = null
# TODO Eventually invert these dependencies
onready var _head = get_parent().get_node("Camera")
onready var _hotbar = get_node("../HotBar")
var _terrain = null
var _terrain_tool = null
var _cursor = null
var _action_place = false
var _action_remove = false
func _ready():
if terrain_path == null:
_terrain = get_parent().get_node(get_parent().terrain)
terrain_path = _terrain.get_path() # For correctness
else:
_terrain = get_node(terrain_path)
var mesh = Util.create_wirecube_mesh(Color(0,0,0))
var mesh_instance = MeshInstance.new()
mesh_instance.mesh = mesh
if cursor_material != null:
mesh_instance.material_override = cursor_material
mesh_instance.set_scale(Vector3(1,1,1)*1.01)
_cursor = mesh_instance
_terrain.add_child(_cursor)
_terrain_tool = _terrain.get_voxel_tool()
func get_pointed_voxel():
var origin = _head.get_global_transform().origin
var forward = -_head.get_transform().basis.z.normalized()
var hit = _terrain_tool.raycast(origin, forward, 10)
return hit
func _physics_process(delta):
if _terrain == null:
return
var hit = get_pointed_voxel()
if hit != null:
_cursor.show()
_cursor.set_translation(hit.position)
DDD.set_text("Pointed voxel", str(hit.position))
else:
_cursor.hide()
DDD.set_text("Pointed voxel", "---")
# These inputs have to be in _fixed_process because they rely on collision queries
if hit != null:
var has_cube = _terrain_tool.get_voxel(hit.position) != 0
if _action_remove and has_cube:
var pos = hit.position
_place_single_block(pos, 0)
elif _action_place:
var pos = hit.previous_position
if has_cube == false:
pos = hit.position
if can_place_voxel_at(pos):
var block_id = _hotbar.get_selected_block_type()
if block_id != -1:
_place_single_block(pos, block_id)
print("Place voxel at ", pos)
else:
print("Can't place here!")
_action_place = false
_action_remove = false
func _unhandled_input(event):
if event is InputEventMouseButton:
if event.pressed:
match event.button_index:
BUTTON_LEFT:
_action_remove = true
BUTTON_RIGHT:
_action_place = true
elif event is InputEventKey:
if event.pressed:
if _hotbar_keys.has(event.scancode):
var slot_index = _hotbar_keys[event.scancode]
_hotbar.select_slot(slot_index)
func can_place_voxel_at(pos: Vector3):
var space_state = get_viewport().get_world().get_direct_space_state()
var params = PhysicsShapeQueryParameters.new()
params.collision_mask = COLLISION_LAYER_AVATAR
params.transform = Transform(Basis(), pos + Vector3(1,1,1)*0.5)
var shape = BoxShape.new()
var ex = 0.5
shape.extents = Vector3(ex, ex, ex)
params.set_shape(shape)
var hits = space_state.intersect_shape(params)
return hits.size() == 0
func _place_single_block(pos: Vector3, block_id: int):
var block = Blocks.get_block(block_id)
var voxel_id = block.voxels[0]
# TODO Handle rotated variants etc
_place_single_voxel(pos, voxel_id)
func _place_single_voxel(pos, type):
_terrain_tool.channel = VoxelBuffer.CHANNEL_TYPE
_terrain_tool.value = type
_terrain_tool.do_point(pos)

View File

@ -0,0 +1,64 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://blocky_game/player/character_controller.gd" type="Script" id=1]
[ext_resource path="res://common/mouse_look.gd" type="Script" id=2]
[ext_resource path="res://blocky_game/player/avatar_interaction.gd" type="Script" id=3]
[ext_resource path="res://blocky_terrain/crosshair.png" type="Texture" id=4]
[ext_resource path="res://blocky_terrain/center.gd" type="Script" id=5]
[ext_resource path="res://blocky_game/gui/hotbar.tscn" type="PackedScene" id=6]
[sub_resource type="CubeMesh" id=2]
size = Vector3( 0.8, 1.8, 0.8 )
[node name="CharacterAvatar" type="Spatial"]
script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.702764, 0 )
current = true
fov = 90.0
near = 0.1
far = 500.0
script = ExtResource( 2 )
sensitivity = 0.3
distance = 4.0
[node name="Interaction" type="Node" parent="."]
script = ExtResource( 3 )
[node name="crosshair" type="Sprite" parent="."]
visible = false
position = Vector2( 510.693, 285.793 )
texture = ExtResource( 4 )
script = ExtResource( 5 )
[node name="OmniLight" type="OmniLight" parent="."]
visible = false
light_color = Color( 1, 1, 0.533333, 1 )
shadow_bias = 0.1
omni_range = 10.0
omni_attenuation = 2.54912
[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 2 )
material/0 = null
[node name="CenterContainer" type="CenterContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="CenterContainer"]
margin_left = 504.0
margin_top = 292.0
margin_right = 520.0
margin_bottom = 308.0
mouse_filter = 2
texture = ExtResource( 4 )
[node name="HotBar" parent="." instance=ExtResource( 6 )]

View File

@ -0,0 +1,60 @@
extends Spatial
export var speed = 5.0
export var gravity = 9.8
export var jump_force = 5.0
export(NodePath) var head = null
# Not used in this script, but might be useful for child nodes because
# this controller will most likely be on the root
export(NodePath) var terrain = null
var _velocity = Vector3()
var _grounded = false
var _head = null
var _box_mover = VoxelBoxMover.new()
func _ready():
_head = get_node(head)
func _physics_process(delta):
var forward = _head.get_transform().basis.z.normalized()
forward = Plane(Vector3(0, 1, 0), 0).project(forward)
var right = _head.get_transform().basis.x.normalized()
var motor = Vector3()
if Input.is_key_pressed(KEY_UP) or Input.is_key_pressed(KEY_Z) or Input.is_key_pressed(KEY_W):
motor -= forward
if Input.is_key_pressed(KEY_DOWN) or Input.is_key_pressed(KEY_S):
motor += forward
if Input.is_key_pressed(KEY_LEFT) or Input.is_key_pressed(KEY_Q) or Input.is_key_pressed(KEY_A):
motor -= right
if Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_D):
motor += right
motor = motor.normalized() * speed
_velocity.x = motor.x
_velocity.z = motor.z
_velocity.y -= gravity * delta
#if _grounded and Input.is_key_pressed(KEY_SPACE):
if Input.is_key_pressed(KEY_SPACE):
_velocity.y = jump_force
#_grounded = false
var motion = _velocity * delta
if has_node(terrain):
var aabb = AABB(Vector3(-0.4, -0.9, -0.4), Vector3(0.8, 1.8, 0.8))
var terrain_node = get_node(terrain)
motion = _box_mover.get_motion(get_translation(), motion, aabb, terrain_node)
global_translate(motion)
assert(delta > 0)
_velocity = motion / delta

View File

@ -0,0 +1,8 @@
[gd_resource type="VoxelGeneratorNoise2D" load_steps=2 format=2]
[sub_resource type="OpenSimplexNoise" id=1]
[resource]
channel = 0
height_range = 100.0
noise = SubResource( 1 )

View File

@ -61,7 +61,8 @@ static func calculate_normals(positions, indices) -> PoolVector3Array:
i += 3
# TODO does triangle area matter?
# If it does then we don't need to normalize in triangle calculation since it will account for its length
# If it does then we don't need to normalize in triangle calculation since
# it will account for its length
var n = get_triangle_normal(positions[i0], positions[i1], positions[i2])
out_normals[i0] += n

View File

@ -23,6 +23,11 @@ config/icon="res://icon.png"
DDD="*res://addons/zylann.debug_draw/debug_draw.gd"
[display]
window/stretch/mode="2d"
window/stretch/aspect="expand"
[physics]
3d/physics_engine="Bullet"