From 637ee707e7a7b8b86dd5985452973fffe9c1d232 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Fri, 29 Jan 2016 01:52:24 -0500 Subject: [PATCH] Stanislav Lechev's shadow-block patch Originally from http://0xaf.org/software/gtetrinet-0.7.11-shadow.patch --- src/fields.c | 4 +--- src/fields.h | 4 ++++ src/tetris.c | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/fields.c b/src/fields.c index e0ba2f7..2af5301 100644 --- a/src/fields.c +++ b/src/fields.c @@ -48,7 +48,7 @@ static gint fields_nextpiece_expose (GtkWidget *widget); static gint fields_specials_expose (GtkWidget *widget); static void fields_refreshfield (int field); -static void fields_drawblock (int field, int x, int y, char block); +void fields_drawblock (int field, int x, int y, char block); static void gmsginput_activate (void); @@ -361,10 +361,8 @@ void fields_drawfield (int field, FIELD newfield) int x, y; for (y = 0; y < FIELDHEIGHT; y ++) for (x = 0; x < FIELDWIDTH; x ++) - if (newfield[y][x] != displayfields[field][y][x]) { fields_drawblock (field, x, y, newfield[y][x]); displayfields[field][y][x] = newfield[y][x]; - } } void fields_drawblock (int field, int x, int y, char block) diff --git a/src/fields.h b/src/fields.h index b565656..f3c442c 100644 --- a/src/fields.h +++ b/src/fields.h @@ -22,3 +22,7 @@ extern void fields_gmsginput (int i); extern void fields_gmsginputclear (void); extern void fields_gmsginputactivate (int i); extern const char *fields_gmsginputtext (void); + + +//AF +extern void fields_drawblock (int field, int x, int y, char block); diff --git a/src/tetris.c b/src/tetris.c index 04be999..faff631 100644 --- a/src/tetris.c +++ b/src/tetris.c @@ -165,6 +165,32 @@ void tetris_drawcurrentblock (void) if (blocknum >= 0) placeblock (field, blocknum, blockorient, blockx, blocky); fields_drawfield (playerfield(playernum), field); + + + // AF: make shadow + FIELD shadowfield; + int x, y, y1, f; + + if (blocknum < 0) return; + + y1=0; + while (!blockobstructed(fields[playernum], blocknum, blockorient, blockx, y1)) + y1++; + y1--; + + if (y1-4<=blocky) return; + + copyfield (shadowfield, field); + if (blocknum >= 0) + placeblock (shadowfield, blocknum, blockorient, blockx, y1); + f = playerfield(playernum); + + for (y = 0; y < FIELDHEIGHT; y ++) + for (x = 0; x < FIELDWIDTH; x ++) + if (shadowfield[y][x] != fields[playernum][y][x]) { + fields_drawblock (f, x, y, shadowfield[y][x]); + } + } int tetris_makeblock (int block, int orient) -- 2.50.1