You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.1 KiB
C

#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <raylib.h>
#define overload _Generic
#define WIDTH 640
#define HEIGHT 480
#define VMEM WIDTH * HEIGHT
Color video_memory[VMEM] = {};
Image charset[26];
void draw_frame() {
for (int i = 0; i < WIDTH; i++) {
for (int j = 0; j < HEIGHT; j++) {
DrawPixel(i, j, video_memory[i + (j * WIDTH)]);
}
}
}
void red_line(Color *vmem) {
static int i = 0;
for (; i < 70; i++) {
video_memory[i] = RED;
}
}
void write_image(Color *vmem, Image image, uint32_t x, uint32_t y) {
for (int i = 0; i < 16; i++) {
int image_size = image.width * sizeof(uint32_t); //16 pixels, 4 bytes per pixel
memcpy(vmem + (i * WIDTH) + (y * WIDTH * 16) + (x * 16), &image.data[i * image_size], image_size);
}
}
void load_charset() {
char filenames[][26] = {
"resources/A.png",
"resources/B.png",
"resources/C.png",
"resources/D.png",
"resources/E.png",
"resources/F.png",
"resources/G.png",
"resources/H.png",
"resources/I.png",
"resources/J.png",
"resources/K.png",
"resources/L.png",
"resources/M.png",
"resources/N.png",
"resources/O.png",
"resources/P.png",
"resources/Q.png",
"resources/R.png",
"resources/S.png",
"resources/T.png",
"resources/U.png",
"resources/V.png",
"resources/W.png",
"resources/X.png",
"resources/Y.png",
"resources/Z.png"
};
for (int i = 0; i < 26; i++) {
charset[i] = LoadImage(filenames[i]);
}
}
int main(void) {
InitWindow(WIDTH, HEIGHT, "Computer :3");
SetTargetFPS(60);
load_charset();
int i = 0;
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(BLUE);
draw_frame();
//red_line(video_memory);
write_image(&video_memory, charset[i++ % 26], 0, 0);
//tc_putchar(video_memory, &checkers, 1, 2);
EndDrawing();
}
return 0;
}