commit 23143ba9bf53d553180ffa65e522d12c01fc7d53 Author: LittleSheep Date: Fri Feb 16 18:10:00 2024 +0800 :tada: Start developing! diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/assets/player.svg b/assets/player.svg new file mode 100644 index 0000000..a8d92d3 --- /dev/null +++ b/assets/player.svg @@ -0,0 +1,7 @@ + + Player + + + \ No newline at end of file diff --git a/assets/player.svg.import b/assets/player.svg.import new file mode 100644 index 0000000..2569633 --- /dev/null +++ b/assets/player.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b4daomndc1ag" +path="res://.godot/imported/player.svg-e72d10ccf9c1b331af0b406534563f6c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/player.svg" +dest_files=["res://.godot/imported/player.svg-e72d10ccf9c1b331af0b406534563f6c.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=false +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=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/tower_background.svg b/assets/tower_background.svg new file mode 100644 index 0000000..daa38f4 --- /dev/null +++ b/assets/tower_background.svg @@ -0,0 +1,7 @@ + + Tower + + + \ No newline at end of file diff --git a/assets/tower_background.svg.import b/assets/tower_background.svg.import new file mode 100644 index 0000000..cd31a82 --- /dev/null +++ b/assets/tower_background.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://jxub8lma4oud" +path="res://.godot/imported/tower_background.svg-e77d209753f33c422eeb2695c1195112.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/tower_background.svg" +dest_files=["res://.godot/imported/tower_background.svg-e77d209753f33c422eeb2695c1195112.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=false +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=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/tower_forceground.svg b/assets/tower_forceground.svg new file mode 100644 index 0000000..658458f --- /dev/null +++ b/assets/tower_forceground.svg @@ -0,0 +1,7 @@ + + Tower + + + \ No newline at end of file diff --git a/assets/tower_forceground.svg.import b/assets/tower_forceground.svg.import new file mode 100644 index 0000000..8a40759 --- /dev/null +++ b/assets/tower_forceground.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dq3gmuse32md2" +path="res://.godot/imported/tower_forceground.svg-9f6d44720ea623d40c26c9524e3dd5b1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/tower_forceground.svg" +dest_files=["res://.godot/imported/tower_forceground.svg-9f6d44720ea623d40c26c9524e3dd5b1.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=false +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=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..d6091c3 --- /dev/null +++ b/project.godot @@ -0,0 +1,51 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="CyberTower" +run/main_scene="res://scenes/main.tscn" +config/features=PackedStringArray("4.2", "Forward Plus") + +[display] + +window/stretch/mode="canvas_items" + +[input] + +move_up={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +move_down={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +move_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +move_right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +skill_dash={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) +] +} diff --git a/scenes/main.tscn b/scenes/main.tscn new file mode 100644 index 0000000..6901ac7 --- /dev/null +++ b/scenes/main.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://l4mybb2dw107"] + +[ext_resource type="PackedScene" uid="uid://cwkcf8h5rspoh" path="res://scenes/objects/player.tscn" id="1_nq1ke"] +[ext_resource type="PackedScene" uid="uid://cxlgt8h33u7os" path="res://scenes/objects/tower.tscn" id="2_betjv"] + +[node name="Main" type="Node2D"] + +[node name="Player" parent="." instance=ExtResource("1_nq1ke")] + +[node name="Tower" parent="." instance=ExtResource("2_betjv")] diff --git a/scenes/objects/player.tscn b/scenes/objects/player.tscn new file mode 100644 index 0000000..a27259d --- /dev/null +++ b/scenes/objects/player.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=4 format=3 uid="uid://cwkcf8h5rspoh"] + +[ext_resource type="Script" path="res://scripts/PlayerMovement.gd" id="1_e1gjl"] +[ext_resource type="Texture2D" uid="uid://b4daomndc1ag" path="res://assets/player.svg" id="2_3pad2"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_k56cq"] +radius = 52.0096 + +[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("dash_cooldown_timer")] +script = ExtResource("1_e1gjl") +dash_cooldown_timer = NodePath("DashCooldown") + +[node name="DashCooldown" type="Timer" parent="."] + +[node name="PlayerSprite" type="Sprite2D" parent="."] +position = Vector2(1.90735e-06, 1.78814e-06) +scale = Vector2(0.1, 0.1) +texture = ExtResource("2_3pad2") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_k56cq") + +[connection signal="timeout" from="DashCooldown" to="." method="_on_cooled_down"] diff --git a/scenes/objects/tower.tscn b/scenes/objects/tower.tscn new file mode 100644 index 0000000..1f5ae79 --- /dev/null +++ b/scenes/objects/tower.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=4 format=3 uid="uid://cxlgt8h33u7os"] + +[ext_resource type="Script" path="res://scripts/Tower.gd" id="1_58egr"] +[ext_resource type="Texture2D" uid="uid://jxub8lma4oud" path="res://assets/tower_background.svg" id="2_ynj1l"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_7mogk"] +radius = 129.139 + +[node name="Tower" type="Area2D"] +script = ExtResource("1_58egr") + +[node name="TowerSprite" type="Sprite2D" parent="."] +scale = Vector2(0.25, 0.25) +texture = ExtResource("2_ynj1l") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_7mogk") diff --git a/scripts/PlayerMovement.gd b/scripts/PlayerMovement.gd new file mode 100644 index 0000000..0a59507 --- /dev/null +++ b/scripts/PlayerMovement.gd @@ -0,0 +1,29 @@ +extends CharacterBody2D + +@export var speed = 1200 +@export var speed_multiplier = 20 +@export var friction = 0.9 + +@export var dash_cooldown_duration = 1.0 +@export var dash_cooldown_timer: Timer + +func deal_move(delta): + var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down") + velocity = velocity.move_toward(input_direction * speed, speed * delta) + velocity = velocity * friction + + var is_dash = Input.is_action_pressed("skill_dash") + if is_dash && dash_cooldown_timer.is_stopped(): + velocity *= speed_multiplier + dash_cooldown_timer.start(dash_cooldown_duration) + +func _on_cooled_down(): + dash_cooldown_timer.stop() + +func _ready(): + var screen_size = get_viewport_rect().size + position = Vector2(screen_size.x / 2, screen_size.y / 2) + +func _physics_process(delta): + deal_move(delta) + move_and_slide() diff --git a/scripts/Tower.gd b/scripts/Tower.gd new file mode 100644 index 0000000..d42fdac --- /dev/null +++ b/scripts/Tower.gd @@ -0,0 +1,5 @@ +extends Area2D + +func _ready(): + var screen_size = get_viewport_rect().size + position = Vector2(screen_size.x / 2, screen_size.y / 2)