Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
EclipsedMango committed Jun 21, 2024
1 parent 5d8121f commit 9ee79f4
Show file tree
Hide file tree
Showing 21 changed files with 432 additions and 74 deletions.
Binary file added Assets/Models/Rock1.glb
Binary file not shown.
47 changes: 47 additions & 0 deletions Assets/Models/Rock1.glb.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://ca4jop6a75ijt"
path="res://.godot/imported/Rock1.glb-51229319df652e1ff6363984e49111d9.scn"

[deps]

source_file="res://Assets/Models/Rock1.glb"
dest_files=["res://.godot/imported/Rock1.glb-51229319df652e1ff6363984e49111d9.scn"]

[params]

nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={
"meshes": {
"Rock1_Cube": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"lods/normal_split_angle": 25.0,
"save_to_file/enabled": true,
"save_to_file/make_streamable": "",
"save_to_file/path": "res://Assets/Models/Rock1.res"
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
Binary file added Assets/Models/Rock1.res
Binary file not shown.
Binary file added Assets/Models/Tree2FIXEDagain.glb
Binary file not shown.
34 changes: 34 additions & 0 deletions Assets/Models/Tree2FIXEDagain.glb.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://by5gdtlcl17vc"
path="res://.godot/imported/Tree2FIXEDagain.glb-8d6053b40e9f8b8faa5948df16f936c7.scn"

[deps]

source_file="res://Assets/Models/Tree2FIXEDagain.glb"
dest_files=["res://.godot/imported/Tree2FIXEDagain.glb-8d6053b40e9f8b8faa5948df16f936c7.scn"]

[params]

nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions Assets/Models/Tree2FIXEDagain_Leaves Texture - Imgur.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ur5eeqet51x3"
path="res://.godot/imported/Tree2FIXEDagain_Leaves Texture - Imgur.png-ff59857ee11a1604f2096dcd089c1bcc.ctex"
metadata={
"vram_texture": false
}
generator_parameters={
"md5": "d5f31c5134a62f3c31ca3f0e20254606"
}

[deps]

source_file="res://Assets/Models/Tree2FIXEDagain_Leaves Texture - Imgur.png"
dest_files=["res://.godot/imported/Tree2FIXEDagain_Leaves Texture - Imgur.png-ff59857ee11a1604f2096dcd089c1bcc.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
1 change: 1 addition & 0 deletions Credits.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="https://lovepik.com/images/png-texture.html">Texture Png vectors by Lovepik.com</a>
31 changes: 31 additions & 0 deletions Scenes/Rockspawner.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extends Node

const SPAWN_RANGE: float = 200.0

var rock_res: PackedScene = preload("res://Scenes/rock.tscn")
var height_map: Texture2D = preload("res://heightmap1.png")

func _ready() -> void:
randomize()

var image := height_map.get_image()

for i in range(600):
var rock: Node3D = rock_res.instantiate()
rock.position = Vector3(randf_range(-SPAWN_RANGE, SPAWN_RANGE), 0, randf_range(-SPAWN_RANGE, SPAWN_RANGE))

rock.rotation.y = randf() * TAU

var height = image.get_pixelv(image.get_size() / 2 + Vector2i(rock.position.x, rock.position.z)).r
rock.position.y = height * 5.0 - randf_range(0.5, 1.0)

var found_near: bool = false

for other in get_children():
if other.position.distance_to(rock.position) < 1.5:
rock.queue_free()
found_near = true
break

if !found_near:
add_child(rock)
16 changes: 10 additions & 6 deletions Scenes/main.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[gd_scene load_steps=11 format=3 uid="uid://dbkvn3mh5ff31"]
[gd_scene load_steps=12 format=3 uid="uid://dbkvn3mh5ff31"]

[ext_resource type="PackedScene" uid="uid://wygpiaun5mxw" path="res://Scenes/terrain_test.tscn" id="1_6r6n0"]
[ext_resource type="PackedScene" uid="uid://bbuymm13kjypt" path="res://Scenes/player.tscn" id="2_voc7m"]
[ext_resource type="PackedScene" uid="uid://brq1rqhw4t21k" path="res://Scenes/rock.tscn" id="4_6j0fb"]
[ext_resource type="Script" path="res://Scenes/Rockspawner.gd" id="4_ye4sx"]
[ext_resource type="Script" path="res://Scripts/FPS.gd" id="5_ro4ot"]

[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_qq1ji"]
Expand Down Expand Up @@ -41,10 +42,10 @@ volumetric_fog_sky_affect = 0.0

[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_ah7ol"]
dof_blur_far_enabled = true
dof_blur_far_distance = 15.0
dof_blur_far_distance = 50.0
dof_blur_far_transition = 50.0
dof_blur_near_distance = 2.15
dof_blur_amount = 0.02
dof_blur_amount = 0.03

[sub_resource type="BoxMesh" id="BoxMesh_2cujy"]

Expand Down Expand Up @@ -84,9 +85,6 @@ skeleton = NodePath("../../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Blocks/StaticBody3D2"]
shape = SubResource("BoxShape3D_s3gtb")

[node name="Rock" parent="Blocks" instance=ExtResource("4_6j0fb")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2.56269, 6.43175)

[node name="StaticBody3D3" type="StaticBody3D" parent="Blocks"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 3.39732, -0.662387)

Expand All @@ -106,3 +104,9 @@ skeleton = NodePath("../../..")

[node name="CollisionShape3D" type="CollisionShape3D" parent="Blocks/StaticBody3D4"]
shape = SubResource("BoxShape3D_s3gtb")

[node name="Rockspawner" type="Node3D" parent="Blocks"]
script = ExtResource("4_ye4sx")

[node name="Rock" parent="Blocks/Rockspawner" instance=ExtResource("4_6j0fb")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2.56269, 6.43175)
24 changes: 11 additions & 13 deletions Scenes/rock.tscn
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
[gd_scene load_steps=6 format=3 uid="uid://brq1rqhw4t21k"]
[gd_scene load_steps=5 format=3 uid="uid://brq1rqhw4t21k"]

[ext_resource type="Script" path="res://Scripts/Rock.gd" id="1_s6iwx"]
[ext_resource type="ArrayMesh" uid="uid://j78p2ctiwi7b" path="res://Assets/Models/Rock1.res" id="2_2onsw"]

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_h3j46"]
albedo_color = Color(0.47788, 0.47788, 0.47788, 1)

[sub_resource type="BoxMesh" id="BoxMesh_2cujy"]

[sub_resource type="BoxShape3D" id="BoxShape3D_s3gtb"]

[sub_resource type="BoxShape3D" id="BoxShape3D_51hc3"]
size = Vector3(1.05438, 1.01855, 1.08792)
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_d5pkx"]
points = PackedVector3Array(-0.124503, -1.46944, -0.0255355, 0.0176804, 0.238102, 1.55121, 0.0645334, 0.187035, 1.52766, 0.162018, 1.39218, -0.892484, -1.35413, -0.000949979, 0.210591, 1.34143, -0.662691, -0.308849, -0.545966, -0.188577, -1.29219, -0.0295933, 1.46734, 0.77919, -0.362688, -0.951795, 1.3049, 1.00704, 0.0459846, 0.917427, 0.966407, 0.900018, -0.594964, -1.06952, 0.991581, 0.210516, -1.31583, -0.762701, -0.0262956, 1.158, -1.18844, -0.168538, 0.301227, -0.898793, -0.970959, 0.630863, 0.753393, -1.01568, -0.637897, 1.02857, -0.726068, -0.0296861, 1.04503, 1.30503, -1.07556, -0.380918, -0.73915, 0.351002, -1.52333, 0.30643, 1.00756, -0.236631, 0.917844, -0.317088, 0.572997, -1.31913, 0.627731, 0.609142, 1.14888, -0.832774, 1.22724, 0.494078, -0.872862, -0.703694, 0.912695, -0.642035, -1.31997, 0.257261, 1.35857, -0.336028, -0.457994, 0.307154, 1.54081, -0.365314, 0.207178, 1.41942, 0.637121, 1.29298, -0.803656, 0.210444, 0.302305, -0.997034, -0.927125, -0.8736, -1.12618, -0.0241049)

[node name="Rock" type="StaticBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0.831861, 8.36222)
script = ExtResource("1_s6iwx")

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
material_override = SubResource("StandardMaterial3D_h3j46")
mesh = SubResource("BoxMesh_2cujy")
mesh = ExtResource("2_2onsw")
skeleton = NodePath("../../..")

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_s3gtb")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="."]
shape = SubResource("ConvexPolygonShape3D_d5pkx")

[node name="DamageZone" type="Area3D" parent="."]

[node name="CollisionShape3D" type="CollisionShape3D" parent="DamageZone"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00344801, 0.00927734, 0.00401402)
shape = SubResource("BoxShape3D_51hc3")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="DamageZone"]
transform = Transform3D(1.1, 0, 0, 0, 1.1, 0, 0, 0, 1.1, 0, 0, 0)
shape = SubResource("ConvexPolygonShape3D_d5pkx")
18 changes: 15 additions & 3 deletions Scenes/terrain_test.tscn

Large diffs are not rendered by default.

Binary file removed Scripts/EpicSurvivalGame.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion Scripts/Inventory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ class_name Inventory
extends RefCounted

const size: int = 48
var items: Array = []
var items: Array = [ItemStack.new(ItemStack.ItemType.Pickaxe)]

3 changes: 3 additions & 0 deletions Scripts/ItemStack.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ extends RefCounted
var type: ItemType
var amount: int = 1

func _init(t: ItemType) -> void:
type = t

enum ItemType {
Rock,
Wood,
Expand Down
6 changes: 3 additions & 3 deletions Scripts/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func _physics_process(delta) -> void:
var result: Dictionary = space_state.intersect_ray(query)

if result.has("collider") && result.collider.has_method("damage"):
result.collider.damage()
result.collider.damage(self, 1.0)

# Player Death.
if health <= 0:
Expand All @@ -127,11 +127,11 @@ func _input(event: InputEvent) -> void:
head.rotation.x = clampf(head.rotation.x - (event.relative.y * MOUSE_SENSITIVITY), -LOOK_LIMIT, LOOK_LIMIT)
velocity = velocity.rotated(Vector3.UP, -event.relative.x * MOUSE_SENSITIVITY)

func damage_player() -> void:
func damage_player(damager: Variant, damage_done: float) -> void:
if invulnerable:
return

health -= 1.0
health -= damage_done
invulnerable = true

get_tree().create_timer(INVULNERABLE_TIMER).timeout.connect(func():
Expand Down
18 changes: 13 additions & 5 deletions Scripts/Rock.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,34 @@ extends StaticBody3D
@onready var damage_zone: Area3D = $DamageZone
@onready var mesh: MeshInstance3D = $MeshInstance3D

@onready var original_color: Color = mesh.material_override.albedo_color

const INVULNERABLE_TIMER: float = 0.15

var rock_health: float = 5.0
var basic_damage: float = 1.0
var invulnerable: bool = false

func _ready() -> void:
mesh.material_override = mesh.material_override.duplicate()

func _physics_process(delta):
for body in damage_zone.get_overlapping_bodies():
if body.has_method("damage_player"):
body.damage_player()
body.damage_player(self, 1.0)

func damage():
rock_health -= basic_damage
func damage(damager: Variant, damage_amount: float):
if invulnerable:
return

rock_health -= damage_amount
invulnerable = true
if rock_health <= 0.0:
queue_free()

mesh.material_override.albedo_color = Color.RED
mesh.material_override.albedo_color = Color.BROWN
get_tree().create_timer(INVULNERABLE_TIMER).timeout.connect(func():
invulnerable = false
mesh.material_override.albedo_color = Color.WHITE
mesh.material_override.albedo_color = original_color
)

Loading

0 comments on commit 9ee79f4

Please sign in to comment.