History

grid coloring

Sigrid Haflínudóttir committed 6 years ago

Commit 3ddecd71 parent 6a804781 file · +31 −30Browse files

Unified · Split

9tetris.c+31−30
@@ -113,7 +113,7 @@ int big9logo[FIELD_HEIGHT][FIELD_WIDTH] = { · 112 unmodified lines
113113 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
114114 };
115115
116−Image *colorimages[8];
116+Image *colorimages[8], *grey;
117117 int field[FIELD_HEIGHT][FIELD_WIDTH];
118118 Piece *currentpiece;
119119 Point currentpiecepos;
@@ -131,6 +131,25 @@ void currentpiecestuck(void); · 11 unmodified lines
131131 void clearrows(void);
132132 void startgame(void);
133133
134+static char *helps[3][5] = {
135+ {
136+ "** PAUSED **",
137+ nil,
138+ },
139+ {
140+ "** GAME OVER **",
141+ "Press enter for a new game",
142+ nil,
143+ },
144+ {
145+ "Move: o/p ",
146+ "Rotate: q/w ",
147+ "Fast: space",
148+ "Start/Pause: enter",
149+ nil,
150+ },
151+};
152+
134153 void
135154 rotatepieceleft(Piece *p)
136155 {
@@ -277,6 +296,7 @@ setupcolors(void) · 140 unmodified lines
277296 colorimages[ORANGE] = eallocimage(r, 1, DDarkyellow);
278297 colorimages[CYAN] = eallocimage(r, 1, DCyan);
279298 colorimages[PURPLE] = eallocimage(r, 1, DPurpleblue);
299+ grey = eallocimage(r, 1, 0xb0b0b0ff);
280300 }
281301
282302 void
@@ -299,17 +319,18 @@ drawblock(int row, int col, int color) · 16 unmodified lines
299319 void
300320 drawgrid(void)
301321 {
302− /* Horizontal lines */
303− for(int i = 0; i <= FIELD_HEIGHT; i++){
322+ int i;
323+
324+ for(i = 0; i <= FIELD_HEIGHT; i++){
304325 Point p0 = Pt(0, i * BLOCK_SIZE);
305− Point p1 = Pt(FIELD_WIDTH * BLOCK_SIZE, i * BLOCK_SIZE);
306− line(screen, addpt(p0, center.min), addpt(p1, center.min), 0, 0, 0, display->black, ZP);
326+ Point p1 = Pt(FIELD_WIDTH * BLOCK_SIZE+1, i * BLOCK_SIZE);
327+ line(screen, addpt(p0, center.min), addpt(p1, center.min), 0, 0, 0, (i % FIELD_HEIGHT) ? grey : display->black, ZP);
307328 }
308− /* Vertial lines */
309− for(int j = 0; j <= FIELD_WIDTH; j++){
310− Point p0 = Pt(j * BLOCK_SIZE, 0);
311− Point p1 = Pt(j * BLOCK_SIZE, FIELD_HEIGHT * BLOCK_SIZE);
312− line(screen, addpt(p0, center.min), addpt(p1, center.min), 0, 0, 0, display->black, ZP);
329+
330+ for(i = 0; i <= FIELD_WIDTH; i++){
331+ Point p0 = Pt(i * BLOCK_SIZE, (i % FIELD_WIDTH) ? 1 : 0);
332+ Point p1 = Pt(i * BLOCK_SIZE, FIELD_HEIGHT * BLOCK_SIZE);
333+ line(screen, addpt(p0, center.min), addpt(p1, center.min), 0, 0, 0, (i % FIELD_WIDTH) ? grey : display->black, ZP);
313334 }
314335 }
315336
@@ -338,25 +359,6 @@ drawcurrentpiece(void) · 22 unmodified lines
338359 }
339360 }
340361
341−static char *helps[3][5] = {
342− {
343− "** PAUSED **",
344− nil,
345− },
346− {
347− "** GAME OVER **",
348− "Press enter for a new game",
349− nil,
350− },
351− {
352− "Move: o/p ",
353− "Rotate: q/w ",
354− "Fast: space",
355− "Start/Pause: enter",
356− nil,
357− },
358−};
359−
360362 void
361363 drawinfo(void)
362364 {
@@ -448,7 +450,6 @@ iscurrentpiececolliding(void) · 85 unmodified lines
448450 return ispiececolliding(currentpiece, currentpiecepos);
449451 }
450452
451−
452453 int
453454 isrowfull(int row)
454455 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t