-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneogame_0_4.rb
1259 lines (921 loc) · 23.3 KB
/
neogame_0_4.rb
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require 'gosu'
# NeoGame
# The next gen Ruby game framework
# By D3nX, ©2018
# Version pre-alpha 0.4
module Neogame
include Gosu
Vector2 = Struct.new(:x, :y)
Vector3 = Struct.new(:x, :y, :z)
Position = Struct.new(:x, :y)
Settings = Struct.new(
:width,
:height,
:fullscreen,
:title
)
def Neogame.initialize(window)
@@default_window = window
@@default_font = SpriteFont.new(window, SpriteFont::DEFAULT_FONT, 50)
end
def Neogame.default_font
return @@default_font
end
class Input
KB_LEFT = Gosu::KbLeft
KB_RIGHT = Gosu::KbRight
KB_UP = Gosu::KbUp
KB_DOWN = Gosu::KbDown
# Letters
KB_A = Gosu::KB_A
KB_B = Gosu::KB_B
KB_C = Gosu::KB_C
KB_D = Gosu::KB_D
KB_E = Gosu::KB_E
KB_F = Gosu::KB_F
KB_G = Gosu::KB_G
KB_H = Gosu::KB_H
KB_I = Gosu::KB_I
KB_J = Gosu::KB_J
KB_K = Gosu::KB_K
KB_L = Gosu::KB_L
KB_M = Gosu::KB_M
KB_N = Gosu::KB_N
KB_O = Gosu::KB_O
KB_P = Gosu::KB_P
KB_Q = Gosu::KB_Q
KB_R = Gosu::KB_R
KB_S = Gosu::KB_S
KB_T = Gosu::KB_T
KB_U = Gosu::KB_U
KB_V = Gosu::KB_V
KB_W = Gosu::KB_W
KB_X = Gosu::KB_X
KB_Y = Gosu::KB_Y
KB_Z = Gosu::KB_Z
# Number
KB_NUMPAD_0 = Gosu::KB_NUMPAD_0
KB_NUMPAD_1 = Gosu::KB_NUMPAD_1
KB_NUMPAD_2 = Gosu::KB_NUMPAD_2
KB_NUMPAD_3 = Gosu::KB_NUMPAD_3
KB_NUMPAD_4 = Gosu::KB_NUMPAD_4
KB_NUMPAD_5 = Gosu::KB_NUMPAD_5
KB_NUMPAD_6 = Gosu::KB_NUMPAD_6
KB_NUMPAD_7 = Gosu::KB_NUMPAD_7
KB_NUMPAD_8 = Gosu::KB_NUMPAD_8
KB_NUMPAD_9 = Gosu::KB_NUMPAD_9
# Other touch
KB_ENTER = Gosu::KB_ENTER
KB_RETURN = Gosu::KB_RETURN
KB_ESCAPE = Gosu::KB_ESCAPE
KB_BACKSPACE = Gosu::KB_BACKSPACE
KB_SPACE = Gosu::KbSpace
# Mouse
MS_LEFT = Gosu::MS_LEFT
MS_RIGHT = Gosu::MS_RIGHT
MS_MIDDLE = Gosu::MS_MIDDLE
MS_WHEEL_UP = Gosu::MS_WHEEL_UP
MS_WHEEL_DOWN = Gosu::MS_WHEEL_DOWN
def initialize
@key_released = {}
@key_pressed = {}
@mouse_released = {}
@mouse_pressed = {}
@button_released = {}
@button_pressed = {}
end
# Return if any key is down
def key_down?(key)
if key == MS_LEFT or key == MS_RIGHT or key == MS_MIDDLE or key == MS_WHEEL_UP or key == MS_WHEEL_DOWN
raise "NeoGame [ERROR]: Waiting for a keyboard input, not mouse input."
end
return true if Gosu::button_down?(key)
return false
end
def key_released?(key)
if key == MS_LEFT or key == MS_RIGHT or key == MS_MIDDLE or key == MS_WHEEL_UP or key == MS_WHEEL_DOWN
raise "NeoGame [ERROR]: Waiting for a keyboard input, not mouse input."
end
if !@key_released.include?(key)
@key_released[key] = 0
end
@key_released[key] = 1 if Gosu::button_down?(key) and @key_released[key] == 0
@key_released[key] = 2 if !Gosu::button_down?(key) and @key_released[key] == 1
if @key_released[key] == 2
return true
end
return false
end
def key_pressed?(key)
if key == MS_LEFT or key == MS_RIGHT or key == MS_MIDDLE or key == MS_WHEEL_UP or key == MS_WHEEL_DOWN
raise "NeoGame [ERROR]: Waiting for a keyboard input, not mouse input."
end
if !@key_pressed.include?(key)
@key_pressed[key] = 0
end
@key_pressed[key] = 1 if Gosu::button_down?(key) and @key_pressed[key] == 0
@key_pressed.delete(key) if !Gosu::button_down?(key) and @key_pressed[key] == 2
if @key_pressed[key] == 1
return true
end
return false
end
def mouse_down?(button)
if button == MS_LEFT or button == MS_RIGHT or button == MS_MIDDLE or button == MS_WHEEL_UP or button == MS_WHEEL_DOWN
return true if Gosu::button_down?(button)
return false
else
raise "NeoGame [ERROR]: Waiting for a mouse input, not keyboard input."
end
end
def mouse_released?(button)
if button == MS_LEFT or button == MS_RIGHT or button == MS_MIDDLE or button == MS_WHEEL_UP or button == MS_WHEEL_DOWN
if !@mouse_released.include?(button)
@mouse_released[button] = 0
end
@mouse_released[button] = 1 if Gosu::button_down?(button) and @mouse_released[button] == 0
@mouse_released[button] = 2 if !Gosu::button_down?(button) and @mouse_released[button] == 1
if @mouse_released[button] == 2
return true
end
return false
else
raise "NeoGame [ERROR]: Waiting for a mouse input, not keyboard input."
end
end
def mouse_pressed?(button)
if button == MS_LEFT or button == MS_RIGHT or button == MS_MIDDLE or button == MS_WHEEL_UP or button == MS_WHEEL_DOWN
if !@mouse_pressed.include?(button)
@mouse_pressed[button] = 0
end
@mouse_pressed[button] = 1 if Gosu::button_down?(button) and @mouse_pressed[button] == 0
@mouse_pressed.delete(button) if !Gosu::button_down?(button) and @mouse_pressed[button] == 2
if @mouse_pressed[button] == 1
return true
end
return false
else
raise "NeoGame [ERROR]: Waiting for a mouse input, not keyboard input."
end
end
def self.button_down?(button)
return Gosu::button_down?(button)
end
def button_released?(button)
if !@button_released.include?(button)
@button_released[button] = 0
end
@button_released[button] = 1 if Gosu::button_down?(button) and @button_released[button] == 0
@button_released[button] = 2 if !Gosu::button_down?(button) and @button_released[button] == 1
if @button_released[button] == 2
return true
end
return false
end
def button_pressed?(button)
if !@button_pressed.include?(button)
@button_pressed[button] = 0
end
@button_pressed[button] = 1 if Gosu::button_down?(button) and @button_pressed[button] == 0
@button_pressed.delete(button) if !Gosu::button_down?(button) and @button_pressed[button] == 2
if @button_pressed[button] == 1
return true
end
return false
end
private
def reset
# KEY
@key_released.each do |k, v|
if v == 2
@key_released.delete(k)
end
end
@key_pressed.each do |k, v|
if v == 1
@key_pressed[k] = 2
end
end
# MOUSE
@mouse_released.each do |k, v|
if v == 2
@mouse_released.delete(k)
end
end
@mouse_pressed.each do |k, v|
if v == 1
@mouse_pressed[k] = 2
end
end
# BUTTON
@button_released.each do |k, v|
if v == 2
@button_released.delete(k)
end
end
@button_pressed.each do |k, v|
if v == 1
@button_pressed[k] = 2
end
end
end
end
module Shapes
class Shape
attr_accessor :x, :y, :width, :height, :type, :color
end
class Rectangle < Shape
def initialize(x, y, width, height)
@x = x
@y = y
@type = "Rectangle"
@width = width
@height = height
@color = Gosu::Color::WHITE
end
def collides?(shape)
if !shape.is_a?(Shape)
raise "NeoGame [ERROR]: This is not a shape."
end
if shape.is_a? Rectangle
if shape.x > @x + @width or
shape.y > @y + @height or
shape.x + shape.width < @x or
shape.y + shape.height < @y then
return false
else
return true
end
else
dist_x = (shape.x - @x - @width / 2).abs
dist_y = (shape.y - @y - @height / 2).abs
if (dist_x > (@width/2 + shape.radius))
return false
end
if (dist_y > (@height/2 + shape.radius))
return false
end
if (dist_x <= (@width/2))
return true
end
if (dist_y <= (@height/2))
return true
end
dx=dist_x-@width/2;
dy=dist_y-@height/2;
return (dx*dx+dy*dy<=(shape.radius**2))
end
return false
end
def draw
Gosu.draw_rect(@x, @y, @width, @height, @color)
end
end
class Circle < Shape
attr_accessor :radius
def initialize(x, y, radius)
@x = x
@y = y
@type = "Circle"
@radius = radius
@color = Gosu::Color::WHITE
@points = []
end
def draw
for i in 0...360
dx = Math.cos(i * Math::PI / 180) * @radius;
dy = Math.sin(i * Math::PI / 180) * @radius;
Gosu.draw_line(@x + dx,
@y + dy,
@color,
@x + dx + 1,
@y + dy + 1,
@color,
0)
end
end
def resize(radius)
@radius = radius
end
def collides?(shape)
if !shape.is_a?(Shape)
raise "NeoGame [ERROR]: This is not a shape."
end
if shape.is_a? Circle
distance = (@x - shape.x)**2 + (@y - shape.y)**2
if (distance < (shape.radius + @radius)**2)
return true
else
return false
end
elsif shape.is_a? Rectangle
dist_x = (@x - shape.x - shape.width / 2).abs
dist_y = (@y - shape.y - shape.height / 2).abs
if (dist_x > (shape.width/2 + @radius))
return false
end
if (dist_y > (shape.height/2 + @radius))
return false
end
if (dist_x <= (shape.width/2))
return true
end
if (dist_y <= (shape.height/2))
return true
end
dx=dist_x-shape.width/2;
dy=dist_y-shape.height/2;
return (dx*dx+dy*dy<=(@radius**2))
end
return false
end
end
end
class Window < Gosu::Window
attr_accessor :settings
private
attr_accessor :game_input
attr_accessor :use_cursor
public
def initialize(settings)
# Send settings to the window
super settings.width, settings.height, settings.fullscreen
# Initialize neogame with the current window
Neogame.initialize(self)
StateManager.initialize(self)
ObjectManager.initialize
# And keep the settings for reading information
@settings = settings
# Set the title
self.caption = settings.title.to_s
# The input object
@game_input = Input.new()
# The class variables
@use_cursor = false
end
def run
show
end
def update; end
def draw; end
def input
return @game_input
end
def needs_cursor?
@use_cursor
end
private
def show
super
end
end
class Sprite
attr_accessor :x, :y, :z
attr_accessor :angle, :scale_x, :scale_y
attr_accessor :center_x, :center_y
attr_accessor :mirror_x, :mirror_y
attr_accessor :color
attr_accessor :path
def initialize(path, options = {})
if path.is_a? String
@img = Gosu::Image.new(path, options)
elsif path.is_a? Gosu::Image
@img = path
end
@path = path
@width = @img.width
@height = @img.height
@x = 0
@y = 0
@z = 0
@angle = 0.0
@scale_x = 1.0
@scale_y = 1.0
@center_x = 0.0
@center_y = 0.0
@mirror_x = false
@mirror_y = false
@color = Gosu::Color::WHITE
@blob = @img.to_blob
end
def draw(x = @x ,y = @y ,z = @z, scale_x = @scale_x, scale_y = @scale_y)
# Set each point / scale / angle / ...
@center_x = (@center_x * @scale_x).to_f
@center_y = (@center_y * @scale_y).to_f
@scale_x = @scale_x.to_f
@scale_y = @scale_y.to_f
@angle = @angle.to_f
@img.draw_rot(x,
y,
z,
@angle,
(@mirror_x) ? (@width - @center_x) / @width : @center_x / @width,
(@mirror_y) ? (@height - @center_y) / @height : @center_y / @height,
(@mirror_x) ? -scale_x : scale_x,
(@mirror_y) ? -scale_y : scale_y,
@color)
end
def get_pixel(x, y)
if x < 0 or x >= width or y < 0 or y >= height
return nil
else
r = @blob[(y * @img.width + x) * 4, 4][0].unpack("H*").first.to_i(16)
g = @blob[(y * @img.width + x) * 4, 4][1].unpack("H*").first.to_i(16)
b = @blob[(y * @img.width + x) * 4, 4][2].unpack("H*").first.to_i(16)
a = @blob[(y * @img.width + x) * 4, 4][3].unpack("H*").first.to_i(16)
return Gosu::Color.new(a, r, g, b)
end
end
def mouse_hover?
if $game.mouse_x < @x or $game.mouse_x >= @x + @width or $game.mouse_y < @y or $game.mouse_y >= @y + @height
return false
else
return true
end
end
def width
return @width
end
def height
return @height
end
def position=(vec2)
@x = vec2.x
@y = vec2.y
end
def position
return Vector2.new(@x, @y)
end
end
class SpriteSheet
attr_accessor :frame_time
attr_accessor :x, :y, :z
attr_accessor :angle, :scale_x, :scale_y
attr_accessor :center_x, :center_y
attr_accessor :mirror_x, :mirror_y
attr_accessor :color
attr_accessor :path
def initialize(path, width, height, options = {})
@animation = Gosu::Image.load_tiles(path, width, height, options)
@path = path
@frame_time = 1.0
@current_frame = 0
@stop = false
@start_time = Gosu.milliseconds
@time = @start_time.to_f
@mirror_x = false
@mirror_y = false
@x = 0
@y = 0
@z = 0
@width = width
@height = height
@angle = 0.0
@scale_x = 1.0
@scale_y = 1.0
@center_x = 0.0
@center_y = 0.0
@color = Gosu::Color::WHITE
@blob = []
@animation.each { |image| @blob << image.to_blob }
end
def draw(x = @x, y = @y, z = @z)
# Update
if !@stop
@time = Gosu.milliseconds - @start_time
if @time >= (@frame_time * 1000)
@start_time = Gosu.milliseconds
@time = 0.0
@current_frame += 1
@current_frame = 0 if @current_frame == @animation.size
end
end
if @mirror_y
@center_y = @center_x
end
# Draw
@animation[@current_frame].draw_rot(x,
y,
z,
@angle,
(@mirror_x) ? (@width - @center_x) / @width : @center_x / @width,
(@mirror_y) ? (@height - @center_y) / @height : @center_y / @height,
(@mirror_x) ? -@scale_x : @scale_x,
(@mirror_y) ? -@scale_y : @scale_y,
@color)
end
def stop
@stop = true
end
def start
@stop = false
end
def set_frame(frame)
frame = 0 if frame > @animation.size
@current_frame = frame
end
def get_pixel(x, y, frame = @current_frame)
if x < 0 or x >= width or y < 0 or y >= height
return nil
else
r = @blob[frame][(y * width + x) * 4, 4][0].unpack("H*").first.to_i(16)
g = @blob[frame][(y * width + x) * 4, 4][1].unpack("H*").first.to_i(16)
b = @blob[frame][(y * width + x) * 4, 4][2].unpack("H*").first.to_i(16)
a = @blob[frame][(y * width + x) * 4, 4][3].unpack("H*").first.to_i(16)
return Gosu::Color.new(a, r, g, b)
end
end
def mouse_hover?
if $game.mouse_x < @x or $game.mouse_x >= @x + @width or $game.mouse_y < @y or $game.mouse_y >= @y + @height
return false
else
return true
end
end
def width
return @width
end
def height
return @height
end
def position=(vec2)
@x = vec2.x
@y = vec2.y
end
def position
return Vector2.new(@x, @y)
end
end
class ObjectManager
def ObjectManager.initialize()
@@objects ||= {}
end
def ObjectManager.set(object, id)
@@objects[id] = object
end
def ObjectManager.delete(id)
@@objects[id] = nil
end
def ObjectManager.get(id)
return @@objects[id]
end
end
class SpriteFont
DEFAULT_FONT = Gosu.default_font_name
attr_accessor :text
attr_accessor :x, :y, :z
attr_accessor :scale_x, :scale_y
attr_accessor :angle, :center_x, :center_y
attr_accessor :color
def initialize(window, font, size)
if font != DEFAULT_FONT
if font[0] != "." && font[1] != "/"
font = ("./" + font).to_s
end
end
@font = Gosu::Font.new(window, font, size)
@color = Gosu::Color::WHITE
@scale_x = 1.0
@scale_y = 1.0
@x = 0
@y = 0
@z = 0
@text = ""
@angle = 0.0
@center_x = 0.0
@center_y = 0.0
end
def draw(text = @text, x = @x, y = @y, z = @z, scale_x = @scale_x, scale_y = @scale_y, color = @color)
Gosu.rotate(@angle, @center_x, @center_y) do
@font.draw(text, x, y, z, scale_x, scale_y, color)
end
end
def width(text = @text, scale_x = @scale_x)
return @font.text_width(text, scale_x)
end
def height
return @font.height
end
end
class Camera
attr_accessor :x, :y
attr_accessor :scale_x, :scale_y
attr_accessor :center_x, :center_y
attr_accessor :render_order
attr_accessor :angle
def initialize
@x = 0
@y = 0
@scale_x = 1.0
@scale_y = 1.0
@center_x = 0.0
@center_y = 0.0
@render_order = [:scale, :translate, :rotate]
@angle = 0.0
end
def render
raise "NeoGame [ERROR]: The render order array is less than 3." if render_order.size < 3
self.send render_order[0] do
self.send render_order[1] do
self.send render_order[2] do
yield
end
end
end
end
def scale(scale_x = @scale_x, scale_y = @scale_y, center_x = @center_x, center_y = @center_y)
Gosu.scale(scale_x, scale_y, center_x, center_y) do
yield
end
end
def translate(x = @x, y = @y)
Gosu.translate(x, y) do
yield
end
end
def rotate(angle = @angle, center_x = @center_x, center_y = @center_y)
Gosu.rotate(angle, center_x, center_y) do
yield
end
end
def record(width, height)
img = Gosu.record(width, height) do
yield
end
return Sprite.new(img)
end
end
class Media
attr_reader :looping, :volume, :speed, :panning
def initialize(path)
@sample = Gosu::Sample.new(path)
@channel = nil
@looping = false
@volume = 1.0
@speed = 1.0
@panning = 0.0
@playing = false
end
def play(looping = @looping, volume = @volume, speed = @speed, panning = @panning)
@channel = nil
@looping = looping
@volume = volume
@speed = speed
@panning = panning
@channel = @sample.play_pan(panning, volume, speed, looping)
@playing = true
end
def stop
puts "NeoGame [ERROR]: The media is already stopped." if @channel == nil
return if @channel == nil
@channel.stop
@channel = nil
@playing = false
end
def pause
puts "NeoGame [ERROR]: Cannot pause if it was stopped or not started." if @channel == nil
return if @channel == nil
@channel.pause
end
def resume
puts "NeoGame [ERROR]: Cannot resume if it was stopped or not started." if @channel == nil
return if @channel == nil
@channel.resume
end
def playing?
@playing = @channel.playing? if @channel != nil
return @playing
end
def paused?
puts "NeoGame [ERROR]: Cannot return if the media is paused if it was stopped or not played." if @channel == nil
return if @channel == nil
return @channel.paused?
end
def pan=(v)
puts "NeoGame [ERROR]: Cannot set the pan if it was stopped or not started." if @channel == nil
return if @channel == nil
@panning = v
@channel.pan = v
end
def speed=(v)
puts "NeoGame [ERROR]: Cannot set the speed if it was stopped or not started." if @channel == nil
return if @channel == nil
@speed = v
@channel.speed = v
end
def volume=(v)
puts "NeoGame [ERROR]: Cannot set the volume if it was stopped or not started." if @channel == nil
return if @channel == nil
@volume = v
@channel.volume = v
end
end
class StateManager
def self.initialize(window)
@@window = window
@@state ||= {}
@@current_state ||= nil
@@input = window.input