Add: conway game (basic) but flickers?
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user