various updates

This commit is contained in:
Tabby 2025-05-23 21:36:52 +10:00
parent 8d6da7bf7e
commit 43b52fcea9
17 changed files with 244 additions and 109 deletions

View file

@ -44,26 +44,29 @@ func _process(delta: float) -> void:
camera.rotation_degrees = rot_dir * (1-timer/time_limit) * 15
#TODO Surely theres a better way
if Input.is_action_just_pressed("bomb_0"):
enter_number(0)
elif Input.is_action_just_pressed("bomb_1"):
enter_number(1)
elif Input.is_action_just_pressed("bomb_2"):
enter_number(2)
elif Input.is_action_just_pressed("bomb_3"):
enter_number(3)
elif Input.is_action_just_pressed("bomb_4"):
enter_number(4)
elif Input.is_action_just_pressed("bomb_5"):
enter_number(5)
elif Input.is_action_just_pressed("bomb_6"):
enter_number(6)
elif Input.is_action_just_pressed("bomb_7"):
enter_number(7)
elif Input.is_action_just_pressed("bomb_8"):
enter_number(8)
elif Input.is_action_just_pressed("bomb_9"):
enter_number(9)
for i : int in range(10):
if Input.is_action_just_pressed("bomb_" + str(i)):
enter_number(i)
#if Input.is_action_just_pressed("bomb_0"):
#enter_number(0)
#elif Input.is_action_just_pressed("bomb_1"):
#enter_number(1)
#elif Input.is_action_just_pressed("bomb_2"):
#enter_number(2)
#elif Input.is_action_just_pressed("bomb_3"):
#enter_number(3)
#elif Input.is_action_just_pressed("bomb_4"):
#enter_number(4)
#elif Input.is_action_just_pressed("bomb_5"):
#enter_number(5)
#elif Input.is_action_just_pressed("bomb_6"):
#enter_number(6)
#elif Input.is_action_just_pressed("bomb_7"):
#enter_number(7)
#elif Input.is_action_just_pressed("bomb_8"):
#enter_number(8)
#elif Input.is_action_just_pressed("bomb_9"):
#enter_number(9)
func enter_number(number : int):
if(number == current_number):

View file

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=3 uid="uid://ci31lqth7avk3"]
[ext_resource type="Texture2D" uid="uid://d3gtcjbsp5da1" path="res://sprites/invadersBullet.png" id="1_kq8vf"]
[ext_resource type="Script" uid="uid://bmjqhgclmoohl" path="res://games/space invaders/invaders_bullet.gd" id="1_xysrh"]
[sub_resource type="CircleShape2D" id="CircleShape2D_xysrh"]
radius = 7.07107
[node name="InvadersBullet" type="Area2D"]
script = ExtResource("1_xysrh")
speed = 160.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_xysrh")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(2, 2)
texture = ExtResource("1_kq8vf")

View file

@ -0,0 +1,12 @@
extends Area2D
@export var speed : float = 100
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
position.y -= delta * speed

View file

@ -0,0 +1 @@
uid://bmjqhgclmoohl

View file

