Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Created May 27, 2026 18:45
Show Gist options
  • Select an option

  • Save peterhellberg/d23dd28fa09acc71758ff71be73d06d5 to your computer and use it in GitHub Desktop.

Select an option

Save peterhellberg/d23dd28fa09acc71758ff71be73d06d5 to your computer and use it in GitHub Desktop.
Small example of drawing colors using the C SDK for GameTank
#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

Copy link
Copy Markdown
Author
Screenshot_2026-05-27_20-43-49

@peterhellberg

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment