-
Notifications
You must be signed in to change notification settings - Fork 1
/
set_options.js
218 lines (210 loc) · 9.32 KB
/
set_options.js
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
// この関数の内容を変えるだけで自分のゲームに使えます!
// 色々なオプションを変えてください
const set_options = () => {
// ブロックなどを表すタイルは32ピクセルというサイズのrectで表しています
const tile_size = 32;
// tilesに色の文字列か絵文字を使うことができます
// tiles配列とタイル一つを描く関数tile_draw_functionを新しく作ることで
// 新しいグラフィックモードを作るのも可能
// 色は実際のファミコンの色を使いました: http://www.firebrandx.com/nespalette.html
// 定数扱い
const sample_color_tiles = [
"#c3f6f6", // 0 空色
"#754702", // 1 茶色
"#b3af0d", // 2 黄色
"#027645", // 3 緑
"#983700", // 4 赤
"#071380", // 5 青
"#7bc213", // 6 黄緑
];
const sample_emoji_tiles = [
" ",
"📦",
"🎁",
"📗",
"👨🔧",
"💦",
"🐢",
];
// 一つ一つのタイルを描く関数。
// 四角バージョン
const drawSquare = (i, j, tile='#000000', size=32) => {
fill(tile);
rect(j * size, i * size, size, size);
};
// 絵文字バージョン
const drawEmoji = (i, j, tile='⛰', size=32) => {
textSize(size);
text(tile, j * size, i * size, size, size);
};
// この下の`tile_engine`は一つだけ定義できます
// 四角か絵文字をえらんで、他はコメントにしてください
// タイルに単色の四角を使う場合
// const tile_engine = {
// tiles: sample_color_tiles,
// tile_draw_function: drawSquare
// };
// タイルに絵文字を使う場合
const tile_engine = {
tiles: sample_emoji_tiles,
tile_draw_function: drawEmoji
};
// 各ステージ(面)のマップ。数字は出したい色の tiles でのインデックス
// 定数扱い
const stages = [
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
],
[
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 2, 0, 0, 0, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 1, 0, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
],
];
// 全てのステージの位置関係を表すマップ
// 数字は`stages`の中の各ステージのインデックス
// `stages[0]`は最初に出てくるステージとされます
const scroll_map = [
[1, 2, 3],
[4, 0, 5],
[6, 7, 8],
];
// この上の設定で、インスタンスを初期化!
screen = new ScreenScroller(tile_engine.tile_draw_function, scroll_map, tile_size, tile_engine.tiles, stages);
};