just for fun: a test game loop that cycles world width/height from 0-100 once a second; client prints them too btw
This commit is contained in:
parent
307323e561
commit
92fed87080
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
|
|
||||||
void render_world(struct world_t const *world) {
|
void render_world(struct world_t const *world) {
|
||||||
|
printf("%zu %zu\n", world->height, world->width);
|
||||||
|
|
||||||
for (size_t i = 0; i < MAX_ENTITIES; i++) {
|
for (size_t i = 0; i < MAX_ENTITIES; i++) {
|
||||||
struct entity_t const *const entity = &world->entities[i];
|
struct entity_t const *const entity = &world->entities[i];
|
||||||
struct entity_registrant_t const *const registrant =
|
struct entity_registrant_t const *const registrant =
|
||||||
|
@ -28,9 +28,19 @@ static enum error_t simulation_thread_body(struct game_data_t *data) {
|
|||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
|
||||||
// TODO: An actual game loop lol
|
// TODO: An actual game loop lol
|
||||||
printf("Hello, world!\n");
|
while (true) {
|
||||||
|
if (pthread_mutex_lock(&data->world_lock) != 0) goto error;
|
||||||
|
data->world.width = (data->world.width + 1) % 100;
|
||||||
|
data->world.height = (data->world.height + 1) % 100;
|
||||||
|
if (pthread_mutex_unlock(&data->world_lock) != 0) goto error;
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
|
|
||||||
|
error:
|
||||||
|
return ERR_MUTEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user