summaryrefslogtreecommitdiffhomepage
path: root/app/tick.rb
blob: 20ff3e912aca40ae4ae523070bd9aaf95ba0270c (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
75
76
77
78
79
80
81
82
83
84
85

#FF::Cmp::Boid.new(x: position_range.sample, y: position_range.sample, vx: 25, vy: 25, w: sprite.props[:w], h: sprite.props[:h]),
#FF::Cmp::SingletonCamera[0],

#@pause = false
@camera = FF::Cmp::SingletonCamera[0]
@scatter = false
@target = true
@timer = 0
FF::Sys::InitTitleScreen.call
def tick args
  #puts @timer
  @timer += 1
  if @timer >= 100 && !FF::Cmp::SingletonTitle[0].title_screen
    @timer -= 100
    #puts "scatter: #{@scatter}"
    #puts "target: #{@target}"
    @scatter = !@scatter
    if @scatter
      FF::Sys::Scatter.call
    elsif @target
      @target = false
      FF::Sys::Rejoin.call
    else
      @target = true
      FF::Sys::TargetPlayer.call
    end
  end

  args.outputs.background_color = [0,0,0]
  args.outputs.solids << [-10_000, -10_000, 20_000, 20_000, 223, 246, 245]

  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)
    @camera.y += (Math.sin([email protected] * (Math::PI / 180.0)) * 5)
  end
  if args.inputs.keyboard.keys[:down_or_held].include?(:a)
    @camera.x += (Math.cos([email protected] * (Math::PI / 180.0)) * -5)
    @camera.y += (Math.sin([email protected] * (Math::PI / 180.0)) * -5)
  end
  if args.inputs.keyboard.keys[:down_or_held].include?(:w)
    #@camera.y += 5
    @camera.x -= (Math.sin([email protected] * (Math::PI / 180.0)) * 5)
    @camera.y += (Math.cos([email protected] * (Math::PI / 180.0)) * 5)
  end
  if args.inputs.keyboard.keys[:down_or_held].include?(:s)
    #@camera.y -= 5
    @camera.x -= (Math.sin([email protected] * (Math::PI / 180.0)) * -5)
    @camera.y += (Math.cos([email protected] * (Math::PI / 180.0)) * -5)
  end
  if args.inputs.keyboard.keys[:down_or_held].include?(:q)
    @camera.angle += 3
  end
  if args.inputs.keyboard.keys[:down_or_held].include?(:e)
    @camera.angle -= 3
  end
  if args.inputs.keyboard.keys[:down_or_held].include?(:z)
    @camera.zoom *= 1.05
  end
  if args.inputs.keyboard.keys[:down_or_held].include?(:x)
    @camera.zoom *= 0.95
  end

  # Pausing
  if args.inputs.keyboard.keys[:down].include?(:right)
    FF::Scn::BoidRules.call
  end
  if args.inputs.keyboard.keys[:down].include?(:space)
    if @pause
      FF::Stg.add FF::Scn::BoidRules
      @pause = false
    else
      FF::Stg.remove FF::Scn::BoidRules
      @pause = true
    end
  end
end