first commit

This commit is contained in:
DerTyp7
2023-09-19 15:17:39 +02:00
commit f8b11b590b
15 changed files with 442 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/

23
Bullet.gd Normal file
View File

@@ -0,0 +1,23 @@
extends RigidBody2D
var destroy_timer := Timer.new()
func _ready():
add_child(destroy_timer)
destroy_timer.wait_time = 5.0
destroy_timer.one_shot = true # Automatically stops after timing out
# Start the timer
destroy_timer.start()
# Connect the "timeout" signal
destroy_timer.connect("timeout", _on_destroy_timer_timeout)
# Set the wait time for the timer (5 seconds)
func _on_destroy_timer_timeout():
# This function will be called when the timer times out
queue_free() # Destroy the object

27
Bullet.tscn Normal file
View File

@@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=3 uid="uid://day7or3kp8x5u"]
[ext_resource type="Script" path="res://Bullet.gd" id="1_0l6ar"]
[ext_resource type="Texture2D" uid="uid://dafsi3dqavgnb" path="res://Untitled.png" id="1_cjg2r"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_suj8m"]
size = Vector2(4, 4)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lfity"]
size = Vector2(4, 4)
[node name="RigidBody2D" type="RigidBody2D"]
gravity_scale = 0.0
script = ExtResource("1_0l6ar")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_suj8m")
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(-2.38419e-07, -2.38419e-07)
scale = Vector2(0.4, 0.4)
texture = ExtResource("1_cjg2r")
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("RectangleShape2D_lfity")

91
Player.gd Normal file
View File

@@ -0,0 +1,91 @@
extends CharacterBody2D
var movespeed = 300;
var bullet_speed = 2000;
var bullet = preload("res://Bullet.tscn")
var shoot_timer := Timer.new()
var can_shoot := true
func _ready():
add_child(shoot_timer);
shoot_timer.wait_time = 0.3
shoot_timer.start()
shoot_timer.connect("timeout", _on_shoot_timer_timeout)
func _on_shoot_timer_timeout():
can_shoot = true
func _physics_process(delta):
look()
move()
if Input.is_action_pressed("shoot"):
shoot()
func shoot():
if can_shoot:
fire()
can_shoot = false
shoot_timer.start()
func look():
var look_direction = Vector2.ZERO
if Input.is_action_pressed("look_up"):
look_direction.y -= 1
if Input.is_action_pressed("look_down"):
look_direction.y += 1
if Input.is_action_pressed("look_left"):
look_direction.x -= 1
if Input.is_action_pressed("look_right"):
look_direction.x += 1
# Diagonal look
if Input.is_action_pressed("look_up") && Input.is_action_pressed("look_left"):
look_direction = Vector2(-1, -1).normalized()
if Input.is_action_pressed("look_up") && Input.is_action_pressed("look_right"):
look_direction = Vector2(1, -1).normalized()
if Input.is_action_pressed("look_down") && Input.is_action_pressed("look_left"):
look_direction = Vector2(-1, 1).normalized()
if Input.is_action_pressed("look_down") && Input.is_action_pressed("look_right"):
look_direction = Vector2(1, 1).normalized()
if look_direction != Vector2.ZERO:
look_direction = look_direction.normalized()
rotation = look_direction.angle()
func move():
velocity = Vector2.ZERO
if Input.is_action_pressed("walk_up"):
velocity.y -= 1
if Input.is_action_pressed("walk_down"):
velocity.y += 1
if Input.is_action_pressed("walk_left"):
velocity.x -= 1
if Input.is_action_pressed("walk_right"):
velocity.x += 1
velocity = velocity.normalized() * movespeed
move_and_slide()
func fire():
var bullet_instance = bullet.instantiate() # Create an instance of the bullet
var offset = Vector2(20, 0).rotated(rotation) # Adjust the offset as needed
bullet_instance.position = global_position + offset
bullet_instance.rotation_degrees = rotation_degrees
# Calculate the bullet direction based on the player's rotation
var bullet_direction = Vector2(bullet_speed, 0).rotated(rotation)
# Apply the impulse in the correct direction
bullet_instance.apply_impulse(bullet_direction, Vector2())
# Add the bullet to the scene
get_tree().get_root().call_deferred("add_child", bullet_instance)

16
Player.tscn Normal file
View File

@@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=3 uid="uid://dvppgl1s0b3mv"]
[ext_resource type="Texture2D" uid="uid://dafsi3dqavgnb" path="res://Untitled.png" id="1_1rt42"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dty8l"]
size = Vector2(10, 10)
[node name="Node2D" type="Node2D"]
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
texture = ExtResource("1_1rt42")
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
shape = SubResource("RectangleShape2D_dty8l")

BIN
Untitled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

34
Untitled.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dafsi3dqavgnb"
path="res://.godot/imported/Untitled.png-30da513a925d9064453decddf41ecbd4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Untitled.png"
dest_files=["res://.godot/imported/Untitled.png-30da513a925d9064453decddf41ecbd4.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

1
icon.svg Normal file
View File

@@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

37
icon.svg.import Normal file
View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://sjxc2jsooye"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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

35
mai97AF.tmp Normal file
View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=6 format=3 uid="uid://b0i261cp1ugkh"]
[ext_resource type="Script" path="res://Player.gd" id="1_6ke6x"]
[ext_resource type="Texture2D" uid="uid://dafsi3dqavgnb" path="res://Untitled.png" id="2_w1il1"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fs1q0"]
size = Vector2(10, 10)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tqqca"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_my1x2"]
size = Vector2(12, 12)
[node name="World" type="Node2D"]
[node name="Player" type="CharacterBody2D" parent="."]
script = ExtResource("1_6ke6x")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
shape = SubResource("RectangleShape2D_fs1q0")
[node name="Sprite2D" type="Sprite2D" parent="Player"]
texture = ExtResource("2_w1il1")
[node name="Sprite2D" type="Sprite2D" parent="Player/Sprite2D"]
material = SubResource("ShaderMaterial_tqqca")
position = Vector2(-4.00596, 0)
scale = Vector2(0.202, 0.2)
texture = ExtResource("2_w1il1")
offset = Vector2(45.275, 0)
[node name="Area2D" type="Area2D" parent="Player"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Area2D"]
shape = SubResource("RectangleShape2D_my1x2")

35
maiA829.tmp Normal file
View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=6 format=3 uid="uid://b0i261cp1ugkh"]
[ext_resource type="Script" path="res://Player.gd" id="1_6ke6x"]
[ext_resource type="Texture2D" uid="uid://dafsi3dqavgnb" path="res://Untitled.png" id="2_w1il1"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fs1q0"]
size = Vector2(10, 10)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tqqca"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_my1x2"]
size = Vector2(12, 12)
[node name="World" type="Node2D"]
[node name="Player" type="CharacterBody2D" parent="."]
script = ExtResource("1_6ke6x")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
shape = SubResource("RectangleShape2D_fs1q0")
[node name="Sprite2D" type="Sprite2D" parent="Player"]
texture = ExtResource("2_w1il1")
[node name="Sprite2D" type="Sprite2D" parent="Player/Sprite2D"]
material = SubResource("ShaderMaterial_tqqca")
position = Vector2(-4.00596, 0)
scale = Vector2(0.202, 0.2)
texture = ExtResource("2_w1il1")
offset = Vector2(45.275, 0)
[node name="Area2D" type="Area2D" parent="Player"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Area2D"]
shape = SubResource("RectangleShape2D_my1x2")

35
maiD9D6.tmp Normal file
View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=6 format=3 uid="uid://b0i261cp1ugkh"]
[ext_resource type="Script" path="res://Player.gd" id="1_6ke6x"]
[ext_resource type="Texture2D" uid="uid://dafsi3dqavgnb" path="res://Untitled.png" id="2_w1il1"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fs1q0"]
size = Vector2(10, 10)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tqqca"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_my1x2"]
size = Vector2(12, 12)
[node name="World" type="Node2D"]
[node name="Player" type="CharacterBody2D" parent="."]
script = ExtResource("1_6ke6x")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
shape = SubResource("RectangleShape2D_fs1q0")
[node name="Sprite2D" type="Sprite2D" parent="Player"]
texture = ExtResource("2_w1il1")
[node name="Sprite2D" type="Sprite2D" parent="Player/Sprite2D"]
material = SubResource("ShaderMaterial_tqqca")
position = Vector2(-4.00596, 0)
scale = Vector2(0.202, 0.2)
texture = ExtResource("2_w1il1")
offset = Vector2(45.275, 0)
[node name="Area2D" type="Area2D" parent="Player"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Area2D"]
shape = SubResource("RectangleShape2D_my1x2")

35
main.tscn Normal file
View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=6 format=3 uid="uid://b0i261cp1ugkh"]
[ext_resource type="Script" path="res://Player.gd" id="1_6ke6x"]
[ext_resource type="Texture2D" uid="uid://dafsi3dqavgnb" path="res://Untitled.png" id="2_w1il1"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_fs1q0"]
size = Vector2(10, 10)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tqqca"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_my1x2"]
size = Vector2(12, 12)
[node name="World" type="Node2D"]
[node name="Player" type="CharacterBody2D" parent="."]
script = ExtResource("1_6ke6x")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
shape = SubResource("RectangleShape2D_fs1q0")
[node name="Sprite2D" type="Sprite2D" parent="Player"]
texture = ExtResource("2_w1il1")
[node name="Sprite2D" type="Sprite2D" parent="Player/Sprite2D"]
material = SubResource("ShaderMaterial_tqqca")
position = Vector2(-4.00596, 0)
scale = Vector2(0.202, 0.2)
texture = ExtResource("2_w1il1")
offset = Vector2(45.275, 0)
[node name="Area2D" type="Area2D" parent="Player"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player/Area2D"]
shape = SubResource("RectangleShape2D_my1x2")

69
project.godot Normal file
View File

@@ -0,0 +1,69 @@
; 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="TopDownShooter"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.1", "Forward Plus")
config/icon="res://icon.svg"
[dotnet]
project/assembly_name="TopDownShooter"
[input]
walk_up={
"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":87,"key_label":0,"unicode":119,"echo":false,"script":null)
]
}
walk_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)
]
}
walk_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)
]
}
walk_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)
]
}
shoot={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(445, 14),"global_position":Vector2(449, 57),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":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":32,"key_label":0,"unicode":32,"echo":false,"script":null)
]
}
look_up={
"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":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
look_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":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
look_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":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
look_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":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}