summaryrefslogtreecommitdiffhomepage
path: root/run.rb
blob: bfce18040c3eabc5b6bd88c9510f54c88479c7cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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