summaryrefslogtreecommitdiffhomepage
path: root/game/main.rb
blob: 0721741a67a1ce8e2e514ac80c0facb554c73803 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
text = "Our poggies game engine :^)"

Rl.init_window(600, 600, text)

Rl.target_fps = 60
color = Rl::Color.new(200,50,50,255)
white = Rl::Color.new(255,255,255,255)
color2 = Rl::Color.new(200,15,15,255)

rect1 = Rl::Rectangle.new(50,50,10,10)
rect2 = Rl::Rectangle.new(100,50,10,10)
circ1 = Rl::Circle.new(100,100,10)
circ2 = Rl::Circle.new(100,50,10)

puts "rect1: #{rect1.x} #{rect1.y} #{rect1.w} #{rect1.h}"
puts "circ1: #{circ1.x} #{circ1.y} #{circ1.radius}"

puts "false: #{rect1.collide_with_rect? rect2}" # no
puts "true: #{rect1.collide_with_rect? rect1}" # ya

puts "false: #{circ1.collide_with_rect? rect1}" # no
puts "true: #{circ2.collide_with_rect? rect2}" # ya

puts "true: #{rect2.collide_with_circle? circ2}" # ya

puts "false: #{circ1.collide_with_circle? circ2}" # no
puts "true: #{circ1.collide_with_circle? circ1}" # ya

pause_champ = Rl::Texture.new("./assets/PauseChamp.png")
puts "#{pause_champ.w} #{pause_champ.h}"

FECS::Cmp.new('Yep', x: 3)

a = FECS::Cmp::Yep.new

puts "A: #{a.x}"

y = 10
spaceing = 25
font_size = 30

Rl.while_window_open do
  result_x = (Math.cos(Rl.time*2) * 100) + 250
  result_y = (Math.sin(Rl.time*2) * 100) + 250

  unless Rl.keys_pressed.empty?
    puts Rl.keys_pressed.to_s
  end

  Rl.draw(clear_color: white) do

    Rl.scissor_mode(x: Rl.mouse_x - 50, y: Rl.mouse_y - 50, width: 100, height: 100) do
      if Rl.mouse_button_up? 0
        # Draw moving pausechamp face
        Rl.draw_texture(
          texture: pause_champ,
          x: result_x - 100,
          y: result_y + 200 - 140
        )
      end
    end

    if Rl.key_down? 72
      pause_champ.w += 10
      pause_champ.h += 10
    end

    if Rl.key_down? 71
      pause_champ.w += 10
      pause_champ.h += 10
    end

    Rl.draw_text(
      text: "mouse wheel:#{Rl.mouse_wheel}",
      x: 350,
      y: y + (spaceing*2),
      font_size: font_size,
      color: color
    )

    Rl.draw_text(
      text: "mouse x: #{Rl.mouse_x}",
      x: 350,
      y: y,
      font_size: font_size,
      color: color
    )

    Rl.draw_text(
      text: "mouse y: #{Rl.mouse_y}",
      x: 350,
      y: y + spaceing,
      font_size: font_size,
      color: color
    )

    # Draw moving text
    Rl.draw_text(
      text: text,
      x: result_x - 120,
      y: result_y + 200,
      font_size: 25,
      color: color
    )

    # Draw Fps
    Rl.draw_text(
      text: "FPS: #{Rl.fps.to_s}",
      x: 10,
      y: y,
      font_size: font_size,
      color: color
    )

    # Draw Frametime
    Rl.draw_text(
      text: "Frametime: #{"%.4f" % Rl.frame_time}",
      x: 10,
      y: y + spaceing,
      font_size: font_size,
      color: color
    )

    # Draw Elapse Time
    Rl.draw_text(
      text: "Elapsed Time: #{"%.2f" % Rl.time}",
      x: 10, y: y + (spaceing * 2), font_size: font_size, color: color
    )

  end
end