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
|
Rl = Raylib
module Raylib
class Circle
attr_accessor :vector
attr_accessor :radius
def initialize(x, y, radius)
self.vector = Vector2.new(x, y)
self.radius = radius
end
def x
self.vector.x
end
def y
self.vector.y
end
def x=(x)
self.vector.x = x
end
def y=(y)
self.vector.y = y
end
end
class << self
attr_accessor :defined_loop
attr_accessor :data_keys_pressed
def while_window_open(&block)
self.defined_loop = block
if Raylib.platform == 'desktop'
while !Raylib.window_should_close? do
self.main_loop
end
elsif Raylib.platform == 'web'
Raylib.emscripten_set_main_loop
end
end
def main_loop
self.data_keys_pressed = nil
self.defined_loop.call
end
def draw_text(text:, x:, y:, font_size:, color:)
self._draw_text(text, x, y, font_size, color)
end
def draw_texture(texture:, x:, y:, tint: Rl::Color.new(255,255,255,255))
self._draw_texture(texture, x, y, tint)
end
def draw_texture_ex(texture:, pos:, rotation:, scale:, tint: Rl::Color.new(255,255,255,255))
self._draw_texture_ex(texture, pos, rotation, scale, tint)
end
def draw_texture_pro(texture:, source:, dest:, origin:, rotation:, tint: Rl::Color.new(255,255,255,255))
self._draw_texture_pro(texture, source, dest, origin, rotation, tint)
end
def keys_pressed
if self.data_keys_pressed
return self.data_keys_pressed
end
self.data_keys_pressed = []
key = self._key_pressed
while key != 0
self.data_keys_pressed.push key
key = self._key_pressed
end
self.data_keys_pressed
end
end
end
|