-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment_builder.rb
More file actions
84 lines (78 loc) · 1.17 KB
/
environment_builder.rb
File metadata and controls
84 lines (78 loc) · 1.17 KB
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
require 'app/interactibles/wall.rb'
require 'app/interactibles/apple.rb'
require 'app/interactibles/snake.rb'
class EnvironmentBuilder
def initialize(args)
@_args = args
end
def build_environment
build_walls
end
def build_apple
Apple.generate_apple(@_args)
end
def build_snake(rebuild = false)
if rebuild
Snake.generate_snake(@_args)
else
@_snake ||= Snake.generate_snake(@_args)
end
end
private
def build_walls
@_args.state.walls ||= [
Wall.new(
{
x: 20,
y: 18,
w: 1240,
h: 2,
r: 0,
g: 0,
b: 0,
a: 254,
},
@_args,
),
Wall.new(
{
x: 18,
y: 20,
w: 2,
h: 680,
r: 0,
g: 0,
b: 0,
a: 254,
},
@_args,
),
Wall.new(
{
x: 20,
y: 700,
w: 1240,
h: 2,
r: 0,
g: 0,
b: 0,
a: 254,
},
@_args,
),
Wall.new(
{
x: 1260,
y: 20,
w: 2,
h: 680,
r: 0,
g: 0,
b: 0,
a: 254,
},
@_args
),
]
end
end