summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZoRo <dos21h@gmail.com>2020-09-05 21:12:46 +0100
committerZoRo <dos21h@gmail.com>2020-09-05 21:12:46 +0100
commita73c7a57888f0f44f298ec425fc5abd3cfcffd62 (patch)
treec94c1234940f12db0be18f2beef844bc5d616324
parent22726f1e87a4fa668b67f276b61231297931359f (diff)
downloadwasm_fractal-a73c7a57888f0f44f298ec425fc5abd3cfcffd62.tar.gz
wasm_fractal-a73c7a57888f0f44f298ec425fc5abd3cfcffd62.zip
Basic queue
-rw-r--r--Makefile2
-rw-r--r--fractal.c90
-rw-r--r--koh.h7
3 files changed, 92 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index dc702c4..7f8696f 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/fractal.c b/fractal.c
index dcab68b..98410d9 100644
--- a/fractal.c
+++ b/fractal.c
@@ -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;
}
diff --git a/koh.h b/koh.h
index 6018fb9..9c8208e 100644
--- a/koh.h
+++ b/koh.h
@@ -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