69 lines
1.5 KiB
C
69 lines
1.5 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
#include <raylib.h>
|
|
#include <raymath.h>
|
|
|
|
#include "types.h"
|
|
#include "game.h"
|
|
#include "draw.h"
|
|
|
|
#define TEX_N 9
|
|
|
|
char *tex_files[TEX_N] = {
|
|
"assets/blobbleu1.png",
|
|
"assets/blobbleu2.png",
|
|
"assets/blobbleu3.png",
|
|
"assets/blobrouge1.png",
|
|
"assets/blobrouge2.png",
|
|
"assets/blobrouge3.png",
|
|
"assets/blobvert1.png",
|
|
"assets/blobvert2.png",
|
|
"assets/blobvert3.png"
|
|
};
|
|
|
|
Texture2D tex_index[TEX_N];
|
|
|
|
int init_draw(){
|
|
|
|
InitWindow(1280, 720, "Mineur Tycoon");
|
|
|
|
SetTargetFPS(60);
|
|
|
|
for(int i = 0; i < TEX_N; i++){
|
|
tex_index[i] = LoadTexture(tex_files[i]);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void draw_workers(Game *game){
|
|
Workers *workers = &game->workers;
|
|
for(int i = 0; i < workers->worker_n; i++){
|
|
Worker *worker = &workers->worker_stack[i];
|
|
V2d pos = worker->pos;
|
|
if(worker->ai.status == S_Operating){
|
|
pos = Vector2Add(pos,
|
|
machine_dict[worker->ai.mtype].offsets[worker->assign_n]);
|
|
}
|
|
//DrawRectangleV(pos, (V2d){.x=32,.y=32}, WHITE);
|
|
DrawTextureV(tex_index[0], pos, WHITE);
|
|
}
|
|
}
|
|
|
|
void draw_machines(Game *game){
|
|
Machines *machines = &game->machines;
|
|
for(int i = 0; i < machines->machine_n; i++){
|
|
Machine *machine = &machines->machine_stack[i];
|
|
float active_per = Remap((float)machine->active,0,255,0.2,1);
|
|
DrawRectangleV(machine->pos, (V2d){.x=64,.y=64}, Fade(BLUE,active_per));
|
|
}
|
|
}
|
|
|
|
void draw(Game *game){
|
|
draw_machines(game);
|
|
draw_workers(game);
|
|
DrawFPS(0,0);
|
|
}
|