@@ -33,34 +33,36 @@ support = [
3333
3434def draw(v, cellSize) {
3535 c2 = cellSize / 2
36- if (v == HORIZONTAL) fillRect(0, c2 - 2, cellSize, 4)
37- else if (v == VERTICAL) fillRect(c2 - 2, 0, 4, cellSize)
38- else if (v == LEFT_TO_DOWN) {
39- fillRect(0, c2 - 2, c2, 4)
40- fillRect(c2 - 2, c2 - 2, 4, c2 + 2)
41- }
42- else if (v == LEFT_TO_UP) {
43- fillRect(0, c2 - 2, c2, 4)
44- fillRect(c2 - 2, c2 - 2, 4, c2 + 2)
45- }
46- else if (v == RIGHT_TO_UP) {
47- fillRect(c2 - 2, c2 - 2, c2 + 2, 4)
48- fillRect(c2 - 2, 0, 4, c2 + 2)
49- }
50- else if (v == RIGHT_TO_DOWN) {
51- fillRect(c2 - 2, c2 - 2, c2 + 2, 4)
52- fillRect(c2 - 2, c2 - 2, 4, c2 + 2)
53- }
54- else if (v == CROSS) {
55- fillRect(c2 - 2, 0, 4, cellSize)
56- fillRect(0, c2 - 2, cellSize, 4)
36+ match v {
37+ case HORIZONTAL : fillRect(0, c2 - 2, cellSize, 4)
38+ case VERTICAL : fillRect(c2 - 2, 0, 4, cellSize)
39+ case LEFT_TO_DOWN : {
40+ fillRect(0, c2 - 2, c2, 4)
41+ fillRect(c2 - 2, c2 - 2, 4, c2 + 2)
42+ }
43+ case LEFT_TO_UP : {
44+ fillRect(0, c2 - 2, c2, 4)
45+ fillRect(c2 - 2, c2 - 2, 4, c2 + 2)
46+ }
47+ case RIGHT_TO_UP : {
48+ fillRect(c2 - 2, c2 - 2, c2 + 2, 4)
49+ fillRect(c2 - 2, 0, 4, c2 + 2)
50+ }
51+ case RIGHT_TO_DOWN : {
52+ fillRect(c2 - 2, c2 - 2, c2 + 2, 4)
53+ fillRect(c2 - 2, c2 - 2, 4, c2 + 2)
54+ }
55+ case CROSS : {
56+ fillRect(c2 - 2, 0, 4, cellSize)
57+ fillRect(0, c2 - 2, cellSize, 4)
58+ }
5759 }
5860}
5961
60- def supportLeft(v) return support[v][0]
61- def supportRight(v) return support[v][1]
62- def supportUp(v) return support[v][2]
63- def supportDown(v) return support[v][3]
62+ def supportLeft(v) = support[v][0]
63+ def supportRight(v) = support[v][1]
64+ def supportUp(v) = support[v][2]
65+ def supportDown(v) = support[v][3]
6466///-------------------------------------
6567
6668
@@ -73,8 +75,8 @@ SIZE = 10
7375board = newarray(SIZE, SIZE)
7476
7577def createBoard() {
76- for i=0, i<SIZE, i=i+1
77- for j=0, j<SIZE, j=j+1
78+ for i=0, i<SIZE, i++
79+ for j=0, j<SIZE, j++
7880 board[i][j] = rand(CELL_LAST)
7981}
8082
@@ -144,10 +146,10 @@ run = 1
144146while run {
145147 //key = gameaction(keypressed())
146148 key = keypressed()
147- if (key == VK_LEFT && curX > 0) curX = curX - 1
148- else if (key == VK_RIGHT && curX < SIZE - 1) curX = curX + 1
149- else if (key == VK_UP && curY > 0) curY = curY - 1
150- else if (key == VK_DOWN && curY < SIZE - 1) curY = curY + 1
149+ if (key == VK_LEFT && curX > 0) curX--
150+ else if (key == VK_RIGHT && curX < SIZE - 1) curX++
151+ else if (key == VK_UP && curY > 0) curY--
152+ else if (key == VK_DOWN && curY < SIZE - 1) curY++
151153 else if key == VK_FIRE switchCell(curX,curY)
152154 else if key == 48 run = 0
153155
@@ -157,13 +159,13 @@ while run {
157159 // курсор
158160 color(#4444FF)
159161 frect(curX*cellSize, curY*cellSize, cellSize, cellSize)
160- for (i=0, i<SIZE, i=i+1 ) {
162+ for (i=0, i<SIZE, i++ ) {
161163 color(0)
162164 ic = i*cellSize
163165 line(0, ic, cellSize*SIZE, ic)
164166 line(ic, 0, ic, cellSize*SIZE)
165167 color(#FF0000)
166- for j=0, j<SIZE, j=j+1 {
168+ for j=0, j<SIZE, j++ {
167169 translateX = ic
168170 translateY = j*cellSize
169171 draw(board[i][j], cellSize)
0 commit comments