Compare commits
4 Commits
main
...
three_dee_
Author | SHA1 | Date |
---|---|---|
|
5ebca54038 | |
|
3383e8520e | |
|
b842806d0b | |
|
2a204c2e2c |
17
Makefile
17
Makefile
|
@ -4,25 +4,19 @@ LFLAGS = -lSDL2 -lSDL2_image -lm -lncurses
|
||||||
|
|
||||||
all: bin/back
|
all: bin/back
|
||||||
|
|
||||||
test-1: bin/back
|
|
||||||
bin/back templates_lv0.txt 27 0
|
|
||||||
|
|
||||||
test0: bin/back
|
test0: bin/back
|
||||||
bin/back templates.txt 48 1
|
bin/back templates.txt 47
|
||||||
|
|
||||||
test1: bin/back
|
test1: bin/back
|
||||||
bin/back templates_lv1.txt 18 1
|
bin/back templates_lv1.txt 14
|
||||||
|
|
||||||
test2: bin/back
|
test2: bin/back
|
||||||
bin/back templates_lv2.txt 52 1
|
bin/back templates_lv2.txt 52
|
||||||
|
|
||||||
test3: bin/back
|
test3: bin/back
|
||||||
bin/back templates_lv3.txt 33 1
|
bin/back templates_lv3.txt 33
|
||||||
|
|
||||||
test4: bin/back
|
bin/back: obj/main.o obj/generation.o obj/display.o obj/base.o obj/hash.o obj/move.o obj/threed.o
|
||||||
bin/back templates_lv4.txt 52 1
|
|
||||||
|
|
||||||
bin/back: obj/main.o obj/generation.o obj/display.o obj/base.o obj/hash.o obj/move.o
|
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
$(CC) $(FLAGS) $^ $(LFLAGS) -o $@
|
$(CC) $(FLAGS) $^ $(LFLAGS) -o $@
|
||||||
|
|
||||||
|
@ -36,6 +30,7 @@ obj/display.o: src/display.c
|
||||||
obj/base.o: src/base.c
|
obj/base.o: src/base.c
|
||||||
obj/hash.o: src/hash.c
|
obj/hash.o: src/hash.c
|
||||||
obj/move.o: src/move.c
|
obj/move.o: src/move.c
|
||||||
|
obj/threed.o: src/threed.c
|
||||||
|
|
||||||
.PHONY: clean mrproper
|
.PHONY: clean mrproper
|
||||||
|
|
||||||
|
|
18
README.md
18
README.md
|
@ -4,19 +4,7 @@
|
||||||
> zqsd : move
|
> zqsd : move
|
||||||
> TAB : exit
|
> TAB : exit
|
||||||
> p : zoom out
|
> p : zoom out
|
||||||
> m : zoom in
|
> m : zoom in
|
||||||
|
|
||||||
| EXECUTION |
|
| EXECUTION |
|
||||||
*make test-1 : extermly unorganized generation*
|
*make test0 : default template pool (small/medium-sized corridorq)*
|
||||||
*make test0 : default template pool (small/medium-sized corridors)*
|
*make test1 : more hallways but small corridors only*
|
||||||
*make test1 : large rooms with rotating walls*
|
|
||||||
*make test2 : more hallways but small corridors only*
|
|
||||||
*make test3 : long, wide hallways*
|
|
||||||
|
|
||||||
| TILE LIST |
|
|
||||||
> 0 : nothing
|
|
||||||
> 1 : wall
|
|
||||||
> 2 : CCW rotation wall
|
|
||||||
> 3 : CW rotation wall
|
|
||||||
> 4, 5, 6, 7 : translation wall (resp. +X, -X, +Y and -Y)
|
|
||||||
|
|
106
src/base.c
106
src/base.c
|
@ -68,6 +68,18 @@ int convex_seg(int x1, int x2, double theta) {
|
||||||
return (int)(((1.0f - theta) * x1 + theta * x2));
|
return (int)(((1.0f - theta) * x1 + theta * x2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double convex_seg_double(double x1, double x2, double theta) {
|
||||||
|
return ((1.0f - theta) * x1 + theta * x2);
|
||||||
|
}
|
||||||
|
|
||||||
|
pt_3d convex_3d(pt_3d p1, pt_3d p2, double theta) {
|
||||||
|
pt_3d res ;
|
||||||
|
res.x = convex_seg_double(p1.x, p2.x, theta);
|
||||||
|
res.y = convex_seg_double(p1.y, p2.z, theta);
|
||||||
|
res.z = convex_seg_double(p1.z, p2.z, theta);
|
||||||
|
return res ;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_an_integer(char c) {
|
bool is_an_integer(char c) {
|
||||||
return ((int)c >= 48 && (int)c <= 57);
|
return ((int)c >= 48 && (int)c <= 57);
|
||||||
}
|
}
|
||||||
|
@ -84,6 +96,11 @@ double distance_pt(int x1, int x2, int y1, int y2) {
|
||||||
return sqrt(to_double(pw(x2 - x1, 2) + pw(y2 - y1, 2)));
|
return sqrt(to_double(pw(x2 - x1, 2) + pw(y2 - y1, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double distance_pt_double(double x1, double x2, double y1, double y2) {
|
||||||
|
return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||||
|
}
|
||||||
|
|
||||||
int line_count(char* filename) {
|
int line_count(char* filename) {
|
||||||
FILE* ptr = fopen(filename, "r");
|
FILE* ptr = fopen(filename, "r");
|
||||||
char c = 'd';
|
char c = 'd';
|
||||||
|
@ -209,95 +226,6 @@ void pop(array* arr, int elt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool str_equal(char* s1, char* s2) {
|
|
||||||
if(s1[0] == '\0' || s2[0] == '\0') {
|
|
||||||
return (s1[0] == '\0' && s2[0] == '\0');
|
|
||||||
}
|
|
||||||
return (s1[0] == s2[0] && str_equal(&s1[1], &s2[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------ //
|
|
||||||
|
|
||||||
void linked_add(linkedList* lst, int x, int y, char* flag) {
|
|
||||||
if(lst == NULL) {
|
|
||||||
fprintf(stderr, "ERROR : linked list has not been initialized\n");
|
|
||||||
exit(1);
|
|
||||||
} else if(lst->next == NULL) {
|
|
||||||
lst->next = malloc(sizeof(linkedList));
|
|
||||||
lst->next->coord = x + 16*y ;
|
|
||||||
lst->next->flag = flag ;
|
|
||||||
lst->next->next = NULL ;
|
|
||||||
} else {
|
|
||||||
linked_add(lst->next, x, y, flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void linked_removeCoord(linkedList* lst, int x, int y) {
|
|
||||||
if(lst != NULL) {
|
|
||||||
if(lst->coord == x + 16*y) {
|
|
||||||
linkedList* temp = lst->next ;
|
|
||||||
free(lst) ;
|
|
||||||
lst = temp ;
|
|
||||||
} else {
|
|
||||||
linked_removeCoord(lst->next, x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void linked_removeFlag(linkedList* lst, char* flag) {
|
|
||||||
if(lst != NULL) {
|
|
||||||
if(lst->flag == flag) {
|
|
||||||
linkedList* temp = lst->next ;
|
|
||||||
free(lst) ;
|
|
||||||
lst = temp ;
|
|
||||||
} else {
|
|
||||||
linked_removeFlag(lst->next, flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void linked_change(linkedList* lst, int x, int y, char* flag) {
|
|
||||||
linked_removeCoord(lst, x, y);
|
|
||||||
linked_add(lst, x, y, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool linked_mem(linkedList* lst, int x, int y, char** flag) {
|
|
||||||
if(lst == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(lst->coord == x + 16*y) {
|
|
||||||
*flag = lst->flag;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
return linked_mem(lst->next, x, y, flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
linkedList* linked_copy(linkedList* src) {
|
|
||||||
linkedList* new = malloc(sizeof(linkedList)) ;
|
|
||||||
new->flag = "E" ;
|
|
||||||
new->coord = 0 ;
|
|
||||||
new->next = NULL ;
|
|
||||||
|
|
||||||
//printf("in\n");
|
|
||||||
linkedList* curSrc = src->next ;
|
|
||||||
//printf("out\n");
|
|
||||||
|
|
||||||
while(curSrc != NULL) {
|
|
||||||
//printf("cp\n");
|
|
||||||
linked_add(new, curSrc->coord%8, curSrc->coord/16, curSrc->flag);
|
|
||||||
curSrc = curSrc->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void linkedPrint(linkedList* lst) {
|
|
||||||
if(lst != NULL) {
|
|
||||||
printf("[(%d, %d), %s] ", lst->coord%8, lst->coord/16, lst->flag);
|
|
||||||
linkedPrint(lst->next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------ //
|
// ------------------------------------------------------------------------------------------------ //
|
||||||
|
|
||||||
void import_digits(SDL_Renderer* renderer) {
|
void import_digits(SDL_Renderer* renderer) {
|
||||||
|
|
22
src/base.h
22
src/base.h
|
@ -15,6 +15,10 @@ double absf(double n);
|
||||||
|
|
||||||
int convex_seg(int x1, int x2, double theta);
|
int convex_seg(int x1, int x2, double theta);
|
||||||
|
|
||||||
|
double convex_seg_double(double x1, double x2, double theta);
|
||||||
|
|
||||||
|
pt_3d convex_3d(pt_3d p1, pt_3d p2, double theta);
|
||||||
|
|
||||||
bool is_an_integer(char c);
|
bool is_an_integer(char c);
|
||||||
|
|
||||||
double to_double(int n);
|
double to_double(int n);
|
||||||
|
@ -23,6 +27,8 @@ int to_int(double n);
|
||||||
|
|
||||||
double distance_pt(int x1, int x2, int y1, int y2);
|
double distance_pt(int x1, int x2, int y1, int y2);
|
||||||
|
|
||||||
|
double distance_pt_double(double x1, double x2, double y1, double y2);
|
||||||
|
|
||||||
int line_count(char* filename);
|
int line_count(char* filename);
|
||||||
|
|
||||||
int str_to_int(char* s);
|
int str_to_int(char* s);
|
||||||
|
@ -47,22 +53,6 @@ void append(array* arr, int elt);
|
||||||
|
|
||||||
void pop(array* arr, int elt);
|
void pop(array* arr, int elt);
|
||||||
|
|
||||||
bool str_equal(char* s1, char* s2);
|
|
||||||
|
|
||||||
void linked_add(linkedList* lst, int x, int y, char* flag);
|
|
||||||
|
|
||||||
void linked_removeCoord(linkedList* lst, int x, int y);
|
|
||||||
|
|
||||||
void linked_removeFlag(linkedList* lst, char* flag);
|
|
||||||
|
|
||||||
void linked_change(linkedList* lst, int x, int y, char* flag);
|
|
||||||
|
|
||||||
bool linked_mem(linkedList* lst, int x, int y, char** flag);
|
|
||||||
|
|
||||||
linkedList* linked_copy(linkedList* src);
|
|
||||||
|
|
||||||
void linkedPrint(linkedList* lst);
|
|
||||||
|
|
||||||
void import_digits(SDL_Renderer* renderer);
|
void import_digits(SDL_Renderer* renderer);
|
||||||
|
|
||||||
void import_letters(SDL_Renderer* renderer);
|
void import_letters(SDL_Renderer* renderer);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "structure.h"
|
#include "structure.h"
|
||||||
#include "base.h"
|
#include "base.h"
|
||||||
#include "generation.h"
|
#include "generation.h"
|
||||||
|
#include "threed.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
void updateRenderer(SDL_Renderer* renderer) {
|
void updateRenderer(SDL_Renderer* renderer) {
|
||||||
|
@ -136,22 +137,6 @@ void drawStringToRenderer(SDL_Renderer* renderer, imgs data, char* s, int X, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void linked_draw(SDL_Renderer* renderer, linkedList* lst, int chx, int chy, int xmin, int xmax, int ymin, int ymax) {
|
|
||||||
if(lst != NULL) {
|
|
||||||
int cux = 50*(8*chx + lst->coord/16);
|
|
||||||
int cuy = 50*(8*chy + lst->coord%8);
|
|
||||||
int cux2 = 50*(8*chx + lst->coord/16+1);
|
|
||||||
int cuy2 = 50*(8*chy + lst->coord%8+1);
|
|
||||||
int nxmin = to_int((to_double(cux) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
|
|
||||||
int nymin = to_int((to_double(cuy) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
|
|
||||||
int nxmin2 = to_int((to_double(cux2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
|
|
||||||
int nymin2 = to_int((to_double(cuy2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
|
|
||||||
placeRectToRenderer(renderer, nxmin, nymin, nxmin2 - nxmin, nymin2 - nymin, 32+96*(str_equal(lst->flag, "spinCC")), 255, 32+96*(str_equal(lst->flag, "spinCW")), SDL_ALPHA_OPAQUE/2);
|
|
||||||
|
|
||||||
linked_draw(renderer, lst->next, chx, chy, xmin, xmax, ymin, ymax);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax) {
|
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax) {
|
||||||
if(ch->draw_id != draw_par) {
|
if(ch->draw_id != draw_par) {
|
||||||
ch->draw_id = draw_par ;
|
ch->draw_id = draw_par ;
|
||||||
|
@ -162,19 +147,24 @@ void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax,
|
||||||
int cuy = 50*(8*ch->chy + i);
|
int cuy = 50*(8*ch->chy + i);
|
||||||
int cux2 = 50*(8*ch->chx + j+1);
|
int cux2 = 50*(8*ch->chx + j+1);
|
||||||
int cuy2 = 50*(8*ch->chy + i+1);
|
int cuy2 = 50*(8*ch->chy + i+1);
|
||||||
int nxmin = to_int((to_double(cux) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
|
if(true) {
|
||||||
int nymin = to_int((to_double(cuy) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
|
if(cur%2 == 1) {
|
||||||
int nxmin2 = to_int((to_double(cux2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
|
int nxmin = to_int((to_double(cux) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
|
||||||
int nymin2 = to_int((to_double(cuy2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
|
int nymin = to_int((to_double(cuy) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
|
||||||
bool x = abs(ch->chx + ch->chy)%2 == 0 ;
|
int nxmin2 = to_int((to_double(cux2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
|
||||||
placeRectToRenderer(renderer, nxmin, nymin, nxmin2 - nxmin, nymin2 - nymin, 192+63*(1-x)*(ch->chdata.meta->next != NULL), 192+63*x*(ch->chdata.meta->next != NULL), 32, SDL_ALPHA_OPAQUE/(1+3*(cur%2 == 0)));
|
int nymin2 = to_int((to_double(cuy2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
|
||||||
cur = cur / 2 ;
|
if(abs(ch->chx + ch->chy)%2 == 0) {
|
||||||
|
placeRectToRenderer(renderer, nxmin, nymin, nxmin2 - nxmin, nymin2 - nymin, 255, 192, 192, SDL_ALPHA_OPAQUE);
|
||||||
|
} else {
|
||||||
|
placeRectToRenderer(renderer, nxmin, nymin, nxmin2 - nxmin, nymin2 - nymin, 192, 192, 255, SDL_ALPHA_OPAQUE);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
cur = cur / 2 ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
linked_draw(renderer, ch->chdata.meta->next, ch->chx, ch->chy, xmin, xmax, ymin, ymax);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// branchless goes brrr
|
|
||||||
|
|
||||||
void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty) {
|
void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty) {
|
||||||
if(distx < render_distance && disty < render_distance) {
|
if(distx < render_distance && disty < render_distance) {
|
||||||
|
|
|
@ -21,8 +21,6 @@ void drawNumberToRenderer(SDL_Renderer* renderer, imgs data, int n, int X, int Y
|
||||||
|
|
||||||
void drawStringToRenderer(SDL_Renderer* renderer, imgs data, char* s, int X, int Y, int W, int H);
|
void drawStringToRenderer(SDL_Renderer* renderer, imgs data, char* s, int X, int Y, int W, int H);
|
||||||
|
|
||||||
void linked_draw(SDL_Renderer* renderer, linkedList* lst, int chx, int chy, int xmin, int xmax, int ymin, int ymax);
|
|
||||||
|
|
||||||
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax);
|
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax);
|
||||||
|
|
||||||
void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty);
|
void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty);
|
||||||
|
|
308
src/generation.c
308
src/generation.c
|
@ -20,9 +20,6 @@
|
||||||
|
|
||||||
Grid map ;
|
Grid map ;
|
||||||
|
|
||||||
int emptyChance = 75 ; // 1 out of this number for empty chunk override
|
|
||||||
int sizeIncreaseChance = 15 ; // % for an empty chunk to increase in size
|
|
||||||
|
|
||||||
template* configs ;
|
template* configs ;
|
||||||
array** matches ;
|
array** matches ;
|
||||||
int n_configs = 18;
|
int n_configs = 18;
|
||||||
|
@ -45,12 +42,6 @@ imgs digits ;
|
||||||
imgs letters ;
|
imgs letters ;
|
||||||
|
|
||||||
template full ;
|
template full ;
|
||||||
template empty ;
|
|
||||||
|
|
||||||
linkedList* endLst ;
|
|
||||||
|
|
||||||
char** level_list ;
|
|
||||||
int level_count ;
|
|
||||||
|
|
||||||
// yes Valentin I learned to use .h the intended way xD
|
// yes Valentin I learned to use .h the intended way xD
|
||||||
|
|
||||||
|
@ -65,8 +56,6 @@ template copy(template src) {
|
||||||
new.id = src.id ;
|
new.id = src.id ;
|
||||||
new.eastsig = src.eastsig;
|
new.eastsig = src.eastsig;
|
||||||
new.westsig = src.westsig;
|
new.westsig = src.westsig;
|
||||||
new.checkCompat = src.checkCompat ;
|
|
||||||
new.meta = linked_copy(src.meta);
|
|
||||||
new.lines = malloc(sizeof(uint8_t)*8);
|
new.lines = malloc(sizeof(uint8_t)*8);
|
||||||
for(int i = 0; i < 8; i++) {
|
for(int i = 0; i < 8; i++) {
|
||||||
new.lines[i] = src.lines[i];
|
new.lines[i] = src.lines[i];
|
||||||
|
@ -88,16 +77,6 @@ void generate_chunk(int x, int y, int config_id) {
|
||||||
gridInsert(map, x, y, new);
|
gridInsert(map, x, y, new);
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_chunk_raw(int x, int y, template tpl) {
|
|
||||||
chunk* new = malloc(sizeof(chunk)) ;
|
|
||||||
new->chx = x ;
|
|
||||||
new->chy = y ;
|
|
||||||
new->draw_id = draw_par - 2;
|
|
||||||
new->chdata = copy(tpl);
|
|
||||||
//printf("%d\n", new->chdata.checkCompat);
|
|
||||||
gridInsert(map, x, y, new);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_template(int config_id) {
|
void print_template(int config_id) {
|
||||||
for(int i = 0; i < 8; i++) {
|
for(int i = 0; i < 8; i++) {
|
||||||
uint8_t rem = configs[config_id].lines[i];
|
uint8_t rem = configs[config_id].lines[i];
|
||||||
|
@ -114,15 +93,7 @@ void print_template(int config_id) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void rotateLinkedListCounterClockWise(linkedList* lst) {
|
void rotateTemplateClockWise(int config_id) {
|
||||||
if(lst != NULL) {
|
|
||||||
uint8_t newc = (lst->coord/16) + 16 * (7- (lst->coord%8));
|
|
||||||
lst->coord = newc ;
|
|
||||||
rotateLinkedListCounterClockWise(lst->next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void rotateTemplateCounterClockWise(int config_id) {
|
|
||||||
// 1st line become last column ... last line become 1st column
|
// 1st line become last column ... last line become 1st column
|
||||||
uint8_t* new = malloc(sizeof(uint8_t)*8);
|
uint8_t* new = malloc(sizeof(uint8_t)*8);
|
||||||
|
|
||||||
|
@ -142,141 +113,16 @@ void rotateTemplateCounterClockWise(int config_id) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
rotateLinkedListCounterClockWise(configs[config_id].meta);
|
if(config_id >= 9 ) {
|
||||||
|
//print_template(config_id);
|
||||||
|
}
|
||||||
|
|
||||||
free(new);
|
free(new);
|
||||||
}
|
}
|
||||||
|
|
||||||
void transateLinkedList(linkedList* lst, int dy, int dx) {
|
|
||||||
if(lst != NULL) {
|
|
||||||
lst->coord = ((lst->coord%8) + dx + 8)%8 + 16*(((lst->coord/16) + dy + 8)%8) ;
|
|
||||||
transateLinkedList(lst->next, dy, dx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------- //
|
|
||||||
|
|
||||||
void rotateChunkCounterClockWise(int chx, int chy) {
|
|
||||||
chunk* ch = gridGet(map, chx, chy);
|
|
||||||
if(ch == NULL) {
|
|
||||||
fprintf(stderr, "ERROR : cannot rotate non-existing chunk\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
// 1st line become last column ... last line become 1st column
|
|
||||||
uint8_t* new = malloc(sizeof(uint8_t)*8);
|
|
||||||
|
|
||||||
ch->chdata.westsig = ch->chdata.lines[7];
|
|
||||||
ch->chdata.eastsig = ch->chdata.lines[0];
|
|
||||||
|
|
||||||
for(int i = 0; i < 8; i++) {
|
|
||||||
new[i] = ch->chdata.lines[i];
|
|
||||||
ch->chdata.lines[i] = 0;
|
|
||||||
};
|
|
||||||
for(int i = 0; i < 8; i++) {
|
|
||||||
uint8_t rem = new[i];
|
|
||||||
for(int j = 0; j < 8; j++) {
|
|
||||||
ch->chdata.lines[j] *= 2 ;
|
|
||||||
ch->chdata.lines[j] += rem%2 ;
|
|
||||||
rem = rem / 2 ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
rotateLinkedListCounterClockWise(ch->chdata.meta);
|
|
||||||
|
|
||||||
free(new);
|
|
||||||
}
|
|
||||||
|
|
||||||
void translateChunkX(int chx, int chy) {
|
|
||||||
chunk* ch = gridGet(map, chx, chy);
|
|
||||||
if(ch == NULL) {
|
|
||||||
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ch->chdata.eastsig = 0 ;
|
|
||||||
ch->chdata.westsig = 0 ;
|
|
||||||
|
|
||||||
for(int i = 7; i >= 0; i--) {
|
|
||||||
ch->chdata.eastsig *= 2 ;
|
|
||||||
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 6, i));
|
|
||||||
|
|
||||||
ch->chdata.westsig *= 2 ;
|
|
||||||
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 7, i));
|
|
||||||
}
|
|
||||||
for(int i = 0; i < 8; i++) {
|
|
||||||
ch->chdata.lines[i] = (2*ch->chdata.lines[i] + ch->chdata.lines[i]/128)%256 ;
|
|
||||||
}
|
|
||||||
transateLinkedList(ch->chdata.meta->next, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void translateChunk_X(int chx, int chy) {
|
|
||||||
chunk* ch = gridGet(map, chx, chy);
|
|
||||||
if(ch == NULL) {
|
|
||||||
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ch->chdata.eastsig = 0 ;
|
|
||||||
ch->chdata.westsig = 0 ;
|
|
||||||
|
|
||||||
for(int i = 7; i >= 0; i--) {
|
|
||||||
ch->chdata.eastsig *= 2 ;
|
|
||||||
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 0, i));
|
|
||||||
|
|
||||||
ch->chdata.westsig *= 2 ;
|
|
||||||
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 1, i));
|
|
||||||
}
|
|
||||||
for(int i = 0; i < 8; i++) {
|
|
||||||
ch->chdata.lines[i] = ((ch->chdata.lines[i])/2 + 128*(ch->chdata.lines[i]%2))%256 ;
|
|
||||||
}
|
|
||||||
transateLinkedList(ch->chdata.meta->next, -1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void translateChunkY(int chx, int chy) {
|
|
||||||
chunk* ch = gridGet(map, chx, chy);
|
|
||||||
if(ch == NULL) {
|
|
||||||
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ch->chdata.eastsig = (2*ch->chdata.eastsig + ch->chdata.eastsig/128)%256;
|
|
||||||
ch->chdata.westsig = (2*ch->chdata.westsig + ch->chdata.westsig/128)%256;
|
|
||||||
|
|
||||||
uint8_t temp = ch->chdata.lines[0] ;
|
|
||||||
|
|
||||||
for(int i = 0; i < 7; i++) {
|
|
||||||
ch->chdata.lines[i] = ch->chdata.lines[i+1] ;
|
|
||||||
}
|
|
||||||
ch->chdata.lines[7] = temp ;
|
|
||||||
|
|
||||||
transateLinkedList(ch->chdata.meta->next, 0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void translateChunk_Y(int chx, int chy) {
|
|
||||||
chunk* ch = gridGet(map, chx, chy);
|
|
||||||
if(ch == NULL) {
|
|
||||||
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ch->chdata.eastsig = (2*ch->chdata.eastsig + ch->chdata.eastsig/128)%256;
|
|
||||||
ch->chdata.westsig = (2*ch->chdata.westsig + ch->chdata.westsig/128)%256;
|
|
||||||
|
|
||||||
uint8_t temp = ch->chdata.lines[7] ;
|
|
||||||
|
|
||||||
for(int i = 6; i >= 0; i--) {
|
|
||||||
ch->chdata.lines[i+1] = ch->chdata.lines[i] ;
|
|
||||||
}
|
|
||||||
ch->chdata.lines[0] = temp ;
|
|
||||||
|
|
||||||
transateLinkedList(ch->chdata.meta->next, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------- //
|
|
||||||
|
|
||||||
bool is_compat_sig_north(int cx, int cy, int idx) {
|
bool is_compat_sig_north(int cx, int cy, int idx) {
|
||||||
chunk* cp = gridGet(map, cx, cy-1);
|
chunk* cp = gridGet(map, cx, cy-1);
|
||||||
if(cp == NULL || !cp->chdata.checkCompat) {
|
if(cp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return cp->chdata.lines[7] == configs[idx].lines[0];
|
return cp->chdata.lines[7] == configs[idx].lines[0];
|
||||||
|
@ -284,7 +130,7 @@ bool is_compat_sig_north(int cx, int cy, int idx) {
|
||||||
}
|
}
|
||||||
bool is_compat_sig_south(int cx, int cy, int idx) {
|
bool is_compat_sig_south(int cx, int cy, int idx) {
|
||||||
chunk* cp = gridGet(map, cx, cy+1);
|
chunk* cp = gridGet(map, cx, cy+1);
|
||||||
if(cp == NULL || !cp->chdata.checkCompat) {
|
if(cp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return cp->chdata.lines[0] == configs[idx].lines[7];
|
return cp->chdata.lines[0] == configs[idx].lines[7];
|
||||||
|
@ -292,7 +138,7 @@ bool is_compat_sig_south(int cx, int cy, int idx) {
|
||||||
}
|
}
|
||||||
bool is_compat_sig_east(int cx, int cy, int idx) {
|
bool is_compat_sig_east(int cx, int cy, int idx) {
|
||||||
chunk* cp = gridGet(map, cx+1, cy);
|
chunk* cp = gridGet(map, cx+1, cy);
|
||||||
if(cp == NULL || !cp->chdata.checkCompat) {
|
if(cp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return cp->chdata.westsig == configs[idx].eastsig;
|
return cp->chdata.westsig == configs[idx].eastsig;
|
||||||
|
@ -300,7 +146,7 @@ bool is_compat_sig_east(int cx, int cy, int idx) {
|
||||||
}
|
}
|
||||||
bool is_compat_sig_west(int cx, int cy, int idx) {
|
bool is_compat_sig_west(int cx, int cy, int idx) {
|
||||||
chunk* cp = gridGet(map, cx-1, cy);
|
chunk* cp = gridGet(map, cx-1, cy);
|
||||||
if(cp == NULL || !cp->chdata.checkCompat) {
|
if(cp == NULL) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return cp->chdata.eastsig == configs[idx].westsig;
|
return cp->chdata.eastsig == configs[idx].westsig;
|
||||||
|
@ -319,7 +165,7 @@ bool is_compat_with_spins(int cx, int cy, int idx) {
|
||||||
if(is_compat_sig_north(cx, cy, idx) && is_compat_sig_east(cx, cy, idx) && is_compat_sig_south(cx, cy, idx) && is_compat_sig_west(cx, cy, idx)) {
|
if(is_compat_sig_north(cx, cy, idx) && is_compat_sig_east(cx, cy, idx) && is_compat_sig_south(cx, cy, idx) && is_compat_sig_west(cx, cy, idx)) {
|
||||||
return true ;
|
return true ;
|
||||||
} else {
|
} else {
|
||||||
rotateTemplateCounterClockWise(idx);
|
rotateTemplateClockWise(idx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return false;
|
return false;
|
||||||
|
@ -329,7 +175,7 @@ bool is_compat_with_spins_uno(int cx, int cy, int idx) {
|
||||||
if(is_compat_sig_north(cx, cy, idx) && is_compat_sig_east(cx, cy, idx) && is_compat_sig_south(cx, cy, idx) && is_compat_sig_west(cx, cy, idx)) {
|
if(is_compat_sig_north(cx, cy, idx) && is_compat_sig_east(cx, cy, idx) && is_compat_sig_south(cx, cy, idx) && is_compat_sig_west(cx, cy, idx)) {
|
||||||
return true ;
|
return true ;
|
||||||
} else {
|
} else {
|
||||||
rotateTemplateCounterClockWise(idx);
|
rotateTemplateClockWise(idx);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,7 +186,7 @@ void generate_chunk_all(int cx, int cy) {
|
||||||
int turn = 0 ;
|
int turn = 0 ;
|
||||||
int k = 0 ;
|
int k = 0 ;
|
||||||
while(i > 0) {
|
while(i > 0) {
|
||||||
if(turn > 50*n_configs) {
|
if(turn > 100*n_configs) {
|
||||||
i = 0 ;
|
i = 0 ;
|
||||||
idx = 0 ;
|
idx = 0 ;
|
||||||
printf("failed\n");
|
printf("failed\n");
|
||||||
|
@ -348,12 +194,8 @@ void generate_chunk_all(int cx, int cy) {
|
||||||
if(is_compat_with_spins_uno(cx, cy, idx)) {
|
if(is_compat_with_spins_uno(cx, cy, idx)) {
|
||||||
i -= 1;
|
i -= 1;
|
||||||
if(i != 0) {
|
if(i != 0) {
|
||||||
rotateTemplateCounterClockWise(idx);
|
|
||||||
if(k == 3) {
|
if(k == 3) {
|
||||||
idx += 1;
|
idx = (idx+1)%n_configs;
|
||||||
if(idx == n_configs) {
|
|
||||||
idx = 1;
|
|
||||||
};
|
|
||||||
k = 0 ;
|
k = 0 ;
|
||||||
} else {
|
} else {
|
||||||
k++ ;
|
k++ ;
|
||||||
|
@ -373,31 +215,9 @@ void generate_chunk_all(int cx, int cy) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int R = rand()%emptyChance;
|
//printf("generating %d at (%d, %d)...\n", idx, cx, cy);
|
||||||
if(R != 0) {
|
//print_template(idx);
|
||||||
generate_chunk(cx, cy, idx);
|
generate_chunk(cx, cy, idx);
|
||||||
} else {
|
|
||||||
generate_chunk_raw(cx, cy, empty);
|
|
||||||
if(rand()%100 < sizeIncreaseChance) {
|
|
||||||
if(!(gridMem(map, cx+1, cy) || gridMem(map, cx+1, cy+1) || gridMem(map, cx, cy+1))) {
|
|
||||||
generate_chunk_raw(cx+1, cy, empty);
|
|
||||||
generate_chunk_raw(cx, cy+1, empty);
|
|
||||||
generate_chunk_raw(cx+1, cy+1, empty);
|
|
||||||
} else if(!(gridMem(map, cx+1, cy) || gridMem(map, cx+1, cy-1) || gridMem(map, cx, cy-1))) {
|
|
||||||
generate_chunk_raw(cx+1, cy, empty);
|
|
||||||
generate_chunk_raw(cx, cy-1, empty);
|
|
||||||
generate_chunk_raw(cx+1, cy-1, empty);
|
|
||||||
} else if(!(gridMem(map, cx-1, cy) || gridMem(map, cx-1, cy-1) || gridMem(map, cx, cy-1))) {
|
|
||||||
generate_chunk_raw(cx-1, cy, empty);
|
|
||||||
generate_chunk_raw(cx, cy-1, empty);
|
|
||||||
generate_chunk_raw(cx-1, cy-1, empty);
|
|
||||||
} else if(!(gridMem(map, cx-1, cy) || gridMem(map, cx-1, cy+1) || gridMem(map, cx, cy+1))) {
|
|
||||||
generate_chunk_raw(cx-1, cy, empty);
|
|
||||||
generate_chunk_raw(cx, cy+1, empty);
|
|
||||||
generate_chunk_raw(cx-1, cy+1, empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize(SDL_Renderer* renderer) {
|
void initialize(SDL_Renderer* renderer) {
|
||||||
|
@ -407,58 +227,11 @@ void initialize(SDL_Renderer* renderer) {
|
||||||
import_digits(renderer);
|
import_digits(renderer);
|
||||||
|
|
||||||
full.lines = malloc(sizeof(uint8_t)*8);
|
full.lines = malloc(sizeof(uint8_t)*8);
|
||||||
full.westsig = 255 ;
|
|
||||||
full.eastsig = 255 ;
|
|
||||||
|
|
||||||
full.meta = malloc(sizeof(linkedList)) ;
|
|
||||||
full.meta->flag = "E" ;
|
|
||||||
full.meta->coord = 0 ;
|
|
||||||
full.meta->next = NULL ;
|
|
||||||
|
|
||||||
full.checkCompat = false ;
|
|
||||||
|
|
||||||
for(int i = 0; i < 8; i++) {
|
for(int i = 0; i < 8; i++) {
|
||||||
full.lines[i] = 255 ;
|
full.lines[i] = 255 ;
|
||||||
};
|
};
|
||||||
full.id = -1 ;
|
full.id = -1 ;
|
||||||
|
|
||||||
empty.lines = malloc(sizeof(uint8_t)*8);
|
|
||||||
empty.westsig = 0 ;
|
|
||||||
empty.eastsig = 0 ;
|
|
||||||
|
|
||||||
empty.checkCompat = false ;
|
|
||||||
|
|
||||||
empty.lines[0] = 0 ;
|
|
||||||
empty.lines[1] = 0 ;
|
|
||||||
empty.lines[2] = 0 ;
|
|
||||||
empty.lines[3] = 24 ;
|
|
||||||
empty.lines[4] = 24 ;
|
|
||||||
empty.lines[5] = 0 ;
|
|
||||||
empty.lines[6] = 0 ;
|
|
||||||
empty.lines[7] = 0 ;
|
|
||||||
|
|
||||||
empty.id = -1 ;
|
|
||||||
|
|
||||||
empty.meta = malloc(sizeof(linkedList)) ;
|
|
||||||
empty.meta->flag = "E" ;
|
|
||||||
empty.meta->coord = 0 ;
|
|
||||||
empty.meta->next = NULL ;
|
|
||||||
|
|
||||||
endLst = malloc(sizeof(linkedList));
|
|
||||||
endLst->flag = "E";
|
|
||||||
endLst->coord = 0 ;
|
|
||||||
endLst->next = NULL ;
|
|
||||||
|
|
||||||
level_count = 6 ;
|
|
||||||
level_list = malloc(sizeof(char*)*level_count);
|
|
||||||
|
|
||||||
level_list[0] = "templates_lv0.txt";
|
|
||||||
level_list[1] = "templates.txt";
|
|
||||||
level_list[2] = "templates_lv1.txt";
|
|
||||||
level_list[3] = "templates_lv2.txt";
|
|
||||||
level_list[4] = "templates_lv3.txt";
|
|
||||||
level_list[5] = "templates_lv4.txt";
|
|
||||||
|
|
||||||
generate_chunk(0, 0, 2);
|
generate_chunk(0, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,10 +241,7 @@ void destroy() {
|
||||||
free_digits(digits);
|
free_digits(digits);
|
||||||
free_digits(letters);
|
free_digits(letters);
|
||||||
|
|
||||||
free(level_list);
|
|
||||||
|
|
||||||
free(full.lines);
|
free(full.lines);
|
||||||
free(empty.lines);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_one(FILE* ptr, FILE* ptr2, int index) {
|
void parse_one(FILE* ptr, FILE* ptr2, int index) {
|
||||||
|
@ -479,31 +249,15 @@ void parse_one(FILE* ptr, FILE* ptr2, int index) {
|
||||||
for(int j = 0; j < 8; j++) {
|
for(int j = 0; j < 8; j++) {
|
||||||
int xres = get_integer_plus_align(ptr, ptr2);
|
int xres = get_integer_plus_align(ptr, ptr2);
|
||||||
configs[index].lines[i] *= 2 ;
|
configs[index].lines[i] *= 2 ;
|
||||||
configs[index].lines[i] += (xres > 0) ;
|
configs[index].lines[i] += xres ;
|
||||||
|
|
||||||
if(xres == 2) {
|
|
||||||
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
|
|
||||||
linked_add(configs[index].meta, i, 7-j, "spinCC");
|
|
||||||
} else if(xres == 3) {
|
|
||||||
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
|
|
||||||
linked_add(configs[index].meta, i, 7-j, "spinCW");
|
|
||||||
} else if(xres == 4) {
|
|
||||||
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
|
|
||||||
linked_add(configs[index].meta, i, 7-j, "beltX");
|
|
||||||
} else if(xres == 5) {
|
|
||||||
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
|
|
||||||
linked_add(configs[index].meta, i, 7-j, "belt-X");
|
|
||||||
} else if(xres == 6) {
|
|
||||||
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
|
|
||||||
linked_add(configs[index].meta, i, 7-j, "beltY");
|
|
||||||
} else if(xres == 7) {
|
|
||||||
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
|
|
||||||
linked_add(configs[index].meta, i, 7-j, "belt-Y");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(j == 7) {
|
if(j == 7) {
|
||||||
|
//configs[index].westsig *= 2;
|
||||||
|
//configs[index].westsig += xres;
|
||||||
configs[index].westsig += pw(2, i) * xres ;
|
configs[index].westsig += pw(2, i) * xres ;
|
||||||
} else if(j == 0) {
|
} else if(j == 0) {
|
||||||
|
//configs[index].eastsig *= 2;
|
||||||
|
//configs[index].eastsig += xres;
|
||||||
configs[index].eastsig += pw(2, i) * xres ;
|
configs[index].eastsig += pw(2, i) * xres ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,9 +269,7 @@ void parse_one(FILE* ptr, FILE* ptr2, int index) {
|
||||||
printf("-----| Template %d (line %d) |-----\n", index, 9*index);
|
printf("-----| Template %d (line %d) |-----\n", index, 9*index);
|
||||||
print_template(index);
|
print_template(index);
|
||||||
printf("sigs : (%d, %d, %d, %d) (N, E, S, W)\n", configs[index].lines[0], configs[index].eastsig, configs[index].lines[7], configs[index].westsig);
|
printf("sigs : (%d, %d, %d, %d) (N, E, S, W)\n", configs[index].lines[0], configs[index].eastsig, configs[index].lines[7], configs[index].westsig);
|
||||||
printf("SP : ");
|
printf("\n");
|
||||||
linkedPrint(configs[index].meta);
|
|
||||||
printf("\n-----------------------------------\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_configs(char* filename, int n_conf) {
|
void parse_configs(char* filename, int n_conf) {
|
||||||
|
@ -531,13 +283,6 @@ void parse_configs(char* filename, int n_conf) {
|
||||||
configs[i].id = i;
|
configs[i].id = i;
|
||||||
configs[i].eastsig = 0 ;
|
configs[i].eastsig = 0 ;
|
||||||
configs[i].westsig = 0 ;
|
configs[i].westsig = 0 ;
|
||||||
configs[i].checkCompat = doCheck ;
|
|
||||||
|
|
||||||
configs[i].meta = malloc(sizeof(linkedList)) ;
|
|
||||||
configs[i].meta->flag = "E" ;
|
|
||||||
configs[i].meta->coord = 0 ;
|
|
||||||
configs[i].meta->next = NULL ;
|
|
||||||
|
|
||||||
configs[i].lines = malloc(sizeof(uint8_t)*8);
|
configs[i].lines = malloc(sizeof(uint8_t)*8);
|
||||||
for(int j = 0; j < 8; j++) {
|
for(int j = 0; j < 8; j++) {
|
||||||
configs[i].lines[j] = 0;
|
configs[i].lines[j] = 0;
|
||||||
|
@ -548,18 +293,7 @@ void parse_configs(char* filename, int n_conf) {
|
||||||
FILE* ptr = fopen(filename, "r");
|
FILE* ptr = fopen(filename, "r");
|
||||||
FILE* ptr2 = fopen(filename, "r");
|
FILE* ptr2 = fopen(filename, "r");
|
||||||
|
|
||||||
// one pointer for data
|
|
||||||
// one pointer for counting
|
|
||||||
|
|
||||||
for(int k = 0; k < n_conf; k++) {
|
for(int k = 0; k < n_conf; k++) {
|
||||||
parse_one(ptr, ptr2, k);
|
parse_one(ptr, ptr2, k);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void change_configs(char* new_filename, int n_conf) {
|
|
||||||
for(int i = 0; i < n_conf; i++) {
|
|
||||||
free(configs[i].lines);
|
|
||||||
}
|
|
||||||
free(configs);
|
|
||||||
parse_configs(new_filename, n_conf);
|
|
||||||
}
|
}
|
|
@ -5,21 +5,9 @@ bool unpack_coord(uint8_t* lines, int cx, int cy);
|
||||||
|
|
||||||
void generate_chunk(int x, int y, int config_id);
|
void generate_chunk(int x, int y, int config_id);
|
||||||
|
|
||||||
void generate_chunk_raw(int x, int y, template tpl);
|
|
||||||
|
|
||||||
void print_template(int config_id);
|
void print_template(int config_id);
|
||||||
|
|
||||||
void rotateTemplateCounterClockWise(int config_id);
|
void rotateTemplateClockWise(int config_id);
|
||||||
|
|
||||||
void rotateChunkCounterClockWise(int chx, int chy);
|
|
||||||
|
|
||||||
void translateChunkX(int chx, int chy);
|
|
||||||
|
|
||||||
void translateChunk_X(int chx, int chy);
|
|
||||||
|
|
||||||
void translateChunkY(int chx, int chy);
|
|
||||||
|
|
||||||
void translateChunk_Y(int chx, int chy);
|
|
||||||
|
|
||||||
void signature(template t);
|
void signature(template t);
|
||||||
|
|
||||||
|
@ -33,6 +21,4 @@ void destroy();
|
||||||
|
|
||||||
void parse_configs(char* filename, int n_conf);
|
void parse_configs(char* filename, int n_conf);
|
||||||
|
|
||||||
void change_configs(char* new_filename, int n_conf);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
10
src/hash.h
10
src/hash.h
|
@ -4,22 +4,12 @@
|
||||||
#define GRID_H
|
#define GRID_H
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef struct linkedList {
|
|
||||||
uint8_t coord ; // coord%8 = x ; coord/16 = y
|
|
||||||
char* flag ;
|
|
||||||
struct linkedList* next ;
|
|
||||||
} linkedList ;
|
|
||||||
|
|
||||||
typedef struct template {
|
typedef struct template {
|
||||||
uint8_t id ;
|
uint8_t id ;
|
||||||
uint8_t* lines ; // len = 8
|
uint8_t* lines ; // len = 8
|
||||||
|
|
||||||
bool checkCompat ;
|
|
||||||
|
|
||||||
uint8_t eastsig ;
|
uint8_t eastsig ;
|
||||||
uint8_t westsig ;
|
uint8_t westsig ;
|
||||||
|
|
||||||
linkedList* meta ;
|
|
||||||
} template ;
|
} template ;
|
||||||
|
|
||||||
typedef struct chunk {
|
typedef struct chunk {
|
||||||
|
|
36
src/main.c
36
src/main.c
|
@ -16,20 +16,18 @@
|
||||||
#include "base.h"
|
#include "base.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "generation.h"
|
#include "generation.h"
|
||||||
|
#include "threed.h"
|
||||||
#include "move.h"
|
#include "move.h"
|
||||||
|
|
||||||
bool doCheck ;
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
if(argc != 4) {
|
if(argc != 3) {
|
||||||
fprintf(stderr, "usage : bin/back <template_pool> <n_templates> <ckeckSideCompat>\n");
|
fprintf(stderr, "usage : bin/back <template_pool> <n_templates>\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
char* filename = argv[1];
|
char* filename = argv[1];
|
||||||
int length = str_to_int(argv[2]);
|
int length = str_to_int(argv[2]);
|
||||||
doCheck = (bool)((int)argv[3][0] - 48);
|
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
|
@ -58,6 +56,8 @@ int main(int argc, char** argv) {
|
||||||
parse_configs(filename, length);
|
parse_configs(filename, length);
|
||||||
|
|
||||||
initialize(rend);
|
initialize(rend);
|
||||||
|
init_3d();
|
||||||
|
init_sincos();
|
||||||
|
|
||||||
int temp = render_distance ;
|
int temp = render_distance ;
|
||||||
for(int i = 1; i <= temp; i++) {
|
for(int i = 1; i <= temp; i++) {
|
||||||
|
@ -66,9 +66,33 @@ int main(int argc, char** argv) {
|
||||||
drawMapToRenderer(rend, -300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), 300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), -300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)), 300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)));
|
drawMapToRenderer(rend, -300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), 300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), -300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)), 300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)));
|
||||||
};
|
};
|
||||||
|
|
||||||
moveFunctionMaster(rend);
|
printf("entering\n");
|
||||||
|
|
||||||
|
pt_3d p1 ;
|
||||||
|
pt_3d p2 ;
|
||||||
|
pt_3d p3 ;
|
||||||
|
pt_3d p4 ;
|
||||||
|
|
||||||
|
p1.x = 0.0 ; p1.y = 0.0 ; p1.z = 1.0 ;
|
||||||
|
p2.x = 12.0 ; p2.y = 0.0 ; p2.z = 1.0 ;
|
||||||
|
p3.x = 12.0 ; p3.y = 8.0 ; p3.z = 1.0 ;
|
||||||
|
p4.x = 0.0 ; p4.y = 8.0 ; p4.z = 1.0 ;
|
||||||
|
|
||||||
|
for(int i = 0; i < 359; i++) {
|
||||||
|
resetBuffer();
|
||||||
|
project_rectangle(p1, p2, p3, p4);
|
||||||
|
bufferUpdateRenderer(rend);
|
||||||
|
three_angle = i+1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("pass\n");
|
||||||
|
usleep(3000000);
|
||||||
|
|
||||||
|
//moveFunctionMaster(rend);
|
||||||
|
|
||||||
destroy();
|
destroy();
|
||||||
|
destroy_3d();
|
||||||
|
destroy_sincos();
|
||||||
|
|
||||||
/* -------------------------------------------------------- */
|
/* -------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
186
src/move.c
186
src/move.c
|
@ -19,11 +19,66 @@
|
||||||
#include "move.h"
|
#include "move.h"
|
||||||
|
|
||||||
double speed = 0.5 ;
|
double speed = 0.5 ;
|
||||||
int precision = 8 ;
|
int precision = 12 ;
|
||||||
|
|
||||||
double εx = 0.0;
|
double εx = 0.0;
|
||||||
double εy = 0.0;
|
double εy = 0.0;
|
||||||
|
|
||||||
|
bool checkCollision() {
|
||||||
|
return (unpack_coord(gridGet(map, player_cx, player_cy)->chdata.lines, player_x, player_y));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkCollision2(int cx, int cy, int x, int y) {
|
||||||
|
return (unpack_coord(gridGet(map, cx, cy)->chdata.lines, x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
void normalize(int* ch_coord, int* coord, double* ε) {
|
||||||
|
if(*ε >= 1.0) {
|
||||||
|
*ε -= 1.0 ;
|
||||||
|
*coord += 1 ;
|
||||||
|
if(*coord >= 8) {
|
||||||
|
*coord -= 8 ;
|
||||||
|
*ch_coord += 1;
|
||||||
|
}
|
||||||
|
} else if(*ε < 0.0) {
|
||||||
|
*ε += 1.0 ;
|
||||||
|
*coord -= 1 ;
|
||||||
|
if(*coord < 0) {
|
||||||
|
*coord += 8 ;
|
||||||
|
*ch_coord -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkCollisionSquare(double square_size) {
|
||||||
|
double εxmin = εx - square_size;
|
||||||
|
double εxmax = εx + square_size;
|
||||||
|
double εymin = εy - square_size;
|
||||||
|
double εymax = εy + square_size;
|
||||||
|
|
||||||
|
int xmin = player_x ;
|
||||||
|
int xmax = player_x ;
|
||||||
|
int ymin = player_y ;
|
||||||
|
int ymax = player_y ;
|
||||||
|
|
||||||
|
int cxmin = player_cx ;
|
||||||
|
int cxmax = player_cx ;
|
||||||
|
int cymin = player_cy ;
|
||||||
|
int cymax = player_cy ;
|
||||||
|
|
||||||
|
normalize(&cxmin, &xmin, &εxmin);
|
||||||
|
normalize(&cxmax, &xmax, &εxmax);
|
||||||
|
normalize(&cymin, &ymin, &εymin);
|
||||||
|
normalize(&cymax, &ymax, &εymax);
|
||||||
|
|
||||||
|
return (
|
||||||
|
checkCollision2(cxmin, cymin, xmin, ymin) ||
|
||||||
|
checkCollision2(cxmin, cymax, xmin, ymax) ||
|
||||||
|
checkCollision2(cxmax, cymin, xmax, ymin) ||
|
||||||
|
checkCollision2(cxmax, cymax, xmax, ymax)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void increment_x(double dx) {
|
void increment_x(double dx) {
|
||||||
εx = εx + dx ;
|
εx = εx + dx ;
|
||||||
if(εx >= 1.0) {
|
if(εx >= 1.0) {
|
||||||
|
@ -62,132 +117,10 @@ void increment_y(double dy) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useSpecialTiles(int chx, int chy, int x, int y, double dx, double dy) {
|
|
||||||
chunk* ch = gridGet(map, chx, chy);
|
|
||||||
if(ch == NULL) {
|
|
||||||
fprintf(stderr, "ERROR : action performed in unloaded chunk\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
//linkedPrint(ch->chdata.meta->next);
|
|
||||||
//printf("\n");
|
|
||||||
char* flag ;
|
|
||||||
if(linked_mem(ch->chdata.meta->next, y, x, &flag)) {
|
|
||||||
//printf("Triggered\n");
|
|
||||||
if(str_equal(flag, "spinCC")) {
|
|
||||||
rotateChunkCounterClockWise(chx, chy);
|
|
||||||
increment_x(-dx);
|
|
||||||
increment_y(-dy);
|
|
||||||
|
|
||||||
double plx = (double)(player_x + εx) ;
|
|
||||||
double ply = (double)(player_y + εy) ;
|
|
||||||
|
|
||||||
double npx = 7.99999999 - ply ;
|
|
||||||
double npy = plx ;
|
|
||||||
//printf("(%lf, %lf) -> (%lf, %lf)\n", plx, ply, npx, npy);
|
|
||||||
player_x = (int)npx ;
|
|
||||||
εx = (double)(npx - (int)npx) ;
|
|
||||||
|
|
||||||
player_y = (int)npy ;
|
|
||||||
εy = (double)(npy - (int)npy) ;
|
|
||||||
increment_x(dx);
|
|
||||||
increment_y(dy);
|
|
||||||
} else if(str_equal(flag, "spinCW")) {
|
|
||||||
increment_x(-dx);
|
|
||||||
increment_y(-dy);
|
|
||||||
|
|
||||||
for(int k = 0; k < 3; k++) {
|
|
||||||
rotateChunkCounterClockWise(chx, chy);
|
|
||||||
|
|
||||||
double plx = (double)(player_x + εx) ;
|
|
||||||
double ply = (double)(player_y + εy) ;
|
|
||||||
|
|
||||||
double npx = 7.99999999 - ply ;
|
|
||||||
double npy = plx ;
|
|
||||||
//printf("(%lf, %lf) -> (%lf, %lf)\n", plx, ply, npx, npy);
|
|
||||||
player_x = (int)npx ;
|
|
||||||
εx = (double)(npx - (int)npx) ;
|
|
||||||
|
|
||||||
player_y = (int)npy ;
|
|
||||||
εy = (double)(npy - (int)npy) ;
|
|
||||||
}
|
|
||||||
increment_x(dx);
|
|
||||||
increment_y(dy);
|
|
||||||
} else if(str_equal(flag, "beltX")) {
|
|
||||||
translateChunkX(chx, chy);
|
|
||||||
player_x = (player_x+1)%8;
|
|
||||||
} else if(str_equal(flag, "belt-X")) {
|
|
||||||
translateChunk_X(chx, chy);
|
|
||||||
player_x = (player_x+7)%8;
|
|
||||||
} else if(str_equal(flag, "beltY")) {
|
|
||||||
translateChunkY(chx, chy);
|
|
||||||
player_y = (player_y+7)%8;
|
|
||||||
} else if(str_equal(flag, "belt-Y")) {
|
|
||||||
translateChunk_Y(chx, chy);
|
|
||||||
player_y = (player_y+1)%8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool checkCollision() {
|
|
||||||
return (unpack_coord(gridGet(map, player_cx, player_cy)->chdata.lines, player_x, player_y));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool checkCollision2(int cx, int cy, int x, int y, double dx, double dy) {
|
|
||||||
return (unpack_coord(gridGet(map, cx, cy)->chdata.lines, x, y) && useSpecialTiles(cx, cy, x, y, dx, dy));
|
|
||||||
}
|
|
||||||
|
|
||||||
void normalize(int* ch_coord, int* coord, double* ε) {
|
|
||||||
if(*ε >= 1.0) {
|
|
||||||
*ε -= 1.0 ;
|
|
||||||
*coord += 1 ;
|
|
||||||
if(*coord >= 8) {
|
|
||||||
*coord -= 8 ;
|
|
||||||
*ch_coord += 1;
|
|
||||||
}
|
|
||||||
} else if(*ε < 0.0) {
|
|
||||||
*ε += 1.0 ;
|
|
||||||
*coord -= 1 ;
|
|
||||||
if(*coord < 0) {
|
|
||||||
*coord += 8 ;
|
|
||||||
*ch_coord -= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool checkCollisionSquare(double square_size, double dx, double dy) {
|
|
||||||
double εxmin = εx - square_size;
|
|
||||||
double εxmax = εx + square_size;
|
|
||||||
double εymin = εy - square_size;
|
|
||||||
double εymax = εy + square_size;
|
|
||||||
|
|
||||||
int xmin = player_x ;
|
|
||||||
int xmax = player_x ;
|
|
||||||
int ymin = player_y ;
|
|
||||||
int ymax = player_y ;
|
|
||||||
|
|
||||||
int cxmin = player_cx ;
|
|
||||||
int cxmax = player_cx ;
|
|
||||||
int cymin = player_cy ;
|
|
||||||
int cymax = player_cy ;
|
|
||||||
|
|
||||||
normalize(&cxmin, &xmin, &εxmin);
|
|
||||||
normalize(&cxmax, &xmax, &εxmax);
|
|
||||||
normalize(&cymin, &ymin, &εymin);
|
|
||||||
normalize(&cymax, &ymax, &εymax);
|
|
||||||
|
|
||||||
return (
|
|
||||||
checkCollision2(cxmin, cymin, xmin, ymin, dx, dy) ||
|
|
||||||
checkCollision2(cxmin, cymax, xmin, ymax, dx, dy) ||
|
|
||||||
checkCollision2(cxmax, cymin, xmax, ymin, dx, dy) ||
|
|
||||||
checkCollision2(cxmax, cymax, xmax, ymax, dx, dy)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool moveRequest(double dx, double dy) {
|
bool moveRequest(double dx, double dy) {
|
||||||
increment_x(dx);
|
increment_x(dx);
|
||||||
increment_y(dy);
|
increment_y(dy);
|
||||||
if(checkCollisionSquare(0.1, dx, dy)) {
|
if(checkCollisionSquare(0.15)) {
|
||||||
increment_x(-dx);
|
increment_x(-dx);
|
||||||
increment_y(-dy);
|
increment_y(-dy);
|
||||||
return false;
|
return false;
|
||||||
|
@ -241,22 +174,17 @@ void moveControl(bool* halt) {
|
||||||
void moveFunctionMaster(SDL_Renderer* renderer) {
|
void moveFunctionMaster(SDL_Renderer* renderer) {
|
||||||
bool halt = false ;
|
bool halt = false ;
|
||||||
while(!halt) {
|
while(!halt) {
|
||||||
//clock_t start = clock();
|
|
||||||
moveControl(&halt);
|
moveControl(&halt);
|
||||||
resetRenderer(renderer);
|
resetRenderer(renderer);
|
||||||
drawMapToRenderer(renderer, -300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), 300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), -300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)), 300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)));
|
drawMapToRenderer(renderer, -300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), 300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), -300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)), 300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)));
|
||||||
drawNumberToRenderer(renderer, digits, player_cx, 10, 10, 50, 70, 0);
|
drawNumberToRenderer(renderer, digits, player_cx, 10, 10, 50, 70, 0);
|
||||||
drawNumberToRenderer(renderer, digits, player_cy, 10, 80, 50, 70, 0);
|
drawNumberToRenderer(renderer, digits, player_cy, 10, 80, 50, 70, 0);
|
||||||
drawNumberToRenderer(renderer, digits, player_x, __width__ / 3, 10, 50, 70, 0);
|
drawNumberToRenderer(renderer, digits, player_x, __width__ / 3, 10, 50, 70, 0);
|
||||||
drawCharToRenderer(renderer, letters, 'x', __width__ / 3 -20, 10, 50, 70);
|
|
||||||
drawNumberToRenderer(renderer, digits, player_y, __width__ / 3, 80, 50, 70, 0);
|
drawNumberToRenderer(renderer, digits, player_y, __width__ / 3, 80, 50, 70, 0);
|
||||||
drawCharToRenderer(renderer, letters, 'y', __width__ / 3 -20, 80, 50, 70);
|
|
||||||
drawNumberToRenderer(renderer, digits, to_int(εx*100), 2 * __width__ / 3, 10, 50, 70, 0);
|
drawNumberToRenderer(renderer, digits, to_int(εx*100), 2 * __width__ / 3, 10, 50, 70, 0);
|
||||||
drawNumberToRenderer(renderer, digits, to_int(εy*100), 2 * __width__ / 3, 80, 50, 70, 0);
|
drawNumberToRenderer(renderer, digits, to_int(εy*100), 2 * __width__ / 3, 80, 50, 70, 0);
|
||||||
updateRenderer(renderer);
|
updateRenderer(renderer);
|
||||||
draw_par += 1 ;
|
draw_par += 1 ;
|
||||||
//clock_t end = clock();
|
|
||||||
//printf("Time(ms) : %f | FPS : %d\n", 1000.0f * (float)(end - start) / CLOCKS_PER_SEC, (int)(CLOCKS_PER_SEC / (float)(end - start)));
|
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
}
|
}
|
||||||
}
|
}
|
18
src/move.h
18
src/move.h
|
@ -1,20 +1,18 @@
|
||||||
#ifndef BACK_MOVE_H
|
#ifndef BACK_MOVE_H
|
||||||
#define BACK_MOVE_H
|
#define BACK_MOVE_H
|
||||||
|
|
||||||
|
bool checkCollision();
|
||||||
|
|
||||||
|
bool checkCollision2(int cx, int cy, int x, int y);
|
||||||
|
|
||||||
|
void normalize(int* ch_coord, int* coord, double* ε);
|
||||||
|
|
||||||
|
bool checkCollisionSquare(double square_size);
|
||||||
|
|
||||||
void increment_x(double dx);
|
void increment_x(double dx);
|
||||||
|
|
||||||
void increment_y(double dy);
|
void increment_y(double dy);
|
||||||
|
|
||||||
bool useSpecialTiles(int chx, int chy, int x, int y, double dx, double dy);
|
|
||||||
|
|
||||||
bool checkCollision();
|
|
||||||
|
|
||||||
bool checkCollision2(int cx, int cy, int x, int y, double dx, double dy);
|
|
||||||
|
|
||||||
void normalize(int* ch_coord, int* coord, double* ε);
|
|
||||||
|
|
||||||
bool checkCollisionSquare(double square_size, double dx, double dy);
|
|
||||||
|
|
||||||
bool moveRequest(double dx, double dy);
|
bool moveRequest(double dx, double dy);
|
||||||
|
|
||||||
void moveControl(bool* halt);
|
void moveControl(bool* halt);
|
||||||
|
|
|
@ -11,17 +11,22 @@ typedef struct array {
|
||||||
int len ;
|
int len ;
|
||||||
} array ;
|
} array ;
|
||||||
|
|
||||||
|
typedef struct pt_3d {
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
double z;
|
||||||
|
} pt_3d ;
|
||||||
|
|
||||||
|
typedef struct pt_3d_int {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
double z;
|
||||||
|
} pt_3d_int ;
|
||||||
|
|
||||||
typedef enum cardinal {NORTH, EAST, SOUTH, WEST} cardinal ;
|
typedef enum cardinal {NORTH, EAST, SOUTH, WEST} cardinal ;
|
||||||
|
|
||||||
extern Grid map ;
|
extern Grid map ;
|
||||||
|
|
||||||
extern bool doCheck ;
|
|
||||||
|
|
||||||
extern linkedList* endLst ;
|
|
||||||
|
|
||||||
extern int emptyChance ;
|
|
||||||
extern int sizeIncreaseChance ;
|
|
||||||
|
|
||||||
extern int zoom ;
|
extern int zoom ;
|
||||||
|
|
||||||
extern int render_distance ;
|
extern int render_distance ;
|
||||||
|
@ -53,9 +58,18 @@ extern imgs digits ;
|
||||||
extern imgs letters ;
|
extern imgs letters ;
|
||||||
|
|
||||||
extern template full ;
|
extern template full ;
|
||||||
extern template empty ;
|
|
||||||
|
|
||||||
extern char** level_list ;
|
extern double** screen_zbuffer ;
|
||||||
extern int level_count ;
|
extern uint8_t** screen_red ;
|
||||||
|
extern uint8_t** screen_green ;
|
||||||
|
extern uint8_t** screen_blue ;
|
||||||
|
|
||||||
|
extern double three_render_distance ;
|
||||||
|
extern int three_angle ;
|
||||||
|
|
||||||
|
extern double* cosinuses ;
|
||||||
|
extern double* sinuses ;
|
||||||
|
|
||||||
|
extern double ar ;
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,444 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <ncurses.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_image.h>
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
#include "structure.h"
|
||||||
|
#include "base.h"
|
||||||
|
#include "generation.h" // initialize constants
|
||||||
|
#include "display.h"
|
||||||
|
#include "threed.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------- //
|
||||||
|
|
||||||
|
double** screen_zbuffer ;
|
||||||
|
uint8_t** screen_red ;
|
||||||
|
uint8_t** screen_green ;
|
||||||
|
uint8_t** screen_blue ;
|
||||||
|
|
||||||
|
double three_render_distance = 20.0 ;
|
||||||
|
int three_angle = 0 ;
|
||||||
|
|
||||||
|
double* cosinuses ;
|
||||||
|
double* sinuses ;
|
||||||
|
|
||||||
|
static pt_3d* polygon_b ;
|
||||||
|
static int poly_length ;
|
||||||
|
|
||||||
|
static double epsilon = 0.75;
|
||||||
|
|
||||||
|
static pt_3d* projected ;
|
||||||
|
static pt_3d* projected2 ;
|
||||||
|
static int pt_count ;
|
||||||
|
|
||||||
|
static double draw_const ;
|
||||||
|
|
||||||
|
static double tfov ;
|
||||||
|
|
||||||
|
double ar ;
|
||||||
|
|
||||||
|
// ----------------------------------------------- //
|
||||||
|
|
||||||
|
void init_3d() {
|
||||||
|
printf("initializing 3d matrixes... ");
|
||||||
|
screen_zbuffer = malloc(sizeof(double*) * __width__);
|
||||||
|
screen_red = malloc(sizeof(uint8_t*) * __width__);
|
||||||
|
screen_green = malloc(sizeof(uint8_t*) * __width__);
|
||||||
|
screen_blue = malloc(sizeof(uint8_t*) * __width__);
|
||||||
|
|
||||||
|
for(int i = 0; i < __width__; i++) {
|
||||||
|
screen_zbuffer[i] = malloc(sizeof(double) * __height__);
|
||||||
|
screen_red[i] = malloc(sizeof(uint8_t) * __height__);
|
||||||
|
screen_green[i] = malloc(sizeof(uint8_t) * __height__);
|
||||||
|
screen_blue[i] = malloc(sizeof(uint8_t) * __height__);
|
||||||
|
|
||||||
|
for(int j = 0; j < __height__; j++) {
|
||||||
|
screen_zbuffer[i][j] = three_render_distance ;
|
||||||
|
screen_red[i][j] = 0 ;
|
||||||
|
screen_green[i][j] = 0 ;
|
||||||
|
screen_blue[i][j] = 0 ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
polygon_b = malloc(sizeof(pt_3d)*20);
|
||||||
|
poly_length = 0 ;
|
||||||
|
|
||||||
|
projected = malloc(sizeof(pt_3d)*12);
|
||||||
|
projected2 = malloc(sizeof(pt_3d)*12);
|
||||||
|
pt_count = 0 ;
|
||||||
|
|
||||||
|
ar = ((double)__height__) / ((double)__width__);
|
||||||
|
|
||||||
|
tfov = tan((75.0 * 3.14159265358 / 180.0) / 2.0) ;
|
||||||
|
|
||||||
|
draw_const = 1.0 ;
|
||||||
|
|
||||||
|
printf("done\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_sincos() {
|
||||||
|
cosinuses = malloc(sizeof(double)*360);
|
||||||
|
sinuses = malloc(sizeof(double)*360);
|
||||||
|
for(int i = 0; i < 360; i++) {
|
||||||
|
cosinuses[i] = cos(((double)i) * 3.14159265358 / 180.0);
|
||||||
|
sinuses[i] = sin(((double)i) * 3.14159265358 / 180.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cropx(int x) {
|
||||||
|
return max(min(__width__-1, x), 0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cropy(int y) {
|
||||||
|
return max(min(__height__-1, y), 0) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void placeRectToBuffer(int x, int y, double z, int width, int height, int R, int G, int B) {
|
||||||
|
for(int w = 0; w < width; w++) {
|
||||||
|
for(int h = 0; h < height; h++) {
|
||||||
|
if(z >= 0 && z < screen_zbuffer[cropx(x+w)][cropy(y+h)] && cropx(x+w) == x+w && cropy(y+h) == y+h) {
|
||||||
|
//printf("(%d, %d)\n", x+w, y+h);
|
||||||
|
screen_zbuffer[cropx(x+w)][cropy(y+h)] = z ;
|
||||||
|
screen_red[cropx(x+w)][cropy(y+h)] = R ;
|
||||||
|
screen_green[cropx(x+w)][cropy(y+h)] = G ;
|
||||||
|
screen_blue[cropx(x+w)][cropy(y+h)] = B ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawLineWithThiccToBuffer(int width, double x1, double x2, int y1, int y2, int z1, int z2, int R, int G, int B) {
|
||||||
|
// draw projected 3D line to buffer
|
||||||
|
double theta = 0.0;
|
||||||
|
double seglen = distance_pt(z1, z2, y1, y2);
|
||||||
|
while(theta < 1.0) {
|
||||||
|
placeRectToBuffer(convex_seg(z1, z2, theta)-width/2, convex_seg(y1, y2, theta)-width/2, convex_seg_double(x1, x2, theta), width, width, R, G, B);
|
||||||
|
theta += 1 / seglen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double get_zdepth_on_edge(int py, int pz) {
|
||||||
|
for(int i = 0; i < poly_length; i++) {
|
||||||
|
//[ Ax * (By - Cy) + Bx * (Cy - Ay) + Cx * (Ay - By) ]
|
||||||
|
if((double)py * (polygon_b[i].z - polygon_b[(i+1)%poly_length].z) + polygon_b[i].y * (polygon_b[(i+1)%poly_length].z - (double)pz) + polygon_b[(i+1)%poly_length].y * ((double)pz - polygon_b[i].z) < epsilon) {
|
||||||
|
return convex_seg_double(polygon_b[i].x, polygon_b[(i+1)%poly_length].x, (pz - polygon_b[i].z)/(polygon_b[(i+1)%poly_length].z - polygon_b[i].z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "ERROR : point is nowhere near an edge of the polygon\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getLeftMost() {
|
||||||
|
double my = polygon_b[0].y ;
|
||||||
|
int mi = 0 ;
|
||||||
|
for(int i = 1; i < pt_count; i++) {
|
||||||
|
if(my > polygon_b[i].y) {
|
||||||
|
my = polygon_b[i].y ;
|
||||||
|
mi = i ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mi ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getRightMost() {
|
||||||
|
double my = polygon_b[0].y ;
|
||||||
|
int mi = 0 ;
|
||||||
|
for(int i = 1; i < pt_count; i++) {
|
||||||
|
if(my < polygon_b[i].y) {
|
||||||
|
my = polygon_b[i].y ;
|
||||||
|
mi = i ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mi ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_in_convex(int px, int py) {
|
||||||
|
double previous = 0.0 ;
|
||||||
|
for(int i = 0; i < poly_length; i++) {
|
||||||
|
double nw = (polygon_b[(i+1)%poly_length].y - polygon_b[i].y) * ((double)py - polygon_b[i].z) - ((double)px - polygon_b[i].y) * (polygon_b[(i+1)%poly_length].z - polygon_b[i].z);
|
||||||
|
//(x2 - x1) * (yp - y1) - (xp - x1) * (y2 - y1)
|
||||||
|
if(nw * previous < 0.0) {
|
||||||
|
return false ;
|
||||||
|
} else {
|
||||||
|
previous = nw ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawPolygonToBuffer(int count, ...) {
|
||||||
|
// takes a 'list' of pt_3d and draws the coresponding polygon to renderer
|
||||||
|
// /!\ : this draws PROJECTED polygons
|
||||||
|
if(count > 20) {
|
||||||
|
fprintf(stderr, "ERROR : polygon has too many vertexes (%d)\n", count);
|
||||||
|
exit(1);
|
||||||
|
} else if(count >= 3) {
|
||||||
|
poly_length = count ;
|
||||||
|
|
||||||
|
va_list list;
|
||||||
|
va_start(list, count);
|
||||||
|
for(int j = 0; j < count; j++) {
|
||||||
|
polygon_b[j] = va_arg(list, pt_3d);
|
||||||
|
}
|
||||||
|
va_end(list);
|
||||||
|
|
||||||
|
/*int pmin = getLeftMost() ;
|
||||||
|
int pmax = getRightMost() ;
|
||||||
|
|
||||||
|
printf("(%d -> %d)\n", pmin, pmax);*/
|
||||||
|
|
||||||
|
for(int i = 0; i < poly_length; i++) {
|
||||||
|
if(polygon_b[i].x >= draw_const || polygon_b[(i+1)%pt_count].x >= draw_const) {
|
||||||
|
drawLineWithThiccToBuffer(4, polygon_b[i].x, polygon_b[(i+1)%poly_length].x, (int)polygon_b[i].y, (int)polygon_b[(i+1)%poly_length].y, (int)polygon_b[i].z, (int)polygon_b[(i+1)%poly_length].z, 255, 255, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pt_3d adjust(pt_3d p) {
|
||||||
|
pt_3d res;
|
||||||
|
res.x = p.x - (player_cx * 8 + player_x + εx) ;
|
||||||
|
res.y = p.y - (player_cy * 8 + player_y + εy) ;
|
||||||
|
res.z = p.z - 1.8 ; // height of player
|
||||||
|
|
||||||
|
res.x = res.x * cosinuses[three_angle] - (p.y - (player_cy * 8 + player_y + εy)) * sinuses[three_angle] ;
|
||||||
|
res.y = res.y * cosinuses[three_angle] + (p.x - (player_cx * 8 + player_x + εx)) * sinuses[three_angle] ;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
let reduce xmin xmax ymin ymax segx segy (dx : int) (dy : int) =
|
||||||
|
(*
|
||||||
|
line crossing rectangles
|
||||||
|
*)
|
||||||
|
|
||||||
|
let ps = [|-dx; dx; -dy; dy|] in
|
||||||
|
let qs = [|segx - xmin; xmax - segx; segy - ymin; ymax - segy|] in
|
||||||
|
let ts = [|None; None; None; None|] in
|
||||||
|
for k = 0 to 3 do
|
||||||
|
if ps.(k) <> 0 then
|
||||||
|
ts.(k) <- Some ((float_of_int qs.(k)) /. (float_of_int ps.(k)))
|
||||||
|
done ;
|
||||||
|
|
||||||
|
let u1 = ref (-. 1. /. 0.)
|
||||||
|
and u2 = ref (1. /. 0.) in
|
||||||
|
|
||||||
|
for k = 0 to 3 do
|
||||||
|
if ps.(k) < 0 then
|
||||||
|
opt_max ts.(k) u1
|
||||||
|
else if ps.(k) > 0 then
|
||||||
|
opt_min ts.(k) u2
|
||||||
|
done ;
|
||||||
|
|
||||||
|
if 0. < !u1 && !u1 < 1. then
|
||||||
|
(segx + int_of_float (!u1 *. float_of_int dx), segy + int_of_float (!u1 *. float_of_int dy))
|
||||||
|
else if 0. < !u2 && !u2 < 1. then
|
||||||
|
(segx + int_of_float (!u2 *. float_of_int dx), segy + int_of_float (!u2 *. float_of_int dy))
|
||||||
|
else
|
||||||
|
(segx + dx, segy + dy) ;;
|
||||||
|
*/
|
||||||
|
|
||||||
|
void opt_max(double *ts_k, double *u1) {
|
||||||
|
if (ts_k && *ts_k > *u1) {
|
||||||
|
*u1 = *ts_k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void opt_min(double *ts_k, double *u2) {
|
||||||
|
if (ts_k && *ts_k < *u2) {
|
||||||
|
*u2 = *ts_k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reduce(int xmin, int xmax, int ymin, int ymax, int segx, int segy, int dx, int dy, double *result_x, double *result_y, double *result_x2, double *result_y2) {
|
||||||
|
int ps[4] = {-dx, dx, -dy, dy};
|
||||||
|
int qs[4] = {segx - xmin, xmax - segx, segy - ymin, ymax - segy};
|
||||||
|
double ts[4] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; // Initialize to some large value
|
||||||
|
|
||||||
|
for (int k = 0; k < 4; k++) {
|
||||||
|
if (ps[k] != 0) {
|
||||||
|
ts[k] = (double)qs[k] / (double)ps[k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double u1 = -DBL_MAX;
|
||||||
|
double u2 = DBL_MAX;
|
||||||
|
|
||||||
|
for (int k = 0; k < 4; k++) {
|
||||||
|
if (ps[k] < 0) {
|
||||||
|
opt_max(&ts[k], &u1);
|
||||||
|
} else if (ps[k] > 0) {
|
||||||
|
opt_min(&ts[k], &u2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0.0 < u1 && u1 < 1.0) {
|
||||||
|
*result_x = (double)segx + (u1 * dx);
|
||||||
|
*result_y = (double)segy + (u1 * dy);
|
||||||
|
} else if (0.0 < u2 && u2 < 1.0) {
|
||||||
|
*result_x2 = (double)segx + (u2 * dx);
|
||||||
|
*result_y2 = (double)segy + (u2 * dy);
|
||||||
|
} else if (0.0 < u1 && u1 < u2 && u2 < 1.0) {
|
||||||
|
*result_x = (double)segx + (u1 * dx);
|
||||||
|
*result_y = (double)segy + (u1 * dy);
|
||||||
|
*result_x2 = (double)segx + (u2 * dx);
|
||||||
|
*result_y2 = (double)segy + (u2 * dy);
|
||||||
|
} else {
|
||||||
|
// nah
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void project_front(pt_3d p) {
|
||||||
|
double ppy = p.y / (p.x * tfov) ;
|
||||||
|
double ppz = p.z / (ar * p.x * tfov) ;
|
||||||
|
projected[pt_count].x = p.x ;
|
||||||
|
projected[pt_count].y = (__height__ * (1.0 + ppy) / 2);
|
||||||
|
projected[pt_count].z = (__width__ * (1.0 + ppz) / 2);
|
||||||
|
pt_count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void project_back(pt_3d p) {
|
||||||
|
double ppy = p.y / (draw_const * tfov) ;
|
||||||
|
double ppz = p.z / (ar * draw_const * tfov) ;
|
||||||
|
projected[pt_count].x = p.x ;
|
||||||
|
projected[pt_count].y = (__height__ * (1.0 + ppy) / 2);
|
||||||
|
projected[pt_count].z = (__width__ * (1.0 + ppz) / 2);
|
||||||
|
pt_count += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void project_seg(pt_3d p1, pt_3d p2, bool first) {
|
||||||
|
if(p1.x >= draw_const && p2.x >= draw_const) {
|
||||||
|
printf("+/+\n");
|
||||||
|
project_front(p1);
|
||||||
|
if(first) {
|
||||||
|
project_front(p2);
|
||||||
|
}
|
||||||
|
} else if(p1.x >= draw_const) {
|
||||||
|
printf("+/-\n");
|
||||||
|
project_front(p1);
|
||||||
|
project_front(convex_3d(p1, p2, (draw_const - p1.x)/(p2.x - p1.x)));
|
||||||
|
if(first) {
|
||||||
|
project_back(p2);
|
||||||
|
}
|
||||||
|
} else if(p2.x >= draw_const) {
|
||||||
|
printf("-/+\n");
|
||||||
|
project_back(p1);
|
||||||
|
project_front(convex_3d(p2, p1, (draw_const - p2.x)/(p1.x - p2.x)));
|
||||||
|
if(first) {
|
||||||
|
project_front(p2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("-/-\n");
|
||||||
|
// else do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void project_and_render(pt_3d p1, pt_3d p2, pt_3d p3, pt_3d p4) {
|
||||||
|
pt_count = 0 ;
|
||||||
|
|
||||||
|
printf("rect :\n");
|
||||||
|
printf("%lf, %lf, %lf\n", p1.x, p1.y, p1.z);
|
||||||
|
printf("%lf, %lf, %lf\n", p2.x, p2.y, p2.z);
|
||||||
|
printf("%lf, %lf, %lf\n", p3.x, p3.y, p3.z);
|
||||||
|
printf("%lf, %lf, %lf\n\n", p4.x, p4.y, p4.z);
|
||||||
|
|
||||||
|
printf("(%lf)\n", ar);
|
||||||
|
|
||||||
|
project_seg(p1, p2, true);
|
||||||
|
project_seg(p2, p3, true);
|
||||||
|
project_seg(p3, p4, true);
|
||||||
|
project_seg(p4, p1, true);
|
||||||
|
|
||||||
|
printf("C : %d\n\n", pt_count);
|
||||||
|
for(int i = 0; i < pt_count; i++) {
|
||||||
|
printf("pt %d : (%lf, %lf, %lf)\n", i, projected[i].x, projected[i].y, projected[i].z);
|
||||||
|
projected2[i] = projected[i] ;
|
||||||
|
reduce(0, __width__, 0, __height__, (int)projected[i].y, (int)projected[i].z, (int)(projected[(i+1)%pt_count].y - projected[i].y), (int)(projected[(i+1)%pt_count].z - projected[i].z), &(projected2[i].y), &(projected2[i].z), &(projected2[(i+1)%pt_count].y), &(projected2[(i+1)%pt_count].z));
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
for(int i = 0; i < pt_count; i++) {
|
||||||
|
printf("pt %d+ : (%lf, %lf, %lf)\n", i, projected2[i].x, projected2[i].y, projected2[i].z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pt_count == 2) {
|
||||||
|
drawPolygonToBuffer(2, projected2[0], projected2[1]);
|
||||||
|
} else if(pt_count == 3) {
|
||||||
|
drawPolygonToBuffer(3, projected2[0], projected2[1], projected2[2]);
|
||||||
|
} else if(pt_count == 4) {
|
||||||
|
drawPolygonToBuffer(4, projected2[0], projected2[1], projected2[2], projected2[3]);
|
||||||
|
} else if(pt_count == 5) {
|
||||||
|
drawPolygonToBuffer(5, projected2[0], projected2[1], projected2[2], projected2[3], projected2[4]);
|
||||||
|
} else if(pt_count == 6) {
|
||||||
|
drawPolygonToBuffer(6, projected2[0], projected2[1], projected2[2], projected2[3], projected2[4], projected2[5]);
|
||||||
|
} else if(pt_count == 7) {
|
||||||
|
drawPolygonToBuffer(7, projected2[0], projected2[1], projected2[2], projected2[3], projected2[4], projected2[5], projected2[6]);
|
||||||
|
} else if(pt_count == 8) {
|
||||||
|
drawPolygonToBuffer(8, projected2[0], projected2[1], projected2[2], projected2[3], projected2[4], projected2[5], projected2[6], projected2[7]);
|
||||||
|
} else if(pt_count == 9) {
|
||||||
|
drawPolygonToBuffer(9, projected2[0], projected2[1], projected2[2], projected2[3], projected2[4], projected2[5], projected2[6], projected2[7], projected2[8]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void project_rectangle(pt_3d p1, pt_3d p2, pt_3d p3, pt_3d p4) {
|
||||||
|
printf("rawRect :\n");
|
||||||
|
printf("%lf, %lf, %lf\n", p1.x, p1.y, p1.z);
|
||||||
|
printf("%lf, %lf, %lf\n", p2.x, p2.y, p2.z);
|
||||||
|
printf("%lf, %lf, %lf\n", p3.x, p3.y, p3.z);
|
||||||
|
printf("%lf, %lf, %lf\n\n", p4.x, p4.y, p4.z);
|
||||||
|
|
||||||
|
project_and_render(adjust(p1), adjust(p2), adjust(p3), adjust(p4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetBuffer() {
|
||||||
|
for(int i = 0; i < __width__; i++) {
|
||||||
|
for(int j = 0; j < __height__; j++) {
|
||||||
|
screen_blue[i][j] = 0 ;
|
||||||
|
screen_red[i][j] = 0 ;
|
||||||
|
screen_green[i][j] = 0 ;
|
||||||
|
screen_zbuffer[i][j] = three_render_distance ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bufferUpdateRenderer(SDL_Renderer* renderer) {
|
||||||
|
resetRenderer(renderer);
|
||||||
|
for(int i = 0; i < __height__; i++) {
|
||||||
|
for(int j = 0; j < __width__; j++) {
|
||||||
|
SDL_SetRenderDrawColor(renderer, screen_red[i][j], screen_green[i][j], screen_blue[i][j], SDL_ALPHA_OPAQUE);
|
||||||
|
SDL_RenderDrawPoint(renderer, j, __height__ - i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateRenderer(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_3d() {
|
||||||
|
for(int i = 0; i < __width__; i++) {
|
||||||
|
free(screen_zbuffer[i]);
|
||||||
|
free(screen_red[i]);
|
||||||
|
free(screen_green[i]);
|
||||||
|
free(screen_blue[i]);
|
||||||
|
};
|
||||||
|
free(screen_zbuffer);
|
||||||
|
free(screen_red);
|
||||||
|
free(screen_green);
|
||||||
|
free(screen_blue);
|
||||||
|
|
||||||
|
free(polygon_b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy_sincos() {
|
||||||
|
free(cosinuses);
|
||||||
|
free(sinuses);
|
||||||
|
free(projected);
|
||||||
|
free(projected2);
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef BACK_3D_H
|
||||||
|
#define BACK_3D_H
|
||||||
|
|
||||||
|
void init_3d();
|
||||||
|
|
||||||
|
void init_sincos();
|
||||||
|
|
||||||
|
void placeRectToBuffer(int x, int y, double z, int width, int height, int R, int G, int B);
|
||||||
|
|
||||||
|
void drawLineWithThiccToBuffer(int width, double x1, double x2, int y1, int y2, int z1, int z2, int R, int G, int B);
|
||||||
|
|
||||||
|
bool is_in_convex(int px, int py);
|
||||||
|
|
||||||
|
void drawPolygonToBuffer(int count, ...);
|
||||||
|
|
||||||
|
pt_3d adjust(pt_3d p);
|
||||||
|
|
||||||
|
void opt_max(double *ts_k, double *u1);
|
||||||
|
|
||||||
|
void opt_min(double *ts_k, double *u2);
|
||||||
|
|
||||||
|
void reduce(int xmin, int xmax, int ymin, int ymax, int segx, int segy, int dx, int dy, double *result_x, double *result_y, double *result_x2, double *result_y2);
|
||||||
|
|
||||||
|
void project_front(pt_3d p);
|
||||||
|
|
||||||
|
void project_back(pt_3d p);
|
||||||
|
|
||||||
|
void project_seg(pt_3d p1, pt_3d p2, bool first) ;
|
||||||
|
|
||||||
|
void project_and_render(pt_3d p1, pt_3d p2, pt_3d p3, pt_3d p4);
|
||||||
|
|
||||||
|
void project_rectangle(pt_3d p1, pt_3d p2, pt_3d p3, pt_3d p4);
|
||||||
|
|
||||||
|
void resetBuffer();
|
||||||
|
|
||||||
|
void bufferUpdateRenderer(SDL_Renderer* renderer);
|
||||||
|
|
||||||
|
void destroy_3d();
|
||||||
|
|
||||||
|
void destroy_sincos();
|
||||||
|
|
||||||
|
#endif
|
|
@ -322,15 +322,6 @@
|
||||||
1 1 1 1 1 1 1 1
|
1 1 1 1 1 1 1 1
|
||||||
1 1 1 1 1 1 1 1
|
1 1 1 1 1 1 1 1
|
||||||
|
|
||||||
1 1 1 0 0 1 1 1
|
|
||||||
1 1 1 0 0 1 1 1
|
|
||||||
1 1 1 3 3 1 1 1
|
|
||||||
0 0 2 1 1 2 0 0
|
|
||||||
0 0 2 1 1 2 0 0
|
|
||||||
1 1 1 3 3 1 1 1
|
|
||||||
1 1 1 0 0 1 1 1
|
|
||||||
1 1 1 0 0 1 1 1
|
|
||||||
|
|
||||||
1 1 1 0 0 1 1 1
|
1 1 1 0 0 1 1 1
|
||||||
1 1 1 0 0 1 1 1
|
1 1 1 0 0 1 1 1
|
||||||
1 1 1 1 1 1 1 1
|
1 1 1 1 1 1 1 1
|
||||||
|
|
|
@ -1,244 +0,0 @@
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 1 0 0 0 0 0
|
|
||||||
0 0 1 0 0 0 0 0
|
|
||||||
0 0 1 0 0 0 0 0
|
|
||||||
0 0 1 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 0 0 0 0 0 1 0
|
|
||||||
0 0 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 1 0 0 0 0
|
|
||||||
0 0 0 1 0 0 0 0
|
|
||||||
0 0 0 1 0 0 0 0
|
|
||||||
0 0 0 1 0 0 0 0
|
|
||||||
0 0 0 1 0 0 0 0
|
|
||||||
0 0 0 1 0 0 0 0
|
|
||||||
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 1 1 1 1 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 1
|
|
||||||
0 0 0 0 1 0 0 1
|
|
||||||
0 0 0 0 1 0 0 1
|
|
||||||
0 0 0 0 1 0 0 1
|
|
||||||
0 0 0 0 0 0 0 1
|
|
||||||
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 0
|
|
||||||
0 0 0 0 1 0 0 1
|
|
||||||
0 0 0 0 1 0 0 1
|
|
||||||
0 0 0 0 1 0 0 1
|
|
||||||
0 1 1 1 1 0 0 1
|
|
||||||
0 0 0 0 0 0 0 1
|
|
||||||
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 0 0
|
|
||||||
0 0 1 0 0 0 0 0
|
|
||||||
0 0 1 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 1 1 1 1 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 0 0 1
|
|
||||||
0 0 0 0 0 0 0 1
|
|
||||||
0 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 0 0 1 0 0
|
|
||||||
0 0 0 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 1 1 1 1
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
0 1 0 0 1 0 0 0
|
|
||||||
0 1 0 0 1 0 0 0
|
|
||||||
0 1 0 0 1 1 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 0 0 0 0 0
|
|
||||||
0 1 0 1 1 1 1 1
|
|
||||||
|
|
||||||
$
|
|
|
@ -91,8 +91,8 @@
|
||||||
1 1 0 0 0 0 1 1
|
1 1 0 0 0 0 1 1
|
||||||
1 0 0 0 0 1 1 1
|
1 0 0 0 0 1 1 1
|
||||||
0 0 0 0 1 1 1 0
|
0 0 0 0 1 1 1 0
|
||||||
0 0 0 1 1 2 0 0
|
0 0 0 1 1 1 0 0
|
||||||
0 0 3 1 1 0 0 0
|
0 0 1 1 1 0 0 0
|
||||||
0 1 1 1 0 0 0 0
|
0 1 1 1 0 0 0 0
|
||||||
1 1 1 0 0 0 0 1
|
1 1 1 0 0 0 0 1
|
||||||
1 1 0 0 0 0 1 1
|
1 1 0 0 0 0 1 1
|
||||||
|
@ -100,8 +100,8 @@
|
||||||
1 1 1 1 1 1 1 1
|
1 1 1 1 1 1 1 1
|
||||||
1 0 0 0 0 1 1 1
|
1 0 0 0 0 1 1 1
|
||||||
0 0 0 0 1 1 1 0
|
0 0 0 0 1 1 1 0
|
||||||
0 0 0 1 1 2 0 0
|
0 0 0 1 1 1 0 0
|
||||||
0 0 3 1 1 0 0 0
|
0 0 1 1 1 0 0 0
|
||||||
0 1 1 1 0 0 0 0
|
0 1 1 1 0 0 0 0
|
||||||
1 1 1 0 0 0 0 1
|
1 1 1 0 0 0 0 1
|
||||||
1 1 0 0 0 0 1 1
|
1 1 0 0 0 0 1 1
|
||||||
|
@ -109,8 +109,8 @@
|
||||||
1 1 0 0 0 0 1 1
|
1 1 0 0 0 0 1 1
|
||||||
1 0 0 0 0 1 1 1
|
1 0 0 0 0 1 1 1
|
||||||
0 0 0 0 1 1 1 1
|
0 0 0 0 1 1 1 1
|
||||||
0 0 0 1 1 2 0 1
|
0 0 0 1 1 1 0 1
|
||||||
0 0 3 1 1 0 0 1
|
0 0 1 1 1 0 0 1
|
||||||
0 1 1 1 0 0 0 1
|
0 1 1 1 0 0 0 1
|
||||||
1 1 1 0 0 0 0 1
|
1 1 1 0 0 0 0 1
|
||||||
1 1 0 0 0 0 1 1
|
1 1 0 0 0 0 1 1
|
||||||
|
@ -124,40 +124,4 @@
|
||||||
1 1 1 1 1 1 1 1
|
1 1 1 1 1 1 1 1
|
||||||
1 1 1 1 1 1 1 1
|
1 1 1 1 1 1 1 1
|
||||||
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 0 0 4 0 0 0 1
|
|
||||||
1 0 0 4 0 0 0 1
|
|
||||||
1 0 0 4 0 0 0 1
|
|
||||||
1 0 0 4 0 0 0 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 0 0 5 0 0 0 1
|
|
||||||
1 0 0 5 0 0 0 1
|
|
||||||
1 0 0 5 0 0 0 1
|
|
||||||
1 0 0 5 5 0 0 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 0 0 6 0 0 0 1
|
|
||||||
1 0 0 6 0 0 0 1
|
|
||||||
1 0 0 6 6 0 0 1
|
|
||||||
1 0 0 6 6 0 0 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 0 0 7 0 0 0 1
|
|
||||||
1 0 0 7 7 0 0 1
|
|
||||||
1 0 0 7 7 0 0 1
|
|
||||||
1 0 0 7 7 0 0 1
|
|
||||||
1 0 0 0 0 0 0 1
|
|
||||||
1 1 0 0 0 0 1 1
|
|
||||||
|
|
||||||
$
|
$
|
|
@ -1,470 +0,0 @@
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 1 1 1 1 1 1 0
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 0 1 1 1 1
|
|
||||||
1 1 1 0 0 1 1 1
|
|
||||||
1 1 1 0 0 1 1 1
|
|
||||||
1 1 1 1 0 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
0 0 1 1 1 1 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
1 1 1 1 1 0 1 1
|
|
||||||
1 1 1 1 1 0 1 1
|
|
||||||
1 1 1 1 1 0 1 1
|
|
||||||
1 1 1 1 1 0 1 1
|
|
||||||
1 1 1 1 1 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
0 0 0 1 1 0 0 0
|
|
||||||
1 1 0 1 1 0 1 1
|
|
||||||
1 1 0 1 1 0 1 1
|
|
||||||
1 1 0 1 1 0 1 1
|
|
||||||
1 1 0 1 1 0 1 1
|
|
||||||
0 0 0 1 1 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 0
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 0 0 0 0 0 0
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 1 1 1 1 1 1
|
|
||||||
1 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 0
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 1 1 1 1 0 1
|
|
||||||
1 0 0 0 0 0 0 0
|
|
||||||
1 1 1 1 1 1 1 1
|
|
||||||
|
|
||||||
|
|
||||||
$
|
|
Loading…
Reference in New Issue