BackRoomsMaker/src/main.c

106 lines
2.8 KiB
C

#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 <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "hash.h"
#include "structure.h"
#include "base.h"
#include "display.h"
#include "generation.h"
#include "threed.h"
#include "move.h"
int main(int argc, char** argv) {
if(argc != 3) {
fprintf(stderr, "usage : bin/back <template_pool> <n_templates>\n");
exit(1);
};
char* filename = argv[1];
int length = str_to_int(argv[2]);
srand(time(NULL));
//-------------------------------------------------------------------------------//
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
printf("error initializing SDL: %s\n", SDL_GetError());
}
SDL_Window* win = SDL_CreateWindow("Game",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
1000, 1000, 0);
Uint32 render_flags = SDL_RENDERER_ACCELERATED;
SDL_Renderer* rend = SDL_CreateRenderer(win, -1, render_flags);
SDL_SetRenderDrawBlendMode(rend, SDL_BLENDMODE_BLEND);
//-------------------------------------------------------------------------------//
if(SDL_Init(SDL_INIT_AUDIO)) {
fprintf(stderr, "cannot initialize audio");
exit(1);
}
/* -------------------------------------------------------- */
//one_debug();
parse_configs(filename, length);
initialize(rend);
init_3d();
init_sincos();
int temp = render_distance ;
for(int i = 1; i <= temp; i++) {
printf("%d/%d\n", i, temp);
render_distance = i ;
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)));
};
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_3d();
destroy_sincos();
/* -------------------------------------------------------- */
SDL_DestroyRenderer(rend);
SDL_DestroyWindow(win);
SDL_Quit();
/* -------------------------------------------------------- */
return 0;
}