windmill-gint/src/main.cpp

162 lines
2.2 KiB
C++

/*
LISTE DES IDEES
O - objets dynamiques et statics
O - gérer la sphere qui chevauche pas pour simplifier le clipping
O - rotation n'importe quel axe
X - sprite de gint -> pas possible
O - compatibilité couleur
*/
#include "main.hpp"
#include <fxlibc/printf.h>
Game game;
Windmill windmill;
Scene_Map scene_map;
int main(void)
{
__printf_enable_fp();
// Ecran principal
extern bopti_image_t img_windmill;
dclear(C_WHITE);
dimage(16, 0, &img_windmill);
dprint_opt(64, 40, C_BLACK, C_WHITE, DTEXT_MIDDLE, DTEXT_BOTTOM, "Jour 26");
int key = 0;
while(key != KEY_EXE)
{
dupdate();
key = getkey().key;
}
dclear(C_BLACK);
dupdate();
// initialise le moteur de jeu
game.new_game();
scene_map.launch();
int timer = timer_configure(TIMER_ANY, 25*1000, GINT_CALL(callback_tick));
timer_start(timer);
scene_map.update();
// boucle principale
while (1)
{
clearevents();
if (keydown(KEY_EXIT))
break;
if (keydown(KEY_MENU))
gint_osmenu();
scene_map.draw();
}
timer_stop(timer);
scene_map.terminate();
getkey();
return 1;
}
static int callback_tick()
{
scene_map.update();
return TIMER_CONTINUE;
}
void debug_pop(char const *fmt, ...)
{
static int id = 0;
id ++;
dclear(C_WHITE);
va_list args;
va_start(args, fmt);
char str[256];
vsnprintf(str, 256, fmt, args);
va_end(args);
char substr[256];
int line = 0;
int i = 0;
int subi = 0;
while (str[i] != '\0')
{
substr[subi] = str[i];
if (str[i] == '\n')
{
substr[subi] = '\0';
dprint(1, 1+9*line, C_BLACK, substr);
line ++;
subi = 0;
}
else
{
subi++;
}
i++;
}
substr[subi] = '\0';
dprint(1, 1+9*line, C_BLACK, substr);
dprint_opt(124, 60, C_BLACK, C_WHITE, DTEXT_RIGHT, DTEXT_BOTTOM, "%i", id);
dupdate();
getkey();
}
void debug_display(char const *fmt, ...)
{
va_list args;
va_start(args, fmt);
char str[256];
vsnprintf(str, 256, fmt, args);
va_end(args);
char substr[256];
int line = 0;
int i = 0;
int subi = 0;
while (str[i] != '\0')
{
substr[subi] = str[i];
if (str[i] == '\n')
{
substr[subi] = '\0';
dprint(1, 1+9*line, C_BLACK, substr);
line ++;
subi = 0;
}
else
{
subi++;
}
i++;
}
substr[subi] = '\0';
dprint(1, 1+9*line, C_BLACK, substr);
dupdate();
}