🎉 Start developing!

This commit is contained in:
LittleSheep 2024-02-16 18:10:00 +08:00
commit 23143ba9bf
14 changed files with 271 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

7
assets/player.svg Normal file
View File

@ -0,0 +1,7 @@
<svg version="1.2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4096 4096" width="1024" height="1024">
<title>Player</title>
<style>
.s0 { fill: #efefef }
</style>
<path id="形状 1" class="s0" d="m2048 4096c-1132.5 0-2048-915.5-2048-2048 0-1132.5 915.5-2048 2048-2048 1132.5 0 2048 915.5 2048 2048 0 1132.5-915.5 2048-2048 2048z"/>
</svg>

After

Width:  |  Height:  |  Size: 350 B

37
assets/player.svg.import Normal file
View File

@ -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

View File

@ -0,0 +1,7 @@
<svg version="1.2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="1024" height="1024">
<title>Tower</title>
<style>
.s0 { fill: none;stroke: #efefef;stroke-miterlimit:100;stroke-width: 64 }
</style>
<path id="Background" class="s0" d="m512 992c-265.4 0-480-214.6-480-480 0-265.4 214.6-480 480-480 265.4 0 480 214.6 480 480 0 265.4-214.6 480-480 480z"/>
</svg>

After

Width:  |  Height:  |  Size: 385 B

View File

@ -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

View File

@ -0,0 +1,7 @@
<svg version="1.2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="1024" height="1024">
<title>Tower</title>
<style>
.s0 { fill: none;stroke: #4750a3;stroke-miterlimit:100;stroke-width: 64 }
</style>
<path id="Background" class="s0" d="m512 992c-265.4 0-480-214.6-480-480 0-265.4 214.6-480 480-480 265.4 0 480 214.6 480 480 0 265.4-214.6 480-480 480z"/>
</svg>

After

Width:  |  Height:  |  Size: 385 B

View File

@ -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

51
project.godot Normal file
View File

@ -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)
]
}

10
scenes/main.tscn Normal file
View File

@ -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")]

View File

@ -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"]

17
scenes/objects/tower.tscn Normal file
View File

@ -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")

29
scripts/PlayerMovement.gd Normal file
View File

@ -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()

5
scripts/Tower.gd Normal file
View File

@ -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)