diff options
author | rodri <rgl@antares-labs.eu> | 2020-05-18 19:33:23 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2020-05-18 19:33:23 +0000 |
commit | 0628e715e9ae5d5b1ff9e5d9c063781ed9b90907 (patch) | |
tree | 9f3b7e21ad9dc680bc6a350b4f1331cc0b7b8f2c | |
parent | e9a9a611dcb6d61b7221af8634fc5b2e5624f3b2 (diff) | |
download | etoys-0628e715e9ae5d5b1ff9e5d9c063781ed9b90907.tar.gz etoys-0628e715e9ae5d5b1ff9e5d9c063781ed9b90907.tar.bz2 etoys-0628e715e9ae5d5b1ff9e5d9c063781ed9b90907.zip |
isometric: per-cell tile drawing
-rw-r--r-- | asset/tile/building.pic | bin | 4156 -> 8252 bytes | |||
-rw-r--r-- | isometric.c | 21 |
2 files changed, 16 insertions, 5 deletions
diff --git a/asset/tile/building.pic b/asset/tile/building.pic Binary files differindex 1a6139a..76d8811 100644 --- a/asset/tile/building.pic +++ b/asset/tile/building.pic diff --git a/isometric.c b/isometric.c index 97bf20d..7a33dd9 100644 --- a/isometric.c +++ b/isometric.c @@ -125,6 +125,17 @@ drawgrid(void) } void +drawtile(Tile *t, Point2 cell) +{ + Point p; + cell.x *= TW; + cell.y *= TH; + p = toscreen(cell); + p.x -= TW/2; + draw(screen, Rpt(p,addpt(p, Pt(TW,TH))), t->img, nil, ZP); +} + +void redraw(void) { Point2 dp; @@ -134,15 +145,15 @@ redraw(void) draw(screen, screen->r, pal[Cbg], nil, ZP); for(i = 0; i < nelem(map); i++) for(row = map[i]; *row; row++){ - dp = Pt2((row-map[i])*TW,(i)*TH,1); + dp = Pt2(row-map[i],i,1); for(j = 0; j < nelem(tiles); j++) if(tiles[j].id == *row) - draw(screen, Rpt(subpt(toscreen(dp), Pt(TW/2,0)),addpt(toscreen(dp), Pt(TW,TH))), tiles[j].img, nil, ZP); + drawtile(&tiles[j], dp); } dp = fromscreen(mpos); - dp.x = ((int)dp.x/TW)*TW; - dp.y = ((int)dp.y/TH)*TH; - draw(screen, Rpt(subpt(toscreen(dp), Pt(TW/2,0)),addpt(toscreen(dp), Pt(TW,TH))), tfocus->img, nil, ZP); + dp.x = (int)dp.x/TW; + dp.y = (int)dp.y/TH; + drawtile(tfocus, dp); if(showgrid) drawgrid(); drawstats(); |