summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/components/hitcircle.rb3
-rw-r--r--app/components/stats/collision_damage.rb2
-rw-r--r--app/components/stats/hp.rb2
-rw-r--r--app/components/teams/enemy_team.rb1
-rw-r--r--app/components/teams/player_team.rb1
-rw-r--r--app/factories/bullet.rb17
-rw-r--r--app/factories/ships/osprey.rb22
-rw-r--r--app/main.rb8
-rw-r--r--app/systems/collision_damage.rb14
-rw-r--r--app/systems/death.rb20
-rw-r--r--app/systems/start_game.rb15
-rw-r--r--app/tick.rb5
-rw-r--r--sprites/kenny/Ships/Bunting.png (renamed from sprites/kenny/Ships/ship_0010.png)bin222 -> 222 bytes
-rw-r--r--sprites/kenny/Ships/BuntingGrey.png (renamed from sprites/kenny/Ships/ship_0022.png)bin222 -> 222 bytes
-rw-r--r--sprites/kenny/Ships/Falcon.png (renamed from sprites/kenny/Ships/ship_0000.png)bin296 -> 296 bytes
-rw-r--r--sprites/kenny/Ships/FalconGrey.png (renamed from sprites/kenny/Ships/ship_0012.png)bin296 -> 296 bytes
-rw-r--r--sprites/kenny/Ships/Grosbeak.png (renamed from sprites/kenny/Ships/ship_0001.png)bin279 -> 279 bytes
-rw-r--r--sprites/kenny/Ships/GrosbeakGrey.png (renamed from sprites/kenny/Ships/ship_0013.png)bin279 -> 279 bytes
-rw-r--r--sprites/kenny/Ships/Longspur.png (renamed from sprites/kenny/Ships/ship_0008.png)bin221 -> 221 bytes
-rw-r--r--sprites/kenny/Ships/LongspurGrey.png (renamed from sprites/kenny/Ships/ship_0020.png)bin221 -> 221 bytes
-rw-r--r--sprites/kenny/Ships/Magpie.png (renamed from sprites/kenny/Ships/ship_0004.png)bin251 -> 251 bytes
-rw-r--r--sprites/kenny/Ships/MagpieGrey.png (renamed from sprites/kenny/Ships/ship_0016.png)bin251 -> 251 bytes
-rw-r--r--sprites/kenny/Ships/Nighthawk.png (renamed from sprites/kenny/Ships/ship_0006.png)bin238 -> 238 bytes
-rw-r--r--sprites/kenny/Ships/NighthawkGrey.png (renamed from sprites/kenny/Ships/ship_0018.png)bin238 -> 238 bytes
-rw-r--r--sprites/kenny/Ships/Nutcracker.png (renamed from sprites/kenny/Ships/ship_0007.png)bin270 -> 270 bytes
-rw-r--r--sprites/kenny/Ships/NutcrackerGrey.png (renamed from sprites/kenny/Ships/ship_0019.png)bin270 -> 270 bytes
-rw-r--r--sprites/kenny/Ships/Osprey.png (renamed from sprites/kenny/Ships/ship_0002.png)bin300 -> 300 bytes
-rw-r--r--sprites/kenny/Ships/OspreyGrey.png (renamed from sprites/kenny/Ships/ship_0014.png)bin300 -> 300 bytes
-rw-r--r--sprites/kenny/Ships/Pintail.png (renamed from sprites/kenny/Ships/ship_0003.png)bin286 -> 286 bytes
-rw-r--r--sprites/kenny/Ships/PintailGrey.png (renamed from sprites/kenny/Ships/ship_0015.png)bin286 -> 286 bytes
-rw-r--r--sprites/kenny/Ships/Warbler.png (renamed from sprites/kenny/Ships/ship_0011.png)bin237 -> 237 bytes
-rw-r--r--sprites/kenny/Ships/WarblerGrey.png (renamed from sprites/kenny/Ships/ship_0023.png)bin237 -> 237 bytes
-rw-r--r--sprites/kenny/Ships/Waxwing.png (renamed from sprites/kenny/Ships/ship_0005.png)bin226 -> 226 bytes
-rw-r--r--sprites/kenny/Ships/WaxwingGrey.png (renamed from sprites/kenny/Ships/ship_0017.png)bin226 -> 226 bytes
-rw-r--r--sprites/kenny/Ships/Weebill.png (renamed from sprites/kenny/Ships/ship_0009.png)bin236 -> 236 bytes
-rw-r--r--sprites/kenny/Ships/WeebillGrey.png (renamed from sprites/kenny/Ships/ship_0021.png)bin236 -> 236 bytes
36 files changed, 97 insertions, 13 deletions
diff --git a/app/components/hitcircle.rb b/app/components/hitcircle.rb
new file mode 100644
index 0000000..7f60f01
--- /dev/null
+++ b/app/components/hitcircle.rb
@@ -0,0 +1,3 @@
+FF::Cmp.new('Hitcircle',
+ x: 0, y: 0,
+ r: 50)
diff --git a/app/components/stats/collision_damage.rb b/app/components/stats/collision_damage.rb
new file mode 100644
index 0000000..f915039
--- /dev/null
+++ b/app/components/stats/collision_damage.rb
@@ -0,0 +1,2 @@
+FF::Cmp.new('CollisionDamage',
+ damage: 10)
diff --git a/app/components/stats/hp.rb b/app/components/stats/hp.rb
new file mode 100644
index 0000000..1a6f996
--- /dev/null
+++ b/app/components/stats/hp.rb
@@ -0,0 +1,2 @@
+FF::Cmp.new('Hp',
+ health: 100)
diff --git a/app/components/teams/enemy_team.rb b/app/components/teams/enemy_team.rb
new file mode 100644
index 0000000..9d4e0d1
--- /dev/null
+++ b/app/components/teams/enemy_team.rb
@@ -0,0 +1 @@
+FF::Cmp.new('EnemyTeam')
diff --git a/app/components/teams/player_team.rb b/app/components/teams/player_team.rb
new file mode 100644
index 0000000..6e1b126
--- /dev/null
+++ b/app/components/teams/player_team.rb
@@ -0,0 +1 @@
+FF::Cmp.new('PlayerTeam')
diff --git a/app/factories/bullet.rb b/app/factories/bullet.rb
new file mode 100644
index 0000000..160613c
--- /dev/null
+++ b/app/factories/bullet.rb
@@ -0,0 +1,17 @@
+class Factory
+ class Bullet
+ def self.new(damage: 10, x:, y:)
+ puts 'new ent created'
+ sprite = FF::Cmp::Sprite.new
+ sprite.props[:path] = 'sprites/kenny/Tiles/tile_0000.png'
+ FF::Ent.new(
+ sprite,
+ FF::Cmp::Boid.new(x: x, y: y, vx: 10, w: 16, h: 16),
+ FF::Cmp::SingletonCamera[0],
+ FF::Cmp::Hitcircle.new(r: 10),
+ FF::Cmp::Hp.new(health: 1),
+ FF::Cmp::CollisionDamage.new(damage: damage),
+ )
+ end
+ end
+end
diff --git a/app/factories/ships/osprey.rb b/app/factories/ships/osprey.rb
new file mode 100644
index 0000000..1f57cb1
--- /dev/null
+++ b/app/factories/ships/osprey.rb
@@ -0,0 +1,22 @@
+class Factory
+ class Osprey
+ def self.new(x: x, y: y)
+ sprite = FF::Cmp::Sprite.new
+ sprite.props[:path] = 'sprites/kenny/Ships/Osprey.png'
+ FF::Ent.new(
+ FF::Cmp::Boid.new(x: x, y: y, vx: 25, vy: 25, w: 32, h: 32),
+ sprite,
+ FF::Cmp::BoidBounds.new(strength: 0.6),
+ FF::Cmp::BoidsAlignment.new(strength: 1),
+ FF::Cmp::BoidsSeparation.new(distance: 150, strength: 0.001),
+ FF::Cmp::BoidsCohesion.new(strength: 10000),
+ FF::Cmp::Hp.new(health: 100),
+ FF::Cmp::CollisionDamage.new(damage: 100),
+ FF::Cmp::Hitcircle.new(r: 12),
+ FF::Cmp::DebugVectorArrow[0],
+ FF::Cmp::SingletonCamera[0],
+ )
+ end
+ end
+end
+
diff --git a/app/main.rb b/app/main.rb
index 5c4797e..4c2a54e 100644
--- a/app/main.rb
+++ b/app/main.rb
@@ -12,6 +12,9 @@ require 'app/components/rules/alignment.rb'
require 'app/components/rules/separation.rb'
require 'app/components/debug/debug_vector_arrow.rb'
require 'app/components/camera.rb'
+require 'app/components/stats/collision_damage.rb'
+require 'app/components/stats/hp.rb'
+require 'app/components/hitcircle.rb'
require 'app/systems/init_title_screen.rb'
require 'app/systems/title_screen.rb'
@@ -26,5 +29,10 @@ require 'app/systems/rules/separation.rb'
require 'app/systems/rules/reset_change_vector.rb'
require 'app/systems/debug/debug_render_vector_arrow.rb'
require 'app/systems/camera.rb'
+require 'app/systems/collision_damage.rb'
+require 'app/systems/death.rb'
+
+require 'app/factories/bullet.rb'
+require 'app/factories/ships/osprey.rb'
require 'app/tick.rb'
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(
diff --git a/app/tick.rb b/app/tick.rb
index c8c8f83..1205fd6 100644
--- a/app/tick.rb
+++ b/app/tick.rb
@@ -10,6 +10,11 @@ def tick args
args.outputs.background_color = [0,0,0]
FelFlame::Stage.call
+ # Spawn Bullet
+ if args.inputs.keyboard.keys[:down].include?(:b)
+ Factory::Bullet.new(x: @camera.x, y: @camera.y)
+ end
+
# Moving Camera
if args.inputs.keyboard.keys[:down_or_held].include?(:d)
@camera.x += (Math.cos([email protected] * (Math::PI / 180.0)) * 5)
diff --git a/sprites/kenny/Ships/ship_0010.png b/sprites/kenny/Ships/Bunting.png
index 2b9ed7b..2b9ed7b 100644
--- a/sprites/kenny/Ships/ship_0010.png
+++ b/sprites/kenny/Ships/Bunting.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0022.png b/sprites/kenny/Ships/BuntingGrey.png
index 9cbfad5..9cbfad5 100644
--- a/sprites/kenny/Ships/ship_0022.png
+++ b/sprites/kenny/Ships/BuntingGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0000.png b/sprites/kenny/Ships/Falcon.png
index b1b8a64..b1b8a64 100644
--- a/sprites/kenny/Ships/ship_0000.png
+++ b/sprites/kenny/Ships/Falcon.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0012.png b/sprites/kenny/Ships/FalconGrey.png
index a161479..a161479 100644
--- a/sprites/kenny/Ships/ship_0012.png
+++ b/sprites/kenny/Ships/FalconGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0001.png b/sprites/kenny/Ships/Grosbeak.png
index 7c79f4c..7c79f4c 100644
--- a/sprites/kenny/Ships/ship_0001.png
+++ b/sprites/kenny/Ships/Grosbeak.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0013.png b/sprites/kenny/Ships/GrosbeakGrey.png
index 0fce519..0fce519 100644
--- a/sprites/kenny/Ships/ship_0013.png
+++ b/sprites/kenny/Ships/GrosbeakGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0008.png b/sprites/kenny/Ships/Longspur.png
index 8ccccbf..8ccccbf 100644
--- a/sprites/kenny/Ships/ship_0008.png
+++ b/sprites/kenny/Ships/Longspur.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0020.png b/sprites/kenny/Ships/LongspurGrey.png
index f2b6334..f2b6334 100644
--- a/sprites/kenny/Ships/ship_0020.png
+++ b/sprites/kenny/Ships/LongspurGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0004.png b/sprites/kenny/Ships/Magpie.png
index 4c5dec1..4c5dec1 100644
--- a/sprites/kenny/Ships/ship_0004.png
+++ b/sprites/kenny/Ships/Magpie.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0016.png b/sprites/kenny/Ships/MagpieGrey.png
index e201d3f..e201d3f 100644
--- a/sprites/kenny/Ships/ship_0016.png
+++ b/sprites/kenny/Ships/MagpieGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0006.png b/sprites/kenny/Ships/Nighthawk.png
index 9a02dba..9a02dba 100644
--- a/sprites/kenny/Ships/ship_0006.png
+++ b/sprites/kenny/Ships/Nighthawk.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0018.png b/sprites/kenny/Ships/NighthawkGrey.png
index 26cd433..26cd433 100644
--- a/sprites/kenny/Ships/ship_0018.png
+++ b/sprites/kenny/Ships/NighthawkGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0007.png b/sprites/kenny/Ships/Nutcracker.png
index ac7ba5c..ac7ba5c 100644
--- a/sprites/kenny/Ships/ship_0007.png
+++ b/sprites/kenny/Ships/Nutcracker.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0019.png b/sprites/kenny/Ships/NutcrackerGrey.png
index 35c1f49..35c1f49 100644
--- a/sprites/kenny/Ships/ship_0019.png
+++ b/sprites/kenny/Ships/NutcrackerGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0002.png b/sprites/kenny/Ships/Osprey.png
index 649fa7c..649fa7c 100644
--- a/sprites/kenny/Ships/ship_0002.png
+++ b/sprites/kenny/Ships/Osprey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0014.png b/sprites/kenny/Ships/OspreyGrey.png
index 8747b09..8747b09 100644
--- a/sprites/kenny/Ships/ship_0014.png
+++ b/sprites/kenny/Ships/OspreyGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0003.png b/sprites/kenny/Ships/Pintail.png
index 02d3b79..02d3b79 100644
--- a/sprites/kenny/Ships/ship_0003.png
+++ b/sprites/kenny/Ships/Pintail.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0015.png b/sprites/kenny/Ships/PintailGrey.png
index d1a9c32..d1a9c32 100644
--- a/sprites/kenny/Ships/ship_0015.png
+++ b/sprites/kenny/Ships/PintailGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0011.png b/sprites/kenny/Ships/Warbler.png
index 327f745..327f745 100644
--- a/sprites/kenny/Ships/ship_0011.png
+++ b/sprites/kenny/Ships/Warbler.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0023.png b/sprites/kenny/Ships/WarblerGrey.png
index 6f251b5..6f251b5 100644
--- a/sprites/kenny/Ships/ship_0023.png
+++ b/sprites/kenny/Ships/WarblerGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0005.png b/sprites/kenny/Ships/Waxwing.png
index 076afbb..076afbb 100644
--- a/sprites/kenny/Ships/ship_0005.png
+++ b/sprites/kenny/Ships/Waxwing.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0017.png b/sprites/kenny/Ships/WaxwingGrey.png
index fc13379..fc13379 100644
--- a/sprites/kenny/Ships/ship_0017.png
+++ b/sprites/kenny/Ships/WaxwingGrey.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0009.png b/sprites/kenny/Ships/Weebill.png
index 5ef6075..5ef6075 100644
--- a/sprites/kenny/Ships/ship_0009.png
+++ b/sprites/kenny/Ships/Weebill.png
Binary files differ
diff --git a/sprites/kenny/Ships/ship_0021.png b/sprites/kenny/Ships/WeebillGrey.png
index e7acecd..e7acecd 100644
--- a/sprites/kenny/Ships/ship_0021.png
+++ b/sprites/kenny/Ships/WeebillGrey.png
Binary files differ