Increment and decrement playfield cells. Now, the debugging!
Chris Pressey
1 year, 3 months ago
83 | 83 | end |
84 | 84 | end |
85 | 85 | |
86 | local increment_playfield_at = function(p, x, y) | |
87 | local data = p:peek(x, y) | |
88 | if data == " " then | |
89 | data = "#" | |
90 | elseif data == "#" then | |
91 | data = "@" | |
92 | elseif data == "@" then | |
93 | data = " " | |
94 | else | |
95 | error("What is this i cannot even " + data) | |
96 | end | |
97 | p:poke(x, y, data) | |
98 | end | |
99 | ||
100 | local decrement_playfield_at = function(p, x, y) | |
101 | local data = p:peek(x, y) | |
102 | if data == " " then | |
103 | data = "@" | |
104 | elseif data == "@" then | |
105 | data = "#" | |
106 | elseif data == "#" then | |
107 | data = " " | |
108 | else | |
109 | error("What is this i cannot even " + data) | |
110 | end | |
111 | p:poke(x, y, data) | |
112 | end | |
113 | ||
86 | 114 | -- |
87 | 115 | -- Loader |
88 | 116 | -- |
159 | 187 | ix = ix + dx |
160 | 188 | iy = iy + dy |
161 | 189 | elseif (dx == -1 and dy == -1) or (dx == 1 and dy == -1) then |
162 | -- FIXME p.increment(dp.x, dp.y); | |
163 | px = px | |
190 | increment_playfield_at(p, px, py) | |
164 | 191 | elseif (dx == -1 and dy == 1) or (dx == 1 and dy == 1) then |
165 | -- FIXME p.decrement(dp.x, dp.y); | |
166 | px = px | |
192 | decrement_playfield_at(p, px, py) | |
167 | 193 | end |
168 | 194 | end |
169 | 195 |