diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | fractal.c | 90 | ||||
-rw-r--r-- | koh.h | 7 |
3 files changed, 92 insertions, 7 deletions
@@ -4,4 +4,4 @@ CC=gcc make: $(CC) -c koh.c $(CC) -c fractal.c - $(CC) koh.o fractal.o -o fractal
\ No newline at end of file + $(CC) koh.o fractal.o -o fractal -lSDL2
\ No newline at end of file @@ -6,11 +6,97 @@ #include <stdint.h> #include <time.h> -#include <SDL/SDL.h> -#include <SDL/SDL_ttf.h> +#include <SDL2/SDL.h> + +#include "koh.h" +//#include "queue.h" + +#define SCREEN_WIDTH 160 +#define SCREEN_HEIGHT 160 + +static int quit=0; +static SDL_Window *window = NULL; +static SDL_Renderer *renderer = NULL; + +#define MAX_LEVEL 7 +#define QUEUE_SIZE (1+MAX_LEVEL*MAX_LEVEL*MAX_LEVEL*MAX_LEVEL) + +int queue_index=0; +koh_node koh_queue[QUEUE_SIZE]; + +void queue_init() +{ + int i; + queue_index = 0; + for (i=0;i<QUEUE_SIZE;i++) + { + koh_queue[i].generaton = 0; + koh_queue[i].size = 0; + koh_queue[i].x = 0; + koh_queue[i].y = 0; + } +} + + +void queue_add(koh_node kn) +{ + koh_queue[queue_index] = kn; + queue_index += 1; +} + + +koh_node queue_get(int idx) +{ + koh_node kn = {-1,-1,-1,-1}; + + if ((idx<0) || (idx>QUEUE_SIZE)) + { + return kn; + } + + kn = koh_queue[idx]; + + return kn; +} int main() { + SDL_Event event; + + printf("Max queue size %d\n", QUEUE_SIZE); + SDL_Init(SDL_INIT_VIDEO); + window = SDL_CreateWindow("KOH", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL); + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + SDL_SetRenderDrawColor(renderer, 0xff, 0x99, 0x99, 0x99); + + while (quit == 0) + { + while (SDL_PollEvent(&event)) + { + + switch (event.type) + { + case SDL_QUIT: + { + quit = 1; + break; + } + //case SDL_KE + } + + //sleep(1); + } + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + } + + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); + + return 0; } @@ -17,10 +17,9 @@ typedef struct typedef struct { - int x1,y1,x2,y2; - int level; - int r,g,b,a; - int invisible; + int x,y; + int generaton; + int size; } koh_node; #endif
\ No newline at end of file |