ddr gaming
This commit is contained in:
parent
04417dffbd
commit
288245037b
25 changed files with 466 additions and 6 deletions
37
games/space invaders/ship.gd
Normal file
37
games/space invaders/ship.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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_spawn : Marker2D
|
||||
@export var bullet_goal : Marker2D
|
||||
|
||||
func _ready() -> void:
|
||||
next_bullet = time_per_bullet
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
next_bullet -= delta
|
||||
if next_bullet <= 0:
|
||||
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
|
||||
new_bullet.position = bullet_spawn.global_position
|
||||
get_parent().add_child(new_bullet)
|
||||
|
||||
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)
|
||||
|
||||
move_and_slide()
|
||||
1
games/space invaders/ship.gd.uid
Normal file
1
games/space invaders/ship.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c1e46eu5tbni0
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://bkabgl6p44c5b"]
|
||||
[gd_scene load_steps=9 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="Texture2D" uid="uid://by327tfhk6xrs" path="res://sprites/invadersBarrier.png" id="2_jsxp6"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_4laqq"]
|
||||
|
|
@ -32,9 +33,13 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
texture = SubResource("NoiseTexture2D_k5cbn")
|
||||
|
||||
[node name="Ship" type="CharacterBody2D" parent="."]
|
||||
[node name="Ship" type="CharacterBody2D" parent="." node_paths=PackedStringArray("bullet_spawn", "bullet_goal")]
|
||||
position = Vector2(336, 319)
|
||||
rotation = -1.5708
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_jsxp6")
|
||||
bullet_spawn = NodePath("Spawn")
|
||||
bullet_goal = NodePath("Goal")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Ship"]
|
||||
texture = ExtResource("1_8m3yy")
|
||||
|
|
@ -42,6 +47,12 @@ texture = ExtResource("1_8m3yy")
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ship"]
|
||||
shape = SubResource("CircleShape2D_jdxs5")
|
||||
|
||||
[node name="Spawn" type="Marker2D" parent="Ship"]
|
||||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue