Game #3: Space Shooter
This commit is contained in:
parent
a00e9b59c9
commit
f785a24c14
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_resource type="DynamicFont" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Fonts/PixelRPG.ttf" type="DynamicFontData" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
size = 6
|
||||||
|
outline_size = 1
|
||||||
|
outline_color = Color( 0, 0, 0, 1 )
|
||||||
|
font_data = ExtResource( 1 )
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,15 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="ogg_vorbis"
|
||||||
|
type="AudioStreamOGGVorbis"
|
||||||
|
path="res://.import/Music.ogg-f69a749f7338b813c63855278de4e5c3.oggstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Music/Music.ogg"
|
||||||
|
dest_files=[ "res://.import/Music.ogg-f69a749f7338b813c63855278de4e5c3.oggstr" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=true
|
||||||
|
loop_offset=0
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamSample"
|
||||||
|
path="res://.import/Explode.wav-aec372f44790e9df20003d37a93b7bfc.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://SFX/Explode.wav"
|
||||||
|
dest_files=[ "res://.import/Explode.wav-aec372f44790e9df20003d37a93b7bfc.sample" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop=false
|
||||||
|
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamSample"
|
||||||
|
path="res://.import/Hit.wav-f77bf5c97be4c0ce892ce1dd6090f868.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://SFX/Hit.wav"
|
||||||
|
dest_files=[ "res://.import/Hit.wav-f77bf5c97be4c0ce892ce1dd6090f868.sample" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop=false
|
||||||
|
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamSample"
|
||||||
|
path="res://.import/Laser.wav-f9c61d174511545a59e6864a4cc323b3.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://SFX/Laser.wav"
|
||||||
|
dest_files=[ "res://.import/Laser.wav-f9c61d174511545a59e6864a4cc323b3.sample" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop=false
|
||||||
|
compress/mode=0
|
Binary file not shown.
|
@ -0,0 +1,21 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamSample"
|
||||||
|
path="res://.import/ShipHit.wav-09354c8cacbe6fedf6eb9998a4d738e2.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://SFX/ShipHit.wav"
|
||||||
|
dest_files=[ "res://.import/ShipHit.wav-09354c8cacbe6fedf6eb9998a4d738e2.sample" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop=false
|
||||||
|
compress/mode=0
|
|
@ -0,0 +1,21 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
const Enemy = preload("res://Scenes/Objects/Enemy.tscn")
|
||||||
|
onready var spawnPoints = $SpawnPoints
|
||||||
|
|
||||||
|
|
||||||
|
func get_random_spawnpoint():
|
||||||
|
var points = spawnPoints.get_children()
|
||||||
|
points.shuffle()
|
||||||
|
return points[0].global_position
|
||||||
|
|
||||||
|
|
||||||
|
func spawn_enemy():
|
||||||
|
var spawn_location = get_random_spawnpoint()
|
||||||
|
var enemy = Enemy.instance()
|
||||||
|
enemy.global_position = spawn_location
|
||||||
|
get_tree().current_scene.add_child(enemy)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Timer_timeout():
|
||||||
|
spawn_enemy()
|
|
@ -0,0 +1,38 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/EnemySpawner.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="EnemySpawner" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="SpawnPoints" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Position2D" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 20 )
|
||||||
|
|
||||||
|
[node name="Position2D2" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 40 )
|
||||||
|
|
||||||
|
[node name="Position2D3" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 60 )
|
||||||
|
|
||||||
|
[node name="Position2D4" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 80 )
|
||||||
|
|
||||||
|
[node name="Position2D5" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 100 )
|
||||||
|
|
||||||
|
[node name="Position2D6" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 120 )
|
||||||
|
|
||||||
|
[node name="Position2D7" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 140 )
|
||||||
|
|
||||||
|
[node name="Position2D8" type="Position2D" parent="SpawnPoints"]
|
||||||
|
position = Vector2( 0, 160 )
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 2.0
|
||||||
|
autostart = true
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
|
@ -0,0 +1,46 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Sprites/Explosion.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://SFX/Explode.wav" type="AudioStream" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=1]
|
||||||
|
resource_name = "Explosion"
|
||||||
|
length = 0.5
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath(".:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4 ),
|
||||||
|
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 0, 1, 2, 3, 4 ]
|
||||||
|
}
|
||||||
|
tracks/1/type = "method"
|
||||||
|
tracks/1/path = NodePath(".")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PoolRealArray( 0.5 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"values": [ {
|
||||||
|
"args": [ ],
|
||||||
|
"method": "queue_free"
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ExplosionEffect" type="Sprite"]
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
hframes = 6
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
autoplay = "Explosion"
|
||||||
|
anims/Explosion = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="ExplosionSound" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource( 2 )
|
||||||
|
autoplay = true
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Timer_timeout():
|
||||||
|
queue_free()
|
|
@ -0,0 +1,37 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/LaserHit.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://SFX/Hit.wav" type="AudioStream" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="ParticlesMaterial" id=1]
|
||||||
|
lifetime_randomness = 1.0
|
||||||
|
emission_shape = 1
|
||||||
|
emission_sphere_radius = 1.0
|
||||||
|
flag_disable_z = true
|
||||||
|
spread = 180.0
|
||||||
|
gravity = Vector3( 0, 0, 0 )
|
||||||
|
initial_velocity = 25.0
|
||||||
|
initial_velocity_random = 1.0
|
||||||
|
orbit_velocity = 0.0
|
||||||
|
orbit_velocity_random = 0.0
|
||||||
|
scale = 1.5
|
||||||
|
|
||||||
|
[node name="LaserHit" type="Node2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 3.0
|
||||||
|
one_shot = true
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[node name="HitParticles" type="Particles2D" parent="."]
|
||||||
|
emitting = false
|
||||||
|
one_shot = true
|
||||||
|
explosiveness = 1.0
|
||||||
|
randomness = 1.0
|
||||||
|
process_material = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="HitSound" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource( 2 )
|
||||||
|
autoplay = true
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Music/Music.ogg" type="AudioStream" id=1]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="Music" type="AudioStreamPlayer"]
|
||||||
|
stream = ExtResource( 1 )
|
||||||
|
volume_db = -2.0
|
||||||
|
autoplay = true
|
|
@ -0,0 +1,18 @@
|
||||||
|
extends RigidBody2D
|
||||||
|
|
||||||
|
|
||||||
|
const LaserHit = preload("res://Scenes/LaserHit.tscn")
|
||||||
|
|
||||||
|
onready var laserSound = $LaserSound
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
laserSound.play()
|
||||||
|
|
||||||
|
func _on_VisibilityNotifier2D_screen_exited():
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func create_hit_effect():
|
||||||
|
var hit = LaserHit.instance()
|
||||||
|
hit.global_position = global_position
|
||||||
|
hit.get_node("HitParticles").emitting = true
|
||||||
|
get_tree().current_scene.add_child(hit)
|
|
@ -0,0 +1,30 @@
|
||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Objects/Bullet.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Sprites/Bullet.png" type="Texture" id=2]
|
||||||
|
[ext_resource path="res://SFX/Laser.wav" type="AudioStream" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 4.07371, 3.0471 )
|
||||||
|
|
||||||
|
[node name="Bullet" type="RigidBody2D"]
|
||||||
|
gravity_scale = 0.0
|
||||||
|
linear_velocity = Vector2( 200, 0 )
|
||||||
|
linear_damp = 0.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Collisiion" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
|
||||||
|
position = Vector2( 0.471259, 0.0496063 )
|
||||||
|
scale = Vector2( 0.456811, 0.394803 )
|
||||||
|
|
||||||
|
[node name="LaserSound" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource( 3 )
|
||||||
|
autoplay = true
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_Bullet_body_entered"]
|
||||||
|
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
|
@ -0,0 +1,30 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
const Explosion = preload("res://Scenes/ExplosionEffect.tscn")
|
||||||
|
|
||||||
|
export (int) var speed = 50
|
||||||
|
export (int) var armor = 3
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
position.x -= speed * delta
|
||||||
|
|
||||||
|
func _on_Enemy_body_entered(body):
|
||||||
|
body.create_hit_effect()
|
||||||
|
body.queue_free()
|
||||||
|
armor -= 1
|
||||||
|
|
||||||
|
if armor <= 0:
|
||||||
|
var root = get_tree().current_scene
|
||||||
|
if root.is_in_group("World"):
|
||||||
|
root.score += 10
|
||||||
|
explode()
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func _on_VisibilityNotifier2D_screen_exited():
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func explode():
|
||||||
|
var explosion = Explosion.instance()
|
||||||
|
explosion.global_position = global_position
|
||||||
|
get_tree().current_scene.add_child(explosion)
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Objects/Enemy.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Sprites/Enemy.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[node name="Enemy" type="Area2D"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Collision" type="CollisionPolygon2D" parent="."]
|
||||||
|
polygon = PoolVector2Array( -3, -7, -1, -7, -1, -5, 0, -5, 0, -6, 1, -6, 1, -7, 3, -7, 3, -6, 4, -6, 4, -5, 5, -5, 5, 5, 4, 5, 4, 6, 3, 6, 3, 7, 1, 7, 1, 6, 0, 6, 0, 5, -1, 5, -1, 7, -3, 7, -3, 6, -4, 6, -4, 5, -2, 5, -2, 3, -3, 3, -3, 2, -5, 2, -5, 1, -4, 1, -4, -1, -5, -1, -5, -2, -3, -2, -3, -3, -2, -3, -2, -5, -4, -5, -4, -6, -3, -6 )
|
||||||
|
|
||||||
|
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="."]
|
||||||
|
position = Vector2( 0, 4.17233e-07 )
|
||||||
|
scale = Vector2( 0.6, 0.8 )
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_Enemy_body_entered"]
|
||||||
|
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
|
@ -0,0 +1,39 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
const Bullet = preload("res://Scenes/Objects/Bullet.tscn")
|
||||||
|
const Explosion = preload("res://Scenes/ExplosionEffect.tscn")
|
||||||
|
|
||||||
|
export (int) var speed = 100
|
||||||
|
|
||||||
|
signal player_death
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
if Input.is_action_pressed("ui_up"):
|
||||||
|
position.y -= speed * delta
|
||||||
|
|
||||||
|
if Input.is_action_pressed("ui_down"):
|
||||||
|
position.y += speed * delta
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("ui_select"):
|
||||||
|
fire_bullet()
|
||||||
|
|
||||||
|
|
||||||
|
func fire_bullet():
|
||||||
|
var bullet = Bullet.instance()
|
||||||
|
var root = get_tree().current_scene # World scene root node
|
||||||
|
|
||||||
|
bullet.global_position = global_position
|
||||||
|
|
||||||
|
root.add_child_below_node(root.get_node("Background"), bullet)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Ship_area_entered(area):
|
||||||
|
queue_free()
|
||||||
|
area.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
var explosion = Explosion.instance()
|
||||||
|
explosion.global_position = global_position
|
||||||
|
get_tree().current_scene.call_deferred("add_child", explosion)
|
||||||
|
emit_signal("player_death")
|
|
@ -0,0 +1,15 @@
|
||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Sprites/Ship.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Objects/Ship.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="Ship" type="Area2D"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Collision" type="CollisionPolygon2D" parent="."]
|
||||||
|
polygon = PoolVector2Array( -7, -4, -5, -4, -5, -3, -4, -3, -4, -7, -2, -7, -2, -6, -1, -6, -1, -5, 0, -5, 0, -4, 1, -4, 1, -3, 2, -3, 2, -2, 5, -2, 5, -1, 7, -1, 7, 1, 5, 1, 5, 2, 2, 2, 2, 3, 1, 3, 1, 4, 0, 4, 0, 5, -1, 5, -1, 6, -2, 6, -2, 7, -4, 7, -4, 3, -5, 3, -5, 4, -7, 4, -7, 2, -6, 2, -6, 1, -7, 1, -7, -1, -6, -1, -6, -2, -7, -2 )
|
||||||
|
[connection signal="area_entered" from="." to="." method="_on_Ship_area_entered"]
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="ParticlesMaterial" id=1]
|
||||||
|
emission_shape = 2
|
||||||
|
emission_box_extents = Vector3( 1, 90, 1 )
|
||||||
|
flag_disable_z = true
|
||||||
|
spread = 0.0
|
||||||
|
gravity = Vector3( 0, 0, 0 )
|
||||||
|
initial_velocity = -100.0
|
||||||
|
initial_velocity_random = 0.5
|
||||||
|
orbit_velocity = 0.0
|
||||||
|
orbit_velocity_random = 0.0
|
||||||
|
|
||||||
|
[node name="Stars" type="Particles2D"]
|
||||||
|
position = Vector2( 320, 90 )
|
||||||
|
amount = 120
|
||||||
|
lifetime = 10.0
|
||||||
|
preprocess = 10.0
|
||||||
|
process_material = SubResource( 1 )
|
|
@ -0,0 +1,28 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
# Use user://save.json to automatically use user app config folders
|
||||||
|
# Leaving as res to avoid storing json files for test games
|
||||||
|
const SAVE_DATA_PATH = "res://save.json"
|
||||||
|
|
||||||
|
var default_save_data = {
|
||||||
|
"hi_score": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func store_save_data(data):
|
||||||
|
var save_file = File.new()
|
||||||
|
save_file.open(SAVE_DATA_PATH, File.WRITE)
|
||||||
|
save_file.store_line(to_json(data))
|
||||||
|
save_file.close()
|
||||||
|
|
||||||
|
func load_save_data():
|
||||||
|
var save_file = File.new()
|
||||||
|
|
||||||
|
if not save_file.file_exists(SAVE_DATA_PATH):
|
||||||
|
store_save_data(default_save_data)
|
||||||
|
return default_save_data
|
||||||
|
|
||||||
|
save_file.open(SAVE_DATA_PATH, File.READ)
|
||||||
|
var save_data = parse_json(save_file.get_as_text())
|
||||||
|
save_file.close()
|
||||||
|
|
||||||
|
return save_data
|
|
@ -0,0 +1,10 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var save_data = SaveLoad.load_save_data()
|
||||||
|
$HiScore.text = "Hi-Score: " + str(save_data.hi_score)
|
||||||
|
|
||||||
|
func _process(_delta):
|
||||||
|
if Input.is_action_just_pressed("ui_cancel"):
|
||||||
|
# warning-ignore:return_value_discarded
|
||||||
|
get_tree().change_scene("res://Scenes/Stages/MainMenu.tscn")
|
|
@ -0,0 +1,60 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Fonts/PixelFont.tres" type="DynamicFont" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Objects/Stars.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://Scenes/Stages/GameOver.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[node name="GameOver" type="Node"]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0, 0, 0, 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_lock_": true,
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Stars" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="GameOver" type="Label" parent="."]
|
||||||
|
margin_top = 60.0
|
||||||
|
margin_right = 320.0
|
||||||
|
margin_bottom = 80.0
|
||||||
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
text = "GAME OVER"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HiScore" type="Label" parent="."]
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_top = -100.0
|
||||||
|
margin_bottom = -80.0
|
||||||
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
text = "Hi-Score = 0"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Info" type="Label" parent="."]
|
||||||
|
margin_top = 100.0
|
||||||
|
margin_right = 320.0
|
||||||
|
margin_bottom = 120.0
|
||||||
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
text = "Press ESC to go back to the Main Menu"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta):
|
||||||
|
if Input.is_action_just_pressed("ui_select"):
|
||||||
|
# warning-ignore:return_value_discarded
|
||||||
|
get_tree().change_scene("res://Scenes/Stages/World.tscn")
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("ui_cancel"):
|
||||||
|
get_tree().quit()
|
|
@ -0,0 +1,40 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Fonts/PixelFont.tres" type="DynamicFont" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Objects/Stars.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://Scenes/Stages/MainMenu.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[node name="MainMenu" type="Node"]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0, 0, 0, 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_lock_": true,
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CenterContainer"]
|
||||||
|
margin_left = 121.0
|
||||||
|
margin_top = 82.0
|
||||||
|
margin_right = 199.0
|
||||||
|
margin_bottom = 97.0
|
||||||
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
text = "Press Space to Start
|
||||||
|
Press ESC to exit"
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Stars" parent="." instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 320, 80 )
|
|
@ -0,0 +1,25 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var score = 0 setget set_score
|
||||||
|
onready var scoreLabel = $Score
|
||||||
|
|
||||||
|
|
||||||
|
func set_score(value):
|
||||||
|
score = value
|
||||||
|
update_score(str(value))
|
||||||
|
|
||||||
|
func update_score(value):
|
||||||
|
scoreLabel.text = "Score = " + value
|
||||||
|
|
||||||
|
func update_save_data():
|
||||||
|
var save_data = SaveLoad.load_save_data()
|
||||||
|
if score > save_data.hi_score:
|
||||||
|
save_data.hi_score = score
|
||||||
|
SaveLoad.store_save_data(save_data)
|
||||||
|
|
||||||
|
func _on_Ship_player_death():
|
||||||
|
update_save_data()
|
||||||
|
# Yield until the timer expires
|
||||||
|
yield(get_tree().create_timer(1), "timeout")
|
||||||
|
# warning-ignore:return_value_discarded
|
||||||
|
get_tree().change_scene("res://Scenes/Stages/GameOver.tscn")
|
|
@ -0,0 +1,42 @@
|
||||||
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Objects/Ship.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Stages/World.gd" type="Script" id=2]
|
||||||
|
[ext_resource path="res://Scenes/EnemySpawner.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://Fonts/PixelFont.tres" type="DynamicFont" id=4]
|
||||||
|
[ext_resource path="res://Scenes/Objects/Stars.tscn" type="PackedScene" id=5]
|
||||||
|
|
||||||
|
[node name="World" type="Node" groups=[
|
||||||
|
"World",
|
||||||
|
]]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0, 0, 0, 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_lock_": true,
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Stars" parent="." instance=ExtResource( 5 )]
|
||||||
|
|
||||||
|
[node name="EnemySpawner" parent="." instance=ExtResource( 3 )]
|
||||||
|
position = Vector2( 336, 0 )
|
||||||
|
|
||||||
|
[node name="Ship" parent="." instance=ExtResource( 1 )]
|
||||||
|
position = Vector2( 32, 90 )
|
||||||
|
|
||||||
|
[node name="Score" type="Label" parent="."]
|
||||||
|
margin_right = 320.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
custom_fonts/font = ExtResource( 4 )
|
||||||
|
text = "Score = 0"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_lock_": true,
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
[connection signal="player_death" from="Ship" to="." method="_on_Ship_player_death"]
|
Binary file not shown.
After Width: | Height: | Size: 210 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/Bullet.png-166c5f5d643c7e49aef2de7a06516757.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/Bullet.png"
|
||||||
|
dest_files=[ "res://.import/Bullet.png-166c5f5d643c7e49aef2de7a06516757.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
Binary file not shown.
After Width: | Height: | Size: 271 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/Enemy.png-4f2f37ccc9d782f4030225b9d1bff284.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/Enemy.png"
|
||||||
|
dest_files=[ "res://.import/Enemy.png-4f2f37ccc9d782f4030225b9d1bff284.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
Binary file not shown.
After Width: | Height: | Size: 278 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/Explosion.png-4cec69c6d6c03527ba22cbc120bf0a6e.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/Explosion.png"
|
||||||
|
dest_files=[ "res://.import/Explosion.png-4cec69c6d6c03527ba22cbc120bf0a6e.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
Binary file not shown.
After Width: | Height: | Size: 257 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/Ship.png-d6898bd410dcafdd90baf6595b371339.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/Ship.png"
|
||||||
|
dest_files=[ "res://.import/Ship.png-d6898bd410dcafdd90baf6595b371339.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="Environment" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="ProceduralSky" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
background_mode = 2
|
||||||
|
background_sky = SubResource( 1 )
|
|
@ -0,0 +1,22 @@
|
||||||
|
[preset.0]
|
||||||
|
|
||||||
|
name="HTML5"
|
||||||
|
platform="HTML5"
|
||||||
|
runnable=true
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="export/game.html"
|
||||||
|
patch_list=PoolStringArray( )
|
||||||
|
script_export_mode=1
|
||||||
|
script_encryption_key=""
|
||||||
|
|
||||||
|
[preset.0.options]
|
||||||
|
|
||||||
|
vram_texture_compression/for_desktop=true
|
||||||
|
vram_texture_compression/for_mobile=false
|
||||||
|
html/custom_html_shell=""
|
||||||
|
html/head_include=""
|
||||||
|
custom_template/release=""
|
||||||
|
custom_template/debug=""
|
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.png"
|
||||||
|
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
|
@ -0,0 +1,79 @@
|
||||||
|
; 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=4
|
||||||
|
|
||||||
|
_global_script_classes=[ ]
|
||||||
|
_global_script_class_icons={
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Space Shooter"
|
||||||
|
run/main_scene="res://Scenes/Stages/MainMenu.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Music="*res://Scenes/Music.tscn"
|
||||||
|
SaveLoad="*res://Scenes/SaveLoad.gd"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/width=320
|
||||||
|
window/size/height=180
|
||||||
|
window/size/resizable=false
|
||||||
|
window/size/test_width=1280
|
||||||
|
window/size/test_height=720
|
||||||
|
window/stretch/mode="2d"
|
||||||
|
window/stretch/aspect="keep"
|
||||||
|
|
||||||
|
[importer_defaults]
|
||||||
|
|
||||||
|
texture={
|
||||||
|
"compress/bptc_ldr": 0,
|
||||||
|
"compress/hdr_mode": 0,
|
||||||
|
"compress/lossy_quality": 0.7,
|
||||||
|
"compress/mode": 0,
|
||||||
|
"compress/normal_map": 0,
|
||||||
|
"detect_3d": false,
|
||||||
|
"flags/anisotropic": false,
|
||||||
|
"flags/filter": false,
|
||||||
|
"flags/mipmaps": false,
|
||||||
|
"flags/repeat": 0,
|
||||||
|
"flags/srgb": 2,
|
||||||
|
"process/HDR_as_SRGB": false,
|
||||||
|
"process/fix_alpha_border": true,
|
||||||
|
"process/invert_color": false,
|
||||||
|
"process/premult_alpha": false,
|
||||||
|
"size_limit": 0,
|
||||||
|
"stream": false,
|
||||||
|
"svg/scale": 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
ui_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ui_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
environment/default_environment="res://default_env.tres"
|
Loading…
Reference in New Issue