summaryrefslogtreecommitdiffhomepage
path: root/run.rb
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-08-09 05:17:42 -0400
committerrealtradam <[email protected]>2021-08-09 05:17:42 -0400
commit4e909c6b44794b76ef3a98c032ea90204b673f85 (patch)
tree79cc49469447edf61ad835f61279bf48de51a61f /run.rb
parent4401e68464d1d5932daec84e41aeb7b4a88c831e (diff)
downloadruboids-4e909c6b44794b76ef3a98c032ea90204b673f85.tar.gz
ruboids-4e909c6b44794b76ef3a98c032ea90204b673f85.zip
cohesion and seperation
Diffstat (limited to 'run.rb')
-rw-r--r--run.rb74
1 files changed, 74 insertions, 0 deletions
diff --git a/run.rb b/run.rb
index e69de29..bfce180 100644
--- a/run.rb
+++ b/run.rb
@@ -0,0 +1,74 @@
+require 'ruby2d'
+require 'ruby2d/camera'
+require 'felflame'
+
+Dir[File.join(__dir__, 'lib/**', '*.rb')].sort.each { |file| require file }
+#FF::Scn::BoidCalculations.remove FF::Sys::Cohesion
+FF::Stg.remove FF::Scn::BoidCalculations
+
+class GameWindow < Ruby2D::Window
+ def initialize
+ super
+ #Camera.x = 10
+ #Camera.y = 10
+ randspot = ((-720 / 2)..(720/2)).to_a
+ @ent = FF::Ent.new(
+ FF::Cmp::Boids.new(x: randspot.sample, y:randspot.sample),
+ FF::Cmp::BoidVisuals.new(
+ obj: Camera::Circle.new(
+ color: [0.86,1.0,0.96,1],
+ radius: 7,
+ sectors: 10
+ ),
+ vect: Camera::Line.new(
+ width: 7,
+ color: 'red',
+ z: -1
+ )
+ )
+ )
+ 5.times do
+ FF::Ent.new(
+ FF::Cmp::Boids.new(x: randspot.sample, y:randspot.sample),
+ FF::Cmp::BoidVisuals.new(
+ obj: Camera::Circle.new(
+ color: [0.86,0.57,0.96,1],
+ radius: 7,
+ sectors: 10
+ ),
+ vect: Camera::Line.new(
+ width: 7,
+ color: 'red',
+ z: -1
+ )
+ )
+ )
+ end
+ end
+
+ def update
+ FF::Stage.call
+ Camera.y += 5 if key_held('s')
+ Camera.y -= 5 if key_held('w')
+ Camera.x += 5 if key_held('d')
+ Camera.x -= 5 if key_held('a')
+ Camera.zoom *= 1.1 if key_held('z')
+ Camera.zoom /= 1.1 if key_held('x')
+ if key_held('space')
+ FF::Scn::BoidCalculations.call #if key_held('space')
+ puts "X: #{@ent.components[FF::Cmp::Boids].first.x}"
+ puts "Y: #{@ent.components[FF::Cmp::Boids].first.y}"
+ puts "VX:#{@ent.components[FF::Cmp::Boids].first.vx}"
+ puts "VY:#{@ent.components[FF::Cmp::Boids].first.vy}"
+ end
+ end
+
+ def render
+ end
+end
+
+
+gamewindow = GameWindow.new
+set(title: "Ruboids", width: 1280, height: 720, resizable: true)
+gamewindow.set(title: "Ruboids", width: 1280, height: 720, resizable: true)
+gamewindow.show