diff --git a/share/examples/gpanel/flappy.c b/share/examples/gpanel/flappy.c index 75d0e80..c5f52db 100644 --- a/share/examples/gpanel/flappy.c +++ b/share/examples/gpanel/flappy.c @@ -55,6 +55,9 @@ void fill(int color, int x, int y, int w, int h) void drawPillar(int x, int gap) { + if (x >= 320) + return; + fill(GREEN, x+2, 2, 46, gap-4); fill(GREEN, x+2, gap+92, 46, 136-gap); @@ -66,6 +69,9 @@ void drawPillar(int x, int gap) void clearPillar(int x, int gap) { + if (x >= 320) + return; + // "cheat" slightly and just clear the right hand pixels // to help minimise flicker, the rest will be overdrawn fill(BLUE, x+45, 0, 5, gap); @@ -199,11 +205,11 @@ void startGame() // Draw Ground int tx, ty = 230; - for (tx = 0; tx <= 300; tx +=20) { - gpanel_fill_triangle(GREEN, tx, ty, tx+10, ty, tx, ty+10); - gpanel_fill_triangle(YELLOW, tx+10, ty+10, tx+10, ty, tx, ty+10); - gpanel_fill_triangle(YELLOW, tx+10, ty, tx+20, ty, tx+10, ty+10); - gpanel_fill_triangle(GREEN, tx+20, ty+10, tx+20, ty, tx+10, ty+10); + for (tx = 0; tx <= 300; tx += 20) { + gpanel_fill_triangle(GREEN, tx, ty, tx+9, ty, tx, ty+9); + gpanel_fill_triangle(YELLOW, tx+9, ty+9, tx+9, ty, tx, ty+9); + gpanel_fill_triangle(YELLOW, tx+10, ty, tx+19, ty, tx+10, ty+9); + gpanel_fill_triangle(GREEN, tx+19, ty+9, tx+19, ty, tx+10, ty+9); } nextDrawLoopRunTime = millis() + DRAW_LOOP_INTERVAL; diff --git a/src/libgpanel/fill_triangle.c b/src/libgpanel/fill_triangle.c index 690d1bd..8f64a85 100644 --- a/src/libgpanel/fill_triangle.c +++ b/src/libgpanel/fill_triangle.c @@ -63,7 +63,7 @@ void gpanel_fill_triangle(int color, int x0, int y0, else if (x2 > b) b = x2; - gpanel_fill(color, a, y0, b-a+1, y0); + gpanel_fill(color, a, y0, b, y0); return; } @@ -100,7 +100,7 @@ void gpanel_fill_triangle(int color, int x0, int y0, if (a > b) swapi(a, b); - gpanel_fill(color, a, y, b-a+1, y); + gpanel_fill(color, a, y, b, y); } // For lower part of triangle, find scanline crossings for segments @@ -120,6 +120,6 @@ void gpanel_fill_triangle(int color, int x0, int y0, if (a > b) swapi(a, b); - gpanel_fill(color, a, y, b-a+1, y); + gpanel_fill(color, a, y, b, y); } }