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
|
Rl = Raylib
module Raylib
class Rectangle
def draw(color: Rl::Color.new(255,255,255,255))
self._draw(color)
end
def draw_lines(line_thick: 1, color: Rl::Color.new(255,255,255,255))
self._draw_lines(line_thick, color)
end
end
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: Rl::Color.new(255,255,255,255))
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: 0, scale: 1, tint: Rl::Color.new(255,255,255,255))
self._draw_texture_ex(texture, pos, rotation, scale, tint)
end
def draw_texture_pro(texture:, source_rec:, dest_rec:, origin: Rl::Vector.new(0,0), rotation: 0, tint: Rl::Color.new(255,255,255,255))
self._draw_texture_pro(texture, source_rec, dest_rec, origin, rotation, tint)
end
def keys_pressed
if self.data_keys_pressed
return self.data_keys_pressed
end
self.data_keys_pressed = []
key = self._next_key_pressed
while key != 0
self.data_keys_pressed.push key
key = self._next_key_pressed
end
self.data_keys_pressed
end
def scissor_mode(x: x, y: y, width: width, height: height, &block)
self.begin_scissor_mode(x, y, width, height)
yield
self.end_scissor_mode
end
def draw(clear_color: nil, &block)
self.clear_background(clear_color) if clear_color
self.begin_drawing
yield
self.end_drawing
end
end
end
|