1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <stdint.h>
#include <time.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;
}
|