@ -4,23 +4,23 @@ extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
@export var time_per_bullet : float = 2
var next_bullet : float =2
@export var bullet_cooldown : float = 1
var cooldown : float = 0
@export var bullet_spawn : Marker2D
@export var bullet_goal : Marker2D
func _ready() -> void:
next_bullet = time_per_bullet
cooldown = 0
func _process(delta: float) -> void:
next_bullet -= delta
if next_bullet <= 0:
cooldown -= delta
if cooldown <= 0 and Input.is_action_just_pressed("invaders_shoot"):
shoot()
func shoot():
next_bullet = time_per_bullet
var new_bullet : Node2D = load("res://games/asteroids/bullet.tscn").instantiate() as Node2D
new_bullet.goal = bullet_goal.global_position
cooldown = bullet_cooldown
var new_bullet : Node2D = load("res://games/space invaders/invadersBullet.tscn").instantiate() as Node2D
#new_bullet.goal = bullet_goal.global_position
new_bullet.position = bullet_spawn.global_position
get_parent().add_child(new_bullet)
@ -28,10 +28,11 @@ func _physics_process(delta: float) -> void:
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("invaders_left", "invaders_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
#var direction := Input.get_axis("invaders_left", "invaders_right")
#if direction:
#velocity.x = direction * SPEED
#else:
#velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()

View file

@ -3,6 +3,12 @@ extends Node
signal game_win
signal game_lose
@export var ufo_speed : float = 0.1
@export_group("Node References")
@export var ufo_path : PathFollow2D
var ufo_progress : float
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
@ -10,4 +16,13 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
ufo_progress += delta * ufo_speed
ufo_path.progress_ratio = ufo_progress
if ufo_progress >= 1:
print("invaders lose")
game_lose.emit()
func _on_ufo_area_entered(area: Area2D) -> void:
print("invaders win")
game_win.emit()

View file

@ -1,9 +1,9 @@
[gd_scene load_steps=10 format=3 uid="uid://bkabgl6p44c5b"]
[gd_scene load_steps=12 format=3 uid="uid://bkabgl6p44c5b"]
[ext_resource type="Texture2D" uid="uid://dqorec3q3h3pp" path="res://sprites/asteroidsShip.png" id="1_8m3yy"]
[ext_resource type="Script" uid="uid://c1e46eu5tbni0" path="res://games/space invaders/ship.gd" id="1_jsxp6"]
[ext_resource type="Script" uid="uid://0v0y62pyhpq4" path="res://games/space invaders/space_invaders.gd" id="1_k5cbn"]
[ext_resource type="Texture2D" uid="uid://by327tfhk6xrs" path="res://sprites/invadersBarrier.png" id="2_jsxp6"]
[ext_resource type="Texture2D" uid="uid://d1p5uve4nterl" path="res://sprites/invadersShip.png" id="3_k5cbn"]
[ext_resource type="Texture2D" uid="uid://yff1qo402ihn" path="res://sprites/ufo.png" id="4_k5cbn"]
[sub_resource type="Gradient" id="Gradient_4laqq"]
interpolation_mode = 1
@ -21,11 +21,21 @@ noise = SubResource("FastNoiseLite_ceqm6")
[sub_resource type="CircleShape2D" id="CircleShape2D_jdxs5"]
radius = 24.1868
[sub_resource type="RectangleShape2D" id="RectangleShape2D_gagve"]
size = Vector2(56, 28)
[sub_resource type="Curve2D" id="Curve2D_jdxs5"]
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 40, 70, 0, 0, 0, 0, 600, 70, 0, 0, 0, 0, 600, 150, 0, 0, 0, 0, 40, 150, 0, 0, 0, 0, 40, 230, 0, 0, 0, 0, 600, 230)
}
point_count = 6
[node name="SpaceInvaders" type="Node"]
[sub_resource type="CircleShape2D" id="CircleShape2D_gagve"]
radius = 32.0
[sub_resource type="LabelSettings" id="LabelSettings_k5cbn"]
font_size = 36
[node name="SpaceInvaders" type="Node" node_paths=PackedStringArray("ufo_path")]
script = ExtResource("1_k5cbn")
ufo_path = NodePath("UfoPath/PathFollow2D")
[node name="TextureRect" type="TextureRect" parent="."]
anchors_preset = 15
@ -44,7 +54,9 @@ bullet_spawn = NodePath("Spawn")
bullet_goal = NodePath("Goal")
[node name="Sprite2D" type="Sprite2D" parent="Ship"]
texture = ExtResource("1_8m3yy")
rotation = 1.5708
scale = Vector2(3, 3)
texture = ExtResource("3_k5cbn")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ship"]
shape = SubResource("CircleShape2D_jdxs5")
@ -55,13 +67,33 @@ position = Vector2(34, 1.48619e-06)
[node name="Goal" type="Marker2D" parent="Ship"]
position = Vector2(335, 1.46433e-05)
[node name="Barrier" type="StaticBody2D" parent="."]
position = Vector2(334, 264)
[node name="UfoPath" type="Path2D" parent="."]
position = Vector2(0, 23)
curve = SubResource("Curve2D_jdxs5")
[node name="Sprite2D" type="Sprite2D" parent="Barrier"]
scale = Vector2(2, 2)
texture = ExtResource("2_jsxp6")
[node name="PathFollow2D" type="PathFollow2D" parent="UfoPath"]
position = Vector2(40, 70)
rotates = false
loop = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Barrier"]
position = Vector2(0, 2)
shape = SubResource("RectangleShape2D_gagve")
[node name="UFO" type="Area2D" parent="UfoPath/PathFollow2D"]
[node name="Sprite2D" type="Sprite2D" parent="UfoPath/PathFollow2D/UFO"]
scale = Vector2(3, 3)
texture = ExtResource("4_k5cbn")
[node name="CollisionShape2D" type="CollisionShape2D" parent="UfoPath/PathFollow2D/UFO"]
shape = SubResource("CircleShape2D_gagve")
[node name="Label" type="Label" parent="."]
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -196.0
offset_right = 196.0
offset_bottom = 50.0
grow_horizontal = 2
text = "Shoot The UFO with O!"
label_settings = SubResource("LabelSettings_k5cbn")
[connection signal="area_entered" from="UfoPath/PathFollow2D/UFO" to="." method="_on_ufo_area_entered"]