74 lines
1.7 KiB
C
74 lines
1.7 KiB
C
/*
|
|
** EPITECH PROJECT, 2018
|
|
** task01
|
|
** File description:
|
|
** I do task
|
|
*/
|
|
#include <stdlib.h>
|
|
#include "lib/my_graphics.h"
|
|
#include "lib/my_memory.h"
|
|
#include "game/kinematic.h"
|
|
#include "game/message.h"
|
|
#include "game/memory.h"
|
|
#include "game/draw.h"
|
|
#include "game/menu.h"
|
|
#include "game/core.h"
|
|
#include "game/game.h"
|
|
#include "game/ascii.h"
|
|
|
|
static void check_skip(sfml_t *sfml, int *exit)
|
|
{
|
|
int pos[2] = {0, sfml->height - (ASCII_DEFAULT_HEIGHT << 3) - 16};
|
|
uint32_t *option;
|
|
|
|
option = my_print_set_option(3, 0x000000ff, 0xffffffff,
|
|
ASCII_REVERSE | ASCII_CENTER_X);
|
|
my_print(sfml, pos, "Press A to skip intro.", option);
|
|
*exit = check_pause(sfml);
|
|
if (sfml->key & KEY_A && !(sfml->key & PRES_A)){
|
|
sfml->key &= ~KEY_A;
|
|
*exit = 0;
|
|
}
|
|
free(option);
|
|
}
|
|
|
|
static void intro_main(sfml_t *sfml, int *fade_active)
|
|
{
|
|
int exit = 1;
|
|
|
|
while (sfRenderWindow_isOpen(sfml->window)
|
|
&& !(sfml->scene->player->action & PLAYER_WIN) && exit){
|
|
get_key(sfml);
|
|
game_camera_update(sfml->scene, sfml->width, sfml->height);
|
|
my_clear_vram(sfml, 0xffffffff);
|
|
map_rendering(sfml);
|
|
player_rendering(sfml);
|
|
check_skip(sfml, &exit);
|
|
check_message(sfml, sfml->scene->message);
|
|
if (!*fade_active){
|
|
fade(sfml, FADE_OPEN);
|
|
*fade_active = 1;
|
|
}
|
|
else
|
|
my_display_vram(sfml);
|
|
if (!(sfml->scene->player->action & PLAYER_DEAD))
|
|
update_player(sfml);
|
|
set_exit(sfml);
|
|
}
|
|
}
|
|
|
|
void intro(sfml_t *sfml)
|
|
{
|
|
int fade_active;
|
|
|
|
sfml->key = 0x00;
|
|
sfml->scene = new_scene("src/scene_map/map_intro.txt",
|
|
SCENE_LOAD_PLAYER | SCENE_LOAD_MESSAGE_INTRO);
|
|
if (sfml->scene == NULL)
|
|
return;
|
|
fade_active = 0;
|
|
intro_main(sfml, &fade_active);
|
|
fade(sfml, FADE_CLOSE);
|
|
free_scene(sfml->scene);
|
|
}
|