Add: conway game (basic) but flickers?

This commit is contained in:
xamidev
2024-08-10 22:58:56 +02:00
parent c47e29f9ed
commit 51024e1d06
10 changed files with 179 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
#include "crypto.h"
#include "../libc/stdint.h"
int lcg(int seed)
{
@@ -22,3 +23,21 @@ int randint(int seed)
int x = lcg(seed);
return x;
}
static uint32_t next = 1;
uint32_t rand()
{
next = next * 1103515245 + 12345;
return (next/65536) % 32768;
}
float rand_float()
{
return rand() / 32767.0f;
}
void srand(uint32_t seed)
{
next = seed;
}

View File

@@ -3,7 +3,12 @@
#define RAND_MAX 1024
#include "../libc/stdint.h"
int lcg(int seed);
int randint(int seed);
uint32_t rand();
float rand_float();
void srand(uint32_t seed);
#endif