75 lines
1.6 KiB
C
75 lines
1.6 KiB
C
/*
|
|
Projet name .......: Odyssée
|
|
Version ...........: - dev -
|
|
Last modification .: 11 june 2021
|
|
|
|
|
|
code and assets provided with licence :
|
|
GNU General Public Licence v3.0
|
|
*/
|
|
|
|
#include <gint/display.h>
|
|
#include <gint/keyboard.h>
|
|
#include <gint/timer.h>
|
|
#include <gint/clock.h>
|
|
#include <gint/std/stdlib.h>
|
|
|
|
#include "core.h"
|
|
|
|
// title_screen : display the title screen with particule effect
|
|
void title_screen(void);
|
|
|
|
int main(void)
|
|
{
|
|
extern font_t font_odyssee;
|
|
dfont(&font_odyssee);
|
|
|
|
title_screen();
|
|
return 1;
|
|
}
|
|
|
|
|
|
void title_screen(void)
|
|
{
|
|
extern const bopti_image_t img_title;
|
|
int key = 0;
|
|
|
|
// Initialise the particule effect
|
|
srand(1551001551);
|
|
int coord_x[PARTICULE_NB];
|
|
int coord_y[PARTICULE_NB];
|
|
for (int i = 0; i < PARTICULE_NB; i ++)
|
|
{
|
|
coord_x[i] = rand() % 128;
|
|
coord_y[i] = rand() % 64;
|
|
}
|
|
|
|
static volatile int tick = 0;
|
|
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
|
|
if (t >= 0) timer_start(t);
|
|
|
|
while (key != KEY_EXIT)
|
|
{
|
|
while (!tick) sleep();
|
|
tick = 0;
|
|
|
|
dclear(C_WHITE);
|
|
dimage(0, 0, &img_title);
|
|
|
|
// Update particules positions
|
|
for (int i = 0; i < PARTICULE_NB; i ++)
|
|
{
|
|
dpixel(coord_x[i], coord_y[i], C_BLACK);
|
|
coord_x[i] += (rand() % 3) - 1;
|
|
coord_y[i] += (rand() % 3) - 1;
|
|
|
|
if (coord_x[i] < 0 || coord_x[i] > 128) coord_x[i] = rand() % 128;
|
|
if (coord_y[i] < 0 || coord_y[i] > 64) coord_y[i] = rand() % 64;
|
|
}
|
|
|
|
dupdate();
|
|
key = rtc_key();
|
|
}
|
|
|
|
if (t >= 0) timer_stop(t);
|
|
} |