various updates
This commit is contained in:
parent
8d6da7bf7e
commit
43b52fcea9
17 changed files with 244 additions and 109 deletions
18
games/space invaders/invadersBullet.tscn
Normal file
18
games/space invaders/invadersBullet.tscn
Normal 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")
|
||||
12
games/space invaders/invaders_bullet.gd
Normal file
12
games/space invaders/invaders_bullet.gd
Normal 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
|
||||
1
games/space invaders/invaders_bullet.gd.uid
Normal file
1
games/space invaders/invaders_bullet.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bmjqhgclmoohl
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue