MORE BAZEL. VS Code only, by the way

This commit is contained in:
2024-02-25 13:49:21 -08:00
parent e2d648b5fa
commit 3f837d7052
21 changed files with 26 additions and 129 deletions

6
game/BUILD Normal file
View File

@ -0,0 +1,6 @@
cc_library(
name = "game",
srcs = glob(["*.c"]),
hdrs = glob(["*.h"]),
visibility = ["//sdl_host:__pkg__"]
)

3
game/device.c Normal file
View File

@ -0,0 +1,3 @@
#include "device.h"
uint32_t device_pixels[DEVICE_H][DEVICE_W];

12
game/device.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef CROCPARTY_DEVICE_H
#define CROCPARTY_DEVICE_H
#include <stdint.h>
// 240 x 135 is also cool
#define DEVICE_W 128
#define DEVICE_H 128
extern uint32_t device_pixels[DEVICE_H][DEVICE_W];
#endif //CROCPARTY_DEVICE_H

29
game/game.c Normal file
View File

@ -0,0 +1,29 @@
#include "device.h"
#include "game.h"
uint32_t game_frame;
void game_init() {
game_frame = 0;
}
void game_update() {
game_frame += 1;
}
void game_draw() {
for (int x = 0; x < DEVICE_W; x++) {
for (int y = 0; y < DEVICE_H; y++) {
uint32_t r = (x * 255)/DEVICE_W;
uint32_t g = (y * 255)/DEVICE_H;
uint32_t b = game_frame & 0x100 ? 0xff - game_frame & 0xff : game_frame & 0xff;
if (x % 4 == 2 && y % 4 == 2) {
r = 255 - r;
g = 255 - g;
b = 255 - b;
}
uint32_t color = r << 24 | g << 16 | b << 8;
device_pixels[y][x] = color;
}
}
}

8
game/game.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef CROCPARTY_GAME_H
#define CROCPARTY_GAME_H
void game_init();
void game_update();
void game_draw();
#endif //CROCPARTY_GAME_H