#include "cammera.h" #include "entity.h" #include #include #include #define jump tart_move_cursor int CammeraInit(cammera* c, int sx, int sy, int px, int py, world* w, tart_window* tw) { c->w = w; c->tw = tw; c->pos_x = px; c->pos_y = py; c->size_x = sx; c->size_y = sy; c->tileCount = c->size_x * c->size_y; //c->frame = (tile*)malloc(c->tileCount * sizeof(tile)); return 0; } int CammeraResize(cammera* c, int sx, int sy) { tart_window_resize(c->tw, (tart_vec2){sx,sy}); c->size_x = sx ; c->size_y = sy; //free(c->frame); c->tileCount = c->size_x * c->size_y; //c->frame = (tile*)malloc(c->tileCount * sizeof(tile)); return 0; } int CammeraRender(cammera*c) { jump(c->tw, (tart_vec2){0,0}); int ne = 1; for(int i = 0; i < c->size_y; i++) { for(int j = 0; j < c->size_x; j++) { if(c->pos_y+i < c->w->size_y-1 && c->pos_y+i >= 0 && c->pos_x+j < c->w->size_x-1 && c->pos_x+j >= 0){ c->tw->palette[2].background.r = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].cell->tile.background.r; c->tw->palette[2].background.g = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].cell->tile.background.g; c->tw->palette[2].background.b = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].cell->tile.background.b; c->tw->palette[2].forground.r = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].cell->tile.forground.r; c->tw->palette[2].forground.g = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].cell->tile.forground.g; c->tw->palette[2].forground.b = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].cell->tile.forground.b; tart_jump(c->tw, (tart_vec2){j,i}); ne = 1; for(int k = 0; k < 1; k++) { if(c->w->wells[at((c->pos_x+j) ,(c->pos_y+i),c->w)].entityIds[0] != 0000) { if(c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.background.r != 0 && c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.background.r != 0 && c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.background.r != 0) { c->tw->palette[2].background.r = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.background.r; c->tw->palette[2].background.g = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.background.g; c->tw->palette[2].background.b = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.background.b; } c->tw->palette[2].forground.r = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.forground.r; c->tw->palette[2].forground.g = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.forground.g; c->tw->palette[2].forground.b = c->w->wells[at(c->pos_x+j,c->pos_y+i,c->w)].entityIds[k]->tile.forground.b; tart_insert_cell(c->tw, 2, c->w->wells[at((c->pos_x+j) ,(c->pos_y+i),c->w)] .entityIds[k]->tile.simble); tart_jump(c->tw,(tart_vec2){j, i}); ne = 0; } } if(ne) { tart_insert_cell(c->tw, 2, c->w->wells[at((c->pos_x+j) ,(c->pos_y+i),c->w)] .cell->tile.simble); } } } } return 0; } void CammeraFree(cammera *c) { //free(c->frame); }