Slight shuffling of scene files, resources; export presets for macOS
built added.
This commit is contained in:
parent
8175e1469d
commit
a0e8e394a9
63 changed files with 354 additions and 1087 deletions
|
|
@ -1,11 +1,16 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
var enemy = preload("res://scenes/enemy.tscn")
|
||||
var score = 0
|
||||
var playing = false
|
||||
|
||||
@onready var start_button = $CanvasLayer/CenterContainer/Start
|
||||
@onready var game_over = $CanvasLayer/CenterContainer/GameOver
|
||||
|
||||
func _ready():
|
||||
spawn_enemies()
|
||||
start_button.show()
|
||||
game_over.hide()
|
||||
# spawn_enemies()
|
||||
|
||||
func spawn_enemies():
|
||||
for x in range(9):
|
||||
|
|
@ -19,3 +24,22 @@ func spawn_enemies():
|
|||
func _on_enemy_died(value):
|
||||
score += value
|
||||
$CanvasLayer/UI.update_score(score)
|
||||
|
||||
|
||||
func _on_player_died():
|
||||
get_tree().call_group("enemies", "queue_free")
|
||||
game_over.show()
|
||||
await get_tree().create_timer(2).timeout
|
||||
game_over.hide()
|
||||
start_button.show()
|
||||
|
||||
func new_game():
|
||||
score = 0
|
||||
$CanvasLayer/UI.update_score(score)
|
||||
$Player.start()
|
||||
spawn_enemies()
|
||||
playing = true
|
||||
|
||||
func _on_start_pressed():
|
||||
start_button.hide()
|
||||
new_game()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://ce5rw02b3373d"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://ce5rw02b3373d"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b2tub370i3s3v" path="res://scenes/main.gd" id="1_jyhfs"]
|
||||
[ext_resource type="Texture2D" uid="uid://jj8b7vqj3ihx" path="res://resources/Mini Pixel Pack 3/Space_BG (2 frames) (64 x 64).png" id="2_tbgi4"]
|
||||
[ext_resource type="PackedScene" uid="uid://bkuucjejc7p2v" path="res://scenes/player.tscn" id="3_tefeu"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4vq2ytntfvoj" path="res://scenes/enemy.tscn" id="4_o6xl0"]
|
||||
[ext_resource type="PackedScene" uid="uid://k0yw686ys6ug" path="res://scenes/ui.tscn" id="5_tbgi4"]
|
||||
[ext_resource type="Script" uid="uid://b2tub370i3s3v" path="res://scenes/main.gd" id="1_e1tai"]
|
||||
[ext_resource type="Texture2D" uid="uid://jj8b7vqj3ihx" path="res://resources/Mini Pixel Pack 3/Space_BG (2 frames) (64 x 64).png" id="2_4s157"]
|
||||
[ext_resource type="PackedScene" uid="uid://bkuucjejc7p2v" path="res://scenes/player.tscn" id="3_yoeq8"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4vq2ytntfvoj" path="res://scenes/enemy.tscn" id="4_cvw54"]
|
||||
[ext_resource type="PackedScene" uid="uid://k0yw686ys6ug" path="res://scenes/ui.tscn" id="5_4s3oi"]
|
||||
[ext_resource type="Texture2D" uid="uid://bonoqs5pisflo" path="res://resources/Mini Pixel Pack 3/UI objects/START (48 x 8).png" id="6_bsja2"]
|
||||
[ext_resource type="Texture2D" uid="uid://bubqwoum50gf8" path="res://resources/Mini Pixel Pack 3/UI objects/GAME_OVER (72 x 8).png" id="7_4s157"]
|
||||
[ext_resource type="Script" uid="uid://c0c3rj5bcpif0" path="res://scenes/start.gd" id="7_tipki"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_vcsgt"]
|
||||
length = 0.001
|
||||
|
|
@ -45,16 +48,16 @@ _data = {
|
|||
}
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource("1_jyhfs")
|
||||
script = ExtResource("1_e1tai")
|
||||
|
||||
[node name="Background" type="Sprite2D" parent="."]
|
||||
texture_repeat = 2
|
||||
texture = ExtResource("2_tbgi4")
|
||||
texture = ExtResource("2_4s157")
|
||||
centered = false
|
||||
region_enabled = true
|
||||
region_rect = Rect2(0, 0, 240, 320)
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("3_tefeu")]
|
||||
[node name="Player" parent="." instance=ExtResource("3_yoeq8")]
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
|
|
@ -62,12 +65,30 @@ libraries = {
|
|||
}
|
||||
autoplay = "scroll"
|
||||
|
||||
[node name="Enemy" parent="." instance=ExtResource("4_o6xl0")]
|
||||
[node name="Enemy" parent="." instance=ExtResource("4_cvw54")]
|
||||
position = Vector2(-13, 3)
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="UI" parent="CanvasLayer" instance=ExtResource("5_tbgi4")]
|
||||
[node name="UI" parent="CanvasLayer" instance=ExtResource("5_4s3oi")]
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Start" type="TextureButton" parent="CanvasLayer/CenterContainer"]
|
||||
layout_mode = 2
|
||||
texture_normal = ExtResource("6_bsja2")
|
||||
script = ExtResource("7_tipki")
|
||||
|
||||
[node name="GameOver" type="TextureRect" parent="CanvasLayer/CenterContainer"]
|
||||
layout_mode = 2
|
||||
texture = ExtResource("7_4s157")
|
||||
|
||||
[connection signal="area_entered" from="Player" to="Player" method="_on_area_entered"]
|
||||
[connection signal="died" from="Player" to="." method="_on_player_died"]
|
||||
[connection signal="shield_changed" from="Player" to="CanvasLayer/UI" method="update_shield"]
|
||||
[connection signal="pressed" from="CanvasLayer/CenterContainer/Start" to="." method="_on_start_pressed"]
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ extends Area2D
|
|||
signal died
|
||||
signal shield_changed
|
||||
|
||||
@export var speed = 150
|
||||
@export var cooldown = 0.25
|
||||
@export var bullet_scene : PackedScene
|
||||
@export var max_shield = 10
|
||||
var shield = max_shield:
|
||||
set = set_shield
|
||||
|
||||
@export var speed = 150
|
||||
@export var cooldown = 0.25
|
||||
@export var bullet_scene : PackedScene
|
||||
var can_shoot = true
|
||||
|
||||
@onready var screensize = get_viewport_rect().size
|
||||
|
|
@ -18,33 +18,11 @@ func _ready():
|
|||
start()
|
||||
|
||||
func start():
|
||||
show()
|
||||
position = Vector2(screensize.x / 2, screensize.y - 64)
|
||||
shield = max_shield
|
||||
$GunCooldown.wait_time = cooldown
|
||||
|
||||
func shoot():
|
||||
if not can_shoot:
|
||||
return
|
||||
can_shoot = false
|
||||
$GunCooldown.start()
|
||||
var b = bullet_scene.instantiate()
|
||||
get_tree().root.add_child(b)
|
||||
b.start(position + Vector2(0, -8))
|
||||
|
||||
func _on_gun_cooldown_timeout():
|
||||
can_shoot = true
|
||||
|
||||
func set_shield(value):
|
||||
shield = min(max_shield, value)
|
||||
shield_changed.emit(max_shield, shield)
|
||||
if shield <= 0:
|
||||
hide()
|
||||
died.emit()
|
||||
|
||||
func _on_area_entered(area):
|
||||
if area.is_in_group("enemies"):
|
||||
area.explode()
|
||||
shield -= max_shield / 2
|
||||
|
||||
func _process(delta):
|
||||
var input = Input.get_vector("left", "right", "up", "down")
|
||||
if input.x > 0:
|
||||
|
|
@ -61,3 +39,28 @@ func _process(delta):
|
|||
|
||||
if Input.is_action_pressed("shoot"):
|
||||
shoot()
|
||||
|
||||
func shoot():
|
||||
if not can_shoot:
|
||||
return
|
||||
can_shoot = false
|
||||
$GunCooldown.start()
|
||||
var b = bullet_scene.instantiate()
|
||||
get_tree().root.add_child(b)
|
||||
b.start(position + Vector2(0, -8))
|
||||
|
||||
func set_shield(value):
|
||||
shield = min(max_shield, value)
|
||||
shield_changed.emit(max_shield, shield)
|
||||
if shield <= 0:
|
||||
hide()
|
||||
died.emit()
|
||||
|
||||
func _on_gun_cooldown_timeout():
|
||||
can_shoot = true
|
||||
|
||||
|
||||
func _on_area_entered(area):
|
||||
if area.is_in_group("enemies"):
|
||||
area.explode()
|
||||
shield -= max_shield / 2
|
||||
|
|
|
|||
6
scenes/start.gd
Normal file
6
scenes/start.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
extends TextureButton
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is "shoot"
|
||||
_ready()
|
||||
pass
|
||||
1
scenes/start.gd.uid
Normal file
1
scenes/start.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c0c3rj5bcpif0
|
||||
|
|
@ -4,9 +4,9 @@ extends MarginContainer
|
|||
@onready var score_counter = $HBoxContainer/ScoreCounter
|
||||
|
||||
func update_score(value):
|
||||
score_counter.display_digits(value)
|
||||
score_counter.display_digits(value)
|
||||
|
||||
|
||||
func update_shield(max_value, value):
|
||||
shield_bar.max_value = max_value
|
||||
shield_bar.value = value
|
||||
shield_bar.max_value = max_value
|
||||
shield_bar.value = value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue