-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.rb
75 lines (64 loc) · 1.63 KB
/
settings.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
require 'pry'
require_relative 'piece'
class Settings
def self.init
@@board_size = 20
@@cell_size = 40.0
@@window_size = [Settings.cell_size * @@board_size + @@cell_size * 30, Settings.cell_size * @@board_size]
@@colors = {
'black' => 0xff_000000,
'grey' => 0xff_666666,
'white' => 0xff_ffffff,
'red' => 0xff_dd3333,
'green' => 0xff_33dd33,
'blue' => 0xff_3333dd,
'yellow' => 0xff_dddd33
}
@@controls = {
'exit' => [Gosu::KB_ESCAPE]
}
@@pieces = Settings.read_pieces 'pieces/base.txt'
@@player_colors = {1 => @@colors['blue'], 2 => @@colors['red'], 3 => @@colors['green'], 4 => @@colors['yellow']}
@@debug_mode = false
end
def self.board_size
@@board_size
end
def self.cell_size
@@cell_size
end
def self.colors
@@colors
end
def self.controls
@@controls
end
def self.pieces
@@pieces
end
def self.player_colors
@@player_colors
end
def self.window_size
@@window_size
end
def self.debug_mode (debug_mode = nil)
if not debug_mode.nil?
@@debug_mode = debug_mode
end
@@debug_mode
end
def self.read_pieces (file)
pieces = Array.new
file_lines = File.readlines file
file_lines.each do |line|
line = line.strip
next if line == "" # Skip this line if it's empty
piece = line.split ','
piece = piece.map {|l| l.split ''}
piece = piece.map{ |r| r.map{ |c| c.to_i } }
pieces << Piece.new(piece)
end
return pieces
end
end