summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrom <romangraef@gmail.com>2021-04-26 17:55:15 +0200
committerrom <romangraef@gmail.com>2021-04-26 17:56:07 +0200
commitcbb667117356043f026e7d041e767a7a4c692ffa (patch)
tree6045edd4fef254a347b6979771d06ca80c4e53b4
parentb1e4f45c85d3c67ec35c395c23f916d71e4c14db (diff)
downloadldjam48-cbb667117356043f026e7d041e767a7a4c692ffa.tar.gz
ldjam48-cbb667117356043f026e7d041e767a7a4c692ffa.tar.bz2
ldjam48-cbb667117356043f026e7d041e767a7a4c692ffa.zip
bulletmaster3000
-rw-r--r--.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.md53
-rw-r--r--.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.stexbin0 -> 201 bytes
-rw-r--r--.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.md53
-rw-r--r--.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.stexbin0 -> 311 bytes
-rw-r--r--components/Level.gd3
-rw-r--r--project.godot6
-rw-r--r--scenes/levels/base_level.gd4
-rw-r--r--scenes/levels/pixel/PixelDefender.gd73
-rw-r--r--scenes/levels/pixel/PixelDefender.tscn17
-rw-r--r--scenes/levels/pixel/bullet.gd13
-rw-r--r--scenes/levels/pixel/bullet.tscn18
-rw-r--r--scenes/levels/pixel/spaceship.gd2
-rw-r--r--scenes/levels/pixel/spaceship.tscn14
-rw-r--r--scenes/levels/reactiontest.gd2
-rw-r--r--textures/bullet.pngbin0 -> 618 bytes
-rw-r--r--textures/bullet.png.import34
-rw-r--r--textures/spaceship.pngbin0 -> 711 bytes
-rw-r--r--textures/spaceship.png.import34
18 files changed, 222 insertions, 4 deletions
diff --git a/.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.md5 b/.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.md5
new file mode 100644
index 0000000..4bca1ac
--- /dev/null
+++ b/.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.md5
@@ -0,0 +1,3 @@
+source_md5="e01789d0e73c663472c347b1c6419316"
+dest_md5="3d32309becd3db90483520706a3b97f3"
+
diff --git a/.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.stex b/.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.stex
new file mode 100644
index 0000000..9280446
--- /dev/null
+++ b/.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.stex
Binary files differ
diff --git a/.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.md5 b/.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.md5
new file mode 100644
index 0000000..999c97b
--- /dev/null
+++ b/.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.md5
@@ -0,0 +1,3 @@
+source_md5="56612b0474b7e9986a4caf55ad68f86c"
+dest_md5="dd47e198c403cf859ce9102630c2fe17"
+
diff --git a/.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.stex b/.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.stex
new file mode 100644
index 0000000..c09fa86
--- /dev/null
+++ b/.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.stex
Binary files differ
diff --git a/components/Level.gd b/components/Level.gd
index 18965a8..ad48336 100644
--- a/components/Level.gd
+++ b/components/Level.gd
@@ -4,9 +4,11 @@ class_name Level
signal lost_heart(instakill)
signal level_finished()
+var running = false
func start():
print("Level ", name, " starting.")
+ running = true
func lose_heart():
emit_signal("lost_heart", false)
@@ -15,5 +17,6 @@ func lose_all_hearts():
emit_signal("lost_heart", true)
func finish_level():
+ running = false
emit_signal("level_finished")
diff --git a/project.godot b/project.godot
index ffe31ee..659ebc6 100644
--- a/project.godot
+++ b/project.godot
@@ -9,6 +9,11 @@
config_version=4
_global_script_classes=[ {
+"base": "Area2D",
+"class": "Bullet",
+"language": "GDScript",
+"path": "res://scenes/levels/pixel/bullet.gd"
+}, {
"base": "Node2D",
"class": "ButtonTest",
"language": "GDScript",
@@ -40,6 +45,7 @@ _global_script_classes=[ {
"path": "res://components/textreveal.gd"
} ]
_global_script_class_icons={
+"Bullet": "",
"ButtonTest": "",
"CameraTrackFollower": "",
"Card": "",
diff --git a/scenes/levels/base_level.gd b/scenes/levels/base_level.gd
index 8f06747..335376d 100644
--- a/scenes/levels/base_level.gd
+++ b/scenes/levels/base_level.gd
@@ -7,9 +7,9 @@ onready var _path_renderer : PathRenderer = $PathRenderer
onready var _health_bar = $Camera2D/healthbar
onready var _last_camera_location : Vector2 = $Camera2D.position
const _levels = [
- preload("res://scenes/levels/typeracer_explain.tscn"),
preload("res://scenes/levels/typeracer.tscn"),
- preload("res://scenes/levels/reactiontest.tscn")
+ preload("res://scenes/levels/reactiontest.tscn"),
+ preload("res://scenes/levels/pixel/PixelDefender.tscn"),
]
var _current_level = 0
diff --git a/scenes/levels/pixel/PixelDefender.gd b/scenes/levels/pixel/PixelDefender.gd
new file mode 100644
index 0000000..2fc2e2d
--- /dev/null
+++ b/scenes/levels/pixel/PixelDefender.gd
@@ -0,0 +1,73 @@
+extends Level
+
+
+const _bullet_scene = preload("res://scenes/levels/pixel/bullet.tscn")
+const _enemy_scene = preload("res://scenes/levels/pixel/spaceship.tscn")
+
+
+func _new_bullet(velocity, team) -> Bullet:
+ var bullet = _bullet_scene.instance()
+ bullet.velocity = velocity
+ bullet.team = team
+ $BulletHolder.add_child(bullet)
+ return bullet
+
+func _new_enemy():
+ var enemy = _enemy_scene.instance()
+ enemy.position = Vector2(500 + randi() % 80, (randf() * 600) - 350)
+ enemy.scale.x *= -1
+ enemy.team = Bullet.CHAOS
+ $Enemies.add_child(enemy)
+ enemy.connect("area_shape_entered", self, "_on_enemy_area_shape_entered", [enemy])
+ return enemy
+
+func start():
+ .start()
+ var enemy_count = 5
+ if Settings.difficulty == Settings.Difficulty.HARD:
+ enemy_count += 3
+ for i in range(5):
+ _new_enemy()
+
+var t = 0
+var bullet_timer = 1.5
+var enemy_speed = 1
+
+func _process(delta):
+ if not running:
+ return
+ t += delta
+
+ while t > bullet_timer:
+ t -= bullet_timer
+ var b = _new_bullet(10, Bullet.ORDER)
+ b.position = $spaceship.position + Vector2(16, 0)
+ for e in $Enemies.get_children():
+ b = _new_bullet(10, Bullet.CHAOS)
+ b.position = e.position - Vector2(16, 0)
+ if $Enemies.get_child_count() == 0:
+ finish_level()
+ return
+ for e in $Enemies.get_children():
+ e.position -= Vector2(enemy_speed, 0)
+ if e.position.x < $spaceship.position.x:
+ lose_all_hearts()
+ return
+
+ $spaceship.position.y = max(0, min(get_viewport().get_mouse_position().y, get_viewport_rect().size.y)) - 360
+
+func _on_enemy_area_shape_entered(area_id, area, area_shape, local_shape, e):
+ if area is Bullet and area.team == Bullet.CHAOS:
+ return
+ if area is Bullet:
+ area.queue_free()
+ elif area.team == Bullet.CHAOS:
+ return
+ e.queue_free()
+
+func _on_spaceship_area_shape_entered(area_id, area, area_shape, local_shape):
+ if area is Bullet:
+ if area.team == Bullet.CHAOS:
+ lose_heart()
+ else:
+ lose_all_hearts()
diff --git a/scenes/levels/pixel/PixelDefender.tscn b/scenes/levels/pixel/PixelDefender.tscn
new file mode 100644
index 0000000..29c7674
--- /dev/null
+++ b/scenes/levels/pixel/PixelDefender.tscn
@@ -0,0 +1,17 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://scenes/levels/pixel/PixelDefender.gd" type="Script" id=1]
+[ext_resource path="res://scenes/levels/pixel/spaceship.tscn" type="PackedScene" id=2]
+
+[node name="Node2D" type="Node2D"]
+position = Vector2( 640, 360 )
+script = ExtResource( 1 )
+
+[node name="BulletHolder" type="Node2D" parent="."]
+
+[node name="spaceship" parent="." instance=ExtResource( 2 )]
+position = Vector2( -432.818, -39.5735 )
+
+[node name="Enemies" type="Node2D" parent="."]
+
+[connection signal="area_shape_entered" from="spaceship" to="." method="_on_spaceship_area_shape_entered"]
diff --git a/scenes/levels/pixel/bullet.gd b/scenes/levels/pixel/bullet.gd
new file mode 100644
index 0000000..865af35
--- /dev/null
+++ b/scenes/levels/pixel/bullet.gd
@@ -0,0 +1,13 @@
+extends Area2D
+
+class_name Bullet
+
+enum {ORDER, CHAOS}
+var velocity = 10
+var team = ORDER
+
+func _process(delta):
+ if team == ORDER:
+ position.x += velocity
+ else:
+ position.x -= velocity
diff --git a/scenes/levels/pixel/bullet.tscn b/scenes/levels/pixel/bullet.tscn
new file mode 100644
index 0000000..10ff51d
--- /dev/null
+++ b/scenes/levels/pixel/bullet.tscn
@@ -0,0 +1,18 @@
+[gd_scene load_steps=4 format=2]
+
+[ext_resource path="res://textures/bullet.png" type="Texture" id=1]
+[ext_resource path="res://scenes/levels/pixel/bullet.gd" type="Script" id=2]
+
+[sub_resource type="CircleShape2D" id=1]
+radius = 5.58358
+
+[node name="Bullet" type="Area2D"]
+script = ExtResource( 2 )
+
+[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
+position = Vector2( -0.148651, 0.297302 )
+shape = SubResource( 1 )
+
+[node name="Sprite" type="Sprite" parent="."]
+position = Vector2( 0.297302, -0.148651 )
+texture = ExtResource( 1 )
diff --git a/scenes/levels/pixel/spaceship.gd b/scenes/levels/pixel/spaceship.gd
new file mode 100644
index 0000000..3c39665
--- /dev/null
+++ b/scenes/levels/pixel/spaceship.gd
@@ -0,0 +1,2 @@
+extends Area2D
+var team = Bullet.ORDER
diff --git a/scenes/levels/pixel/spaceship.tscn b/scenes/levels/pixel/spaceship.tscn
new file mode 100644
index 0000000..1247f56
--- /dev/null
+++ b/scenes/levels/pixel/spaceship.tscn
@@ -0,0 +1,14 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://textures/spaceship.png" type="Texture" id=1]
+[ext_resource path="res://scenes/levels/pixel/spaceship.gd" type="Script" id=2]
+
+[node name="spaceship" type="Area2D"]
+position = Vector2( 50, 360 )
+script = ExtResource( 2 )
+
+[node name="spaceship" type="Sprite" parent="."]
+texture = ExtResource( 1 )
+
+[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
+polygon = PoolVector2Array( 16, 0, -16, 16, -16, -16 )
diff --git a/scenes/levels/reactiontest.gd b/scenes/levels/reactiontest.gd
index 2038409..60b76ab 100644
--- a/scenes/levels/reactiontest.gd
+++ b/scenes/levels/reactiontest.gd
@@ -5,7 +5,6 @@ onready var timer_label = $TimerLabel
var sequence_index = 0
var timer = 0
-var running = false
func _total_time():
if Settings.difficulty == Settings.Difficulty.HARD:
@@ -14,7 +13,6 @@ func _total_time():
func start():
.start()
- running = true
func _ready():
timer = 0
diff --git a/textures/bullet.png b/textures/bullet.png
new file mode 100644
index 0000000..8de2bbb
--- /dev/null
+++ b/textures/bullet.png
Binary files differ
diff --git a/textures/bullet.png.import b/textures/bullet.png.import
new file mode 100644
index 0000000..ccb3b03
--- /dev/null
+++ b/textures/bullet.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://textures/bullet.png"
+dest_files=[ "res://.import/bullet.png-fcc9b6edffdc3d7ef5fea596f59b4f40.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=true
+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=true
+svg/scale=1.0
diff --git a/textures/spaceship.png b/textures/spaceship.png
new file mode 100644
index 0000000..0f2aa7d
--- /dev/null
+++ b/textures/spaceship.png
Binary files differ
diff --git a/textures/spaceship.png.import b/textures/spaceship.png.import
new file mode 100644
index 0000000..a4de47b
--- /dev/null
+++ b/textures/spaceship.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://textures/spaceship.png"
+dest_files=[ "res://.import/spaceship.png-41a5592f473e830d5b7bfd315d694649.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=true
+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=true
+svg/scale=1.0