Created
May 27, 2026 18:45
-
-
Save peterhellberg/d23dd28fa09acc71758ff71be73d06d5 to your computer and use it in GitHub Desktop.
Small example of drawing colors using the C SDK for GameTank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "gt/gfx/draw_queue.h" | |
| char bx = 30, by = 20; | |
| char dx = 1, dy = 1; | |
| const int cw = 6, ch = 5; | |
| const int sx = 8, sy = 6; | |
| void update() { | |
| bx += dx; | |
| by += dy; | |
| if (bx == 1) { | |
| dx = 1; | |
| } else if (bx == 119) { | |
| dx = -1; | |
| } | |
| if (by == 8) { | |
| dy = 1; | |
| } else if (by == 112) { | |
| dy = -1; | |
| } | |
| } | |
| void draw() { | |
| queue_clear_screen(0x0); | |
| { // Draw colors | |
| int col, row; | |
| for (col = 0; col < 16; col++) { | |
| for (row = 0; row < 16; row++) { | |
| int x = 1 + (col * sx); | |
| int y = 1 + (row * sy); | |
| queue_draw_box(x, y, cw, ch, (col << 4) | row); | |
| } | |
| } | |
| } | |
| { // Bouncing box | |
| queue_draw_box(bx - 1, by - 1, 20, 10, 0xDE); | |
| queue_draw_box(bx, by, 18, 8, 0xDF); | |
| } | |
| { // Border | |
| queue_clear_border(0x0); | |
| } | |
| await_draw_queue(); | |
| await_vsync(1); | |
| flip_pages(); | |
| } | |
| int main() { | |
| while (1) { // Forever | |
| update(); | |
| draw(); | |
| } | |
| return 0; | |
| } |
peterhellberg
commented
May 27, 2026
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment