/* ** EPITECH PROJECT, 2018 ** task01 ** File description: ** I do task */ #include #include "game/memory.h" #include "game/core.h" camera_t *init_camera(scene_t *scene) { camera_t *camera; camera = (camera_t*)malloc(sizeof(camera_t)); camera->x = scene->player->x - (SCREEN_WIDTH >> 1); camera->y = scene->player->y - (SCREEN_HEIGHT >> 1); return (camera); } player_t *init_player(level_t *level) { player_t *player; int i; i = -1; while (++i < level->width * level->height && level->map[i] != ID_PLAYER); if (level->map[i] != ID_PLAYER) return (NULL); level->map[i] = 0x00; player = (player_t*)malloc(sizeof(player_t)); player->x = (i - ((i / level->width) * level->width)) << 6; player->y = (i / level->width) << 6; player->start_x = player->x; player->start_y = player->y; player->action = PLAYER_IDLE | PLAYER_LEFT; player->nb_dead = 0; player->key = 0x00; player->dx = 0; player->dy = 0; return (player); } wall_t *init_wall(player_t *player) { wall_t *wall; wall = (wall_t*)malloc(sizeof(wall_t)); wall->x = player->x - (WALL_SIZE << 2); wall->start_x = player->x; wall->start_y = player->y; return (wall); } sound_t *init_music(char *music_name) { sound_t *sound; sound = (sound_t*)malloc(sizeof(sound_t)); sound->music = sfMusic_createFromFile(music_name); sound->active = SOUND_ON; sound->volume = 30; return (sound); }