diff --git a/Project/Assets/icon.png b/Project/Assets/icon.png new file mode 100644 index 0000000..2b65815 Binary files /dev/null and b/Project/Assets/icon.png differ diff --git a/Project/Assets/icon.png.import b/Project/Assets/icon.png.import new file mode 100644 index 0000000..53047c0 --- /dev/null +++ b/Project/Assets/icon.png.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="StreamTexture" +path.s3tc="res://.import/icon.png-ec880de02d5dab0aa15458af9d6c53ed.s3tc.stex" +path.etc2="res://.import/icon.png-ec880de02d5dab0aa15458af9d6c53ed.etc2.stex" +metadata={ +"imported_formats": [ "s3tc", "etc2" ], +"vram_texture": true +} + +[deps] + +source_file="res://Assets/icon.png" +dest_files=[ "res://.import/icon.png-ec880de02d5dab0aa15458af9d6c53ed.s3tc.stex", "res://.import/icon.png-ec880de02d5dab0aa15458af9d6c53ed.etc2.stex" ] + +[params] + +compress/mode=2 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=true +flags/filter=true +flags/mipmaps=true +flags/anisotropic=false +flags/srgb=1 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/Project/Game3D/Game3D.gd b/Project/Game3D/Game3D.gd index 53ecc18..34b7892 100644 --- a/Project/Game3D/Game3D.gd +++ b/Project/Game3D/Game3D.gd @@ -3,6 +3,21 @@ extends Spatial var score: int = 0 var is_game_over: bool = false +onready var CAMERA: Camera = $Camera +onready var CAMERA_TARGET: Position3D = $"Player/Camera Target" +onready var PLAYER: Player = $Player + +func _ready(): + CAMERA.look_at(CAMERA_TARGET.global_transform.origin, Vector3.UP) + CAMERA.translation = CAMERA.translation.rotated(Vector3.UP, deg2rad(-45)) + +func _process(delta: float) -> void: + if get_tree().paused: return; + + var camera_position = CAMERA_TARGET.global_transform.origin - PLAYER.direction * 10 + CAMERA.translation = camera_position + CAMERA.look_at(CAMERA_TARGET.global_transform.origin, Vector3.UP) + func _input(event: InputEvent) -> void: if event.is_action_pressed("ui_cancel"): if is_game_over: diff --git a/Project/Game3D/Game3D.tscn b/Project/Game3D/Game3D.tscn index b028aa5..cb9d3b1 100644 --- a/Project/Game3D/Game3D.tscn +++ b/Project/Game3D/Game3D.tscn @@ -1,8 +1,17 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://Game3D/Player/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://UI/Pause.tscn" type="PackedScene" id=2] [ext_resource path="res://Game3D/Game3D.gd" type="Script" id=3] +[ext_resource path="res://Assets/icon.png" type="Texture" id=4] + +[sub_resource type="SpatialMaterial" id=10] +albedo_texture = ExtResource( 4 ) +uv1_scale = Vector3( 25, 25, 1 ) + +[sub_resource type="PlaneMesh" id=11] +material = SubResource( 10 ) +size = Vector2( 60, 60 ) [sub_resource type="CubeMesh" id=1] size = Vector3( 2, 2, 50 ) @@ -21,13 +30,13 @@ albedo_color = Color( 0, 1, 0.243137, 1 ) [sub_resource type="CubeMesh" id=3] material = SubResource( 7 ) -size = Vector3( 100, 2, 2 ) +size = Vector3( 104, 2, 2 ) [sub_resource type="ConcavePolygonShape" id=4] data = PoolVector3Array( -50, 1, 1, 50, 1, 1, -50, -1, 1, 50, 1, 1, 50, -1, 1, -50, -1, 1, 50, 1, -1, -50, 1, -1, 50, -1, -1, -50, 1, -1, -50, -1, -1, 50, -1, -1, 50, 1, 1, 50, 1, -1, 50, -1, 1, 50, 1, -1, 50, -1, -1, 50, -1, 1, -50, 1, -1, -50, 1, 1, -50, -1, -1, -50, 1, 1, -50, -1, 1, -50, -1, -1, 50, 1, 1, -50, 1, 1, 50, 1, -1, -50, 1, 1, -50, 1, -1, 50, 1, -1, -50, -1, 1, 50, -1, 1, -50, -1, -1, 50, -1, 1, 50, -1, -1, -50, -1, -1 ) [sub_resource type="CubeMesh" id=8] -size = Vector3( 100, 2, 2 ) +size = Vector3( 104, 2, 2 ) [sub_resource type="ConcavePolygonShape" id=9] data = PoolVector3Array( -50, 1, 1, 50, 1, 1, -50, -1, 1, 50, 1, 1, 50, -1, 1, -50, -1, 1, 50, 1, -1, -50, 1, -1, 50, -1, -1, -50, 1, -1, -50, -1, -1, 50, -1, -1, 50, 1, 1, 50, 1, -1, 50, -1, 1, 50, 1, -1, 50, -1, -1, 50, -1, 1, -50, 1, -1, -50, 1, 1, -50, -1, -1, -50, 1, 1, -50, -1, 1, -50, -1, -1, 50, 1, 1, -50, 1, 1, 50, 1, -1, -50, 1, 1, -50, 1, -1, 50, 1, -1, -50, -1, 1, 50, -1, 1, -50, -1, -1, 50, -1, 1, 50, -1, -1, -50, -1, -1 ) @@ -47,10 +56,13 @@ far = 150.0 [node name="Camera Target" type="Position3D" parent="Player"] transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 6.5, 7 ) +[node name="Floor" type="MeshInstance" parent="."] +mesh = SubResource( 11 ) + [node name="Walls" type="Spatial" parent="."] [node name="Left" type="Area" parent="Walls"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -50, 0, 0 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -25, 0, 0 ) [node name="MeshInstance" type="MeshInstance" parent="Walls/Left"] mesh = SubResource( 1 ) @@ -60,7 +72,7 @@ material/0 = SubResource( 5 ) shape = SubResource( 2 ) [node name="Right" type="Area" parent="Walls"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 50, 0, 0 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 25, 0, 0 ) [node name="MeshInstance" type="MeshInstance" parent="Walls/Right"] mesh = SubResource( 1 ) @@ -70,7 +82,7 @@ material/0 = SubResource( 6 ) shape = SubResource( 2 ) [node name="Top" type="Area" parent="Walls"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -25 ) +transform = Transform( 0.5, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -25 ) [node name="MeshInstance" type="MeshInstance" parent="Walls/Top"] mesh = SubResource( 3 ) @@ -78,11 +90,11 @@ mesh = SubResource( 3 ) [node name="CollisionShape" type="CollisionShape" parent="Walls/Top"] shape = SubResource( 4 ) -[node name="Area" type="Area" parent="Walls"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 25 ) +[node name="Down" type="Area" parent="Walls"] +transform = Transform( 0.5, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 25 ) -[node name="MeshInstance" type="MeshInstance" parent="Walls/Area"] +[node name="MeshInstance" type="MeshInstance" parent="Walls/Down"] mesh = SubResource( 8 ) -[node name="CollisionShape" type="CollisionShape" parent="Walls/Area"] +[node name="CollisionShape" type="CollisionShape" parent="Walls/Down"] shape = SubResource( 9 ) diff --git a/Project/Game3D/Player/Player.gd b/Project/Game3D/Player/Player.gd index c90619f..f96f94d 100644 --- a/Project/Game3D/Player/Player.gd +++ b/Project/Game3D/Player/Player.gd @@ -1,5 +1,7 @@ extends Area +class_name Player + signal food_eated signal dead @@ -8,23 +10,14 @@ export (float, 0.05, 1) var normal_speed: float = 0.1 var direction: Vector3 = Vector3(0, 0, -1) var speed: float = normal_speed -onready var CAMERA: Camera = get_parent().get_node("Camera") -onready var CAMERA_TARGET: Position3D = get_node("Camera Target") onready var MOVE_TIMER: Timer = $Move func _ready(): _set_speed(normal_speed) - CAMERA.look_at(CAMERA_TARGET.global_transform.origin, Vector3.UP) - CAMERA.translation = CAMERA.translation.rotated(Vector3.UP, deg2rad(-45)) - func _process(delta: float) -> void: if get_tree().paused: return; look_at(global_transform.origin + direction, Vector3.UP) - - var camera_position = CAMERA_TARGET.global_transform.origin - direction * 10 - CAMERA.translation = camera_position - CAMERA.look_at(CAMERA_TARGET.global_transform.origin, Vector3.UP) func _input(event): if event.is_action_pressed("left"): diff --git a/Project/project.godot b/Project/project.godot index 79f4ff1..0493e76 100644 --- a/Project/project.godot +++ b/Project/project.godot @@ -8,8 +8,14 @@ config_version=4 -_global_script_classes=[ ] +_global_script_classes=[ { +"base": "Area", +"class": "Player", +"language": "GDScript", +"path": "res://Game3D/Player/Player.gd" +} ] _global_script_class_icons={ +"Player": "" } [application]