summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorarngo <[email protected]>2021-12-19 23:00:44 -0500
committerarngo <[email protected]>2021-12-19 23:02:56 -0500
commite78c6699a74fa4e00689a96707b304911b32eb08 (patch)
tree30486fdf6c6336771bb420d4d3855ba1e22af7fc
parent19e578b5a5e0c3d4788f263c7a5e21df4236dc9b (diff)
downloadSteelWings-e78c6699a74fa4e00689a96707b304911b32eb08.tar.gz
SteelWings-e78c6699a74fa4e00689a96707b304911b32eb08.zip
bullet cleanup
-rw-r--r--app/components/singleton_bullet.rb2
-rw-r--r--app/factories/bullet.rb1
-rw-r--r--app/main.rb4
-rw-r--r--app/scenes/scenes.rb1
-rw-r--r--app/systems/cleanup_bullets.rb11
-rw-r--r--app/systems/start_game.rb1
6 files changed, 18 insertions, 2 deletions
diff --git a/app/components/singleton_bullet.rb b/app/components/singleton_bullet.rb
new file mode 100644
index 0000000..c25f827
--- /dev/null
+++ b/app/components/singleton_bullet.rb
@@ -0,0 +1,2 @@
+FF::Cmp.new('SingletonBullet', singleton: true)
+FF::Cmp::SingletonBullet.new
diff --git a/app/factories/bullet.rb b/app/factories/bullet.rb
index 50a68c0..efad44f 100644
--- a/app/factories/bullet.rb
+++ b/app/factories/bullet.rb
@@ -12,6 +12,7 @@ class Factory
FF::Cmp::Hp.new(health: 1),
FF::Cmp::Team.new,
FF::Cmp::CollisionDamage.new(damage: damage),
+ FF::Cmp::SingletonBullet[0],
)
end
end
diff --git a/app/main.rb b/app/main.rb
index f4feee6..8a447d9 100644
--- a/app/main.rb
+++ b/app/main.rb
@@ -15,6 +15,7 @@ require 'app/components/rules/minimum_speed.rb'
require 'app/components/rules/decay_speed.rb'
require 'app/components/debug/singleton_debug_vector_arrow.rb'
require 'app/components/singleton_camera.rb'
+require 'app/components/singleton_bullet.rb'
require 'app/components/stats/collision_damage.rb'
require 'app/components/stats/hp.rb'
require 'app/components/hitcircle.rb'
@@ -44,8 +45,7 @@ require 'app/systems/death.rb'
require 'app/systems/player_weapon.rb'
require 'app/systems/move_camera.rb'
require 'app/systems/rules/minimum_speed.rb'
-
-
+require 'app/systems/cleanup_bullets.rb'
require 'app/factories/bullet.rb'
require 'app/factories/ships/osprey.rb'
diff --git a/app/scenes/scenes.rb b/app/scenes/scenes.rb
index 5cbcdea..3d11802 100644
--- a/app/scenes/scenes.rb
+++ b/app/scenes/scenes.rb
@@ -1,6 +1,7 @@
FF::Scn.new('BoidRules')
FF::Scn.new('Debug')
FF::Scn.new('Camera')
+FF::Scn.new('Cleanup')
FF::Stg.add(
FF::Scn.new('TitleScreen'),
FF::Scn.new('Render'),
diff --git a/app/systems/cleanup_bullets.rb b/app/systems/cleanup_bullets.rb
new file mode 100644
index 0000000..7055de4
--- /dev/null
+++ b/app/systems/cleanup_bullets.rb
@@ -0,0 +1,11 @@
+FF::Scn::Cleanup.add(
+ FF::Sys.new('CleanupBullets', priority: 99) do
+ FF::Cmp::SingletonBullet[0].entities.each do |ent|
+ sprite = ent.components[FF::Cmp::Sprite][0].props
+ hp = ent.components[FF::Cmp::Hp][0]
+ if sprite.x < 0 or sprite.x > $gtk.args.grid.w or sprite.y < 0 or sprite.y > $gtk.args.grid.h
+ hp.health = -1
+ end
+ end
+ end
+)
diff --git a/app/systems/start_game.rb b/app/systems/start_game.rb
index 51f26d4..e329d1d 100644
--- a/app/systems/start_game.rb
+++ b/app/systems/start_game.rb
@@ -53,6 +53,7 @@ FF::Sys.new('StartGame', priority: 50 ) do
FF::Stg.add(
FF::Scn::BoidRules,
FF::Scn::Camera,
+ FF::Scn::Cleanup,
FF::Scn::Debug,
)