Class: Reight::App
- Inherits:
-
Object
show all
- Defined in:
- lib/reight/app.rb
Defined Under Namespace
Classes: Chips
Constant Summary
collapse
- SCREEN_WIDTH =
400
- SCREEN_HEIGHT =
224
- SPACE =
6
- BUTTON_SIZE =
12
- INDEX_SIZE =
36
- NAVIGATOR_HEIGHT =
BUTTON_SIZE + 2
- CHIPS_WIDTH =
128
- PALETTE_COLORS =
%w[
#00000000 #742f29 #ab5236 #f18459 #f7cca9 #ee044e #b8023f #7e2553
#452d32 #5f574f #a28879 #c2c3c7 #fdf1e8 #f6acc5 #f277a8 #e40dab
#1d2c53 #3363b0 #42a5a1 #56adff #64dff6 #bd9adf #83759c #644788
#1e5359 #2d8750 #3eb250 #4fe436 #95f041 #f8ec27 #f3a207 #e26b02
]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(project) ⇒ App
Returns a new instance of App.
22
23
24
25
|
# File 'lib/reight/app.rb', line 22
def initialize(project)
@project = project
@active = false
end
|
Instance Attribute Details
#project ⇒ Object
Returns the value of attribute project.
27
28
29
|
# File 'lib/reight/app.rb', line 27
def project
@project
end
|
Instance Method Details
#activated ⇒ Object
71
72
73
74
75
|
# File 'lib/reight/app.rb', line 71
def activated()
add_world world if world
@setup ||= true.tap {setup}
@active = true
end
|
#active? ⇒ Boolean
46
47
48
|
# File 'lib/reight/app.rb', line 46
def active?()
@active
end
|
#deactivated ⇒ Object
77
78
79
80
|
# File 'lib/reight/app.rb', line 77
def deactivated()
@active = false
remove_world world if world
end
|
#double_clicked ⇒ Object
108
|
# File 'lib/reight/app.rb', line 108
def double_clicked() = nil
|
#draw ⇒ Object
85
86
87
|
# File 'lib/reight/app.rb', line 85
def draw()
navigator.draw
end
|
#flash ⇒ Object
33
34
35
|
# File 'lib/reight/app.rb', line 33
def flash(...)
navigator.flash(...) if history.enabled?
end
|
#group(*buttons) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/reight/app.rb', line 37
def group(*buttons)
buttons.each.with_index do |button, index|
button.clicked do
buttons.each.with_index {|b, i| b.active = i == index}
end
end
buttons
end
|
#history ⇒ Object
54
55
56
|
# File 'lib/reight/app.rb', line 54
def history()
@history ||= Reight::History.new
end
|
#icon(xi, yi, size) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/reight/app.rb', line 62
def icon(xi, yi, size)
(@icon ||= {})[[xi, yi, size]] ||= createGraphics(size, size).tap do |g|
g.beginDraw do
g.copy r8.icons, xi * size, yi * size, size, size, 0, 0, size, size
end
end
end
|
#inspect ⇒ Object
def cut( flash: true) = nil def copy( flash: true) = nil def paste(flash: true) = nil
122
123
124
|
# File 'lib/reight/app.rb', line 122
def inspect()
"#<#{self.class.name}:0x#{object_id}>"
end
|
#key_pressed ⇒ Object
89
90
91
92
|
# File 'lib/reight/app.rb', line 89
def key_pressed()
navigator.key_pressed
pressing_keys.add key_code
end
|
#key_released ⇒ Object
94
95
96
|
# File 'lib/reight/app.rb', line 94
def key_released()
pressing_keys.delete key_code
end
|
#key_typed ⇒ Object
102
|
# File 'lib/reight/app.rb', line 102
def key_typed() = nil
|
#label ⇒ Object
29
30
31
|
# File 'lib/reight/app.rb', line 29
def label()
self.class.name.split('::').last.gsub(/([a-z])([A-Z])/) {"#{$1} #{$2}"}
end
|
#mouse_clicked ⇒ Object
107
|
# File 'lib/reight/app.rb', line 107
def mouse_clicked() = nil
|
#mouse_dragged ⇒ Object
106
|
# File 'lib/reight/app.rb', line 106
def mouse_dragged() = nil
|
#mouse_moved ⇒ Object
105
|
# File 'lib/reight/app.rb', line 105
def mouse_moved() = nil
|
#mouse_pressed ⇒ Object
103
|
# File 'lib/reight/app.rb', line 103
def mouse_pressed() = nil
|
#mouse_released ⇒ Object
104
|
# File 'lib/reight/app.rb', line 104
def mouse_released() = nil
|
#mouse_wheel ⇒ Object
109
|
# File 'lib/reight/app.rb', line 109
def mouse_wheel() = nil
|
#pressing?(key) ⇒ Boolean
50
51
52
|
# File 'lib/reight/app.rb', line 50
def pressing?(key)
pressing_keys.include? key
end
|
#setup ⇒ Object
82
83
|
# File 'lib/reight/app.rb', line 82
def setup()
end
|
#sprites ⇒ Object
58
59
60
|
# File 'lib/reight/app.rb', line 58
def sprites()
navigator.sprites
end
|
#touch_ended ⇒ Object
111
|
# File 'lib/reight/app.rb', line 111
def touch_ended() = nil
|
#touch_moved ⇒ Object
112
|
# File 'lib/reight/app.rb', line 112
def touch_moved() = nil
|
#touch_started ⇒ Object
110
|
# File 'lib/reight/app.rb', line 110
def touch_started() = nil
|
#window_moved ⇒ Object
113
|
# File 'lib/reight/app.rb', line 113
def window_moved() = nil
|
#window_resized ⇒ Object
98
99
100
|
# File 'lib/reight/app.rb', line 98
def window_resized()
navigator.window_resized
end
|