Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <pthread.h>
- #define world_x_size 53
- #define world_y_size 50
- struct Pixel
- {
- char what_here;
- };
- typedef struct Pixel pixelsArr[world_x_size];
- void create_world(pixelsArr *pixels)
- {
- int x = 0;
- int y = 0;
- while (y < world_y_size)
- {
- x = 0;
- while (x < world_x_size)
- {
- pixels[x][y].what_here = 'O';
- x++;
- }
- y++;
- }
- }
- void update_thread(pixelsArr *pixels)
- {
- while(1)
- {
- int x = 0;
- int y = 0;
- while (y < world_y_size)
- {
- char output[world_x_size + 1];
- x = 0;
- while (x < world_x_size)
- {
- output[x] = pixels[x][y].what_here;
- x++;
- }
- y++;
- printf(output);
- printf("\n");
- }
- printf('\033c');
- }
- return NULL;
- }
- int main()
- {
- pixelsArr pixels[world_y_size];
- create_world(pixels);
- pthread_t thread;
- pthread_create(&thread, NULL, update_thread, pixels);
- pthread_join(thread, NULL);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment