wireframe! and music!

This commit is contained in:
Tobin
2026-04-27 14:08:07 -04:00
parent e0eb69fd64
commit 2a9ee28f93
3 changed files with 22 additions and 3 deletions
+14
View File
@@ -133,6 +133,20 @@ void cat_fill(int layer, int visible, int x, int y, int w, int h, unsigned char
cat_pixel(layer, visible, cx + x, cy + y, r, g, b); cat_pixel(layer, visible, cx + x, cy + y, r, g, b);
} }
void cat_wireframe(int layer, int visible, int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b)
{
int cx; for (cx = 0; cx < w; cx++)
{
cat_pixel(layer, visible, x + cx, y, r, g, b);
cat_pixel(layer, visible, x + cx, y+h, r, g, b);
}
int cy; for (cy = 0; cy < h; cy++)
{
cat_pixel(layer, visible, x, y + cy, r, g, b);
cat_pixel(layer, visible, x + w, y + cy, r, g, b);
}
}
/* TODO: cat bresenham */ /* TODO: cat bresenham */
/* audio... */ /* audio... */
Binary file not shown.
+8 -3
View File
@@ -164,6 +164,7 @@ void mouse_up(unsigned char button)
void process_input(void) void process_input(void)
{ {
/* mode switch game or menus */
struct cat_event* e = cat_get_event(); struct cat_event* e = cat_get_event();
if (e == NULL) return; if (e == NULL) return;
if (e->type == QUIT) bye(); if (e->type == QUIT) bye();
@@ -179,7 +180,7 @@ void erase_entity(struct entity* e)
/* get sprite info, etc */ /* get sprite info, etc */
/* FIXME */ /* FIXME */
if (e->x < 0 || e->y < 0 || e->x >= screen_width || e->y >= screen_height) return; if (e->x < 0 || e->y < 0 || e->x >= screen_width || e->y >= screen_height) return;
cat_fill(1, 0, e->x, e->y, e->width, e->height, 0, 0, 0); cat_wireframe(1, 0, e->x, e->y, e->width, e->height, 0, 0, 0);
} }
void draw_entity(struct entity* e) void draw_entity(struct entity* e)
@@ -187,7 +188,7 @@ void draw_entity(struct entity* e)
/* get sprite info, etc */ /* get sprite info, etc */
/* FIXME */ /* FIXME */
if (e->x < 0 || e->y < 0 || e->x >= screen_width || e->y >= screen_height) return; if (e->x < 0 || e->y < 0 || e->x >= screen_width || e->y >= screen_height) return;
cat_fill(1, 1, e->x, e->y, e->width, e->height, e->r, e->g, e->b); cat_wireframe(1, 1, e->x, e->y, e->width, e->height, e->r, e->g, e->b);
/* if out of bounds do not draw */ /* if out of bounds do not draw */
} }
@@ -236,6 +237,8 @@ void tick(void)
printf("tick %d!\n", tick_count++); printf("tick %d!\n", tick_count++);
/* code to run every tick goes here */ /* code to run every tick goes here */
/* something like "for i in fns_to_run_per_tick (linked list) run ->fn()
and somewhere there's an add_fn_to_run_every_tick() thing... or every n ticks... idk */
erase_entities(); erase_entities();
struct entity* p = get_player(); struct entity* p = get_player();
if (is_held(' ')) p->ay = -5; if (is_held(' ')) p->ay = -5;
@@ -252,6 +255,7 @@ void game_loop(void)
{ {
cat_render(); cat_render();
process_input(); process_input();
/* mode check for in game or in menu */
tick(); tick();
} }
@@ -261,7 +265,8 @@ int main(int argc, char** argv)
cat_create_window(1920, 1080); cat_create_window(1920, 1080);
//cat_play_wav("etc/example.wav"); //cat_play_wav("etc/example.wav");
//cat_play_wav("etc/cat_quick.wav"); //cat_play_wav("etc/cat_quick.wav");
cat_play_wav("etc/cat_beep_box.wav"); //cat_play_wav("etc/cat_beep_box.wav");
cat_play_wav("etc/cat_beep_slower.wav");
/* layer, visibility, x, y, width, height, r, g, b */ /* layer, visibility, x, y, width, height, r, g, b */
cat_fill(0, 1, 0, 0, screen_width - 1, screen_height - 1, 132, 155, 132); cat_fill(0, 1, 0, 0, screen_width - 1, screen_height - 1, 132, 155, 132);
/* create the player */ add_entity(1, 0, 0, 0, 50, 50, 100, 50, 0, 0, 0, 0, 0); /* create the player */ add_entity(1, 0, 0, 0, 50, 50, 100, 50, 0, 0, 0, 0, 0);