summaryrefslogtreecommitdiffhomepage
path: root/app/systems
diff options
context:
space:
mode:
Diffstat (limited to 'app/systems')
-rw-r--r--app/systems/collision_damage.rb14
-rw-r--r--app/systems/death.rb20
-rw-r--r--app/systems/start_game.rb15
3 files changed, 36 insertions, 13 deletions
diff --git a/app/systems/collision_damage.rb b/app/systems/collision_damage.rb
new file mode 100644
index 0000000..9e47c0c
--- /dev/null
+++ b/app/systems/collision_damage.rb
@@ -0,0 +1,14 @@
+FF::Scn::BoidRules.add(
+ FF::Sys.new("CollisionDamage", priority: 65) do
+ FF::Cmp::Hitcircle.each do |hitcircle_self|
+ boid_self = hitcircle_self.entities[0].components[FF::Cmp::Boid][0]
+ FF::Cmp::Hitcircle.each do |hitcircle_target|
+ next if hitcircle_self == hitcircle_target
+ boid_target = hitcircle_target.entities[0].components[FF::Cmp::Boid][0]
+ if Math.sqrt(((boid_self.x - boid_target.x) ** 2) + ((boid_self.y - boid_target.y) ** 2)) < (hitcircle_target.r + hitcircle_self.r)
+ hitcircle_target.entities[0].components[FF::Cmp::Hp][0].health -= hitcircle_self.entities[0].components[FF::Cmp::CollisionDamage][0].damage
+ end
+ end
+ end
+ end
+)
diff --git a/app/systems/death.rb b/app/systems/death.rb
new file mode 100644
index 0000000..d9cd792
--- /dev/null
+++ b/app/systems/death.rb
@@ -0,0 +1,20 @@
+FF::Scn::BoidRules.add(
+ FF::Sys.new("Death", priority: 200) do
+ FF::Cmp::Hp.each do |hp|
+ if hp.health <= 0
+ component_hash = hp.entities[0].components.clone
+ component_hash.each_pair do |manager, manager_array|
+ next if manager.equal?(FF::Cmp::SingletonCamera)
+ next if manager.equal?(FF::Cmp::Hp)
+ next if manager.equal?(FF::Cmp::DebugVectorArrow)
+ manager_array.each do |component|
+ # unless singleton
+ component.delete
+ end
+ end
+ hp.entities[0].delete
+ hp.delete
+ end
+ end
+ end
+)
diff --git a/app/systems/start_game.rb b/app/systems/start_game.rb
index cb29092..b5a832b 100644
--- a/app/systems/start_game.rb
+++ b/app/systems/start_game.rb
@@ -17,19 +17,8 @@ FF::Sys.new('StartGame', priority: 50 ) do
]
position_range = (100..700).to_a
- 25.times do |pos|
- sprite = FF::Cmp::Sprite.new
- sprite.props[:path] = 'sprites/kenny/Ships/ship_0011.png'
- FF::Ent.new(
- FF::Cmp::Boid.new(x: position_range.sample, y: position_range.sample, vx: 25, vy: 25, w: sprite.props[:w], h: sprite.props[:h]),
- sprite,
- FF::Cmp::BoidBounds.new(strength: 1),
- FF::Cmp::BoidsAlignment.new(strength: 1),
- FF::Cmp::BoidsSeparation.new(distance: 150, strength: 0.01),
- FF::Cmp::BoidsCohesion.new(strength: 100),
- debug_arrow,
- FF::Cmp::SingletonCamera[0],
- )
+ 5.times do |pos|
+ Factory::Osprey.new(x: position_range.sample, y: position_range.sample)
end
FF::Stg.add(