summaryrefslogtreecommitdiff
path: root/game_draw.c
blob: ed91aa4fee51c8f27894cb99e4f916f20da9154f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   game_draw.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: kdx    <kdx   @student.42angouleme.fr      +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2022/10/12 10:10:28 by kdx               #+#    #+#             */
/*   Updated: 2022/10/14 03:28:39 by kdx              ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "game.h"
#include "map.h"
#include "player.h"
#include "sprite.h"
#include "badeline.h"

void	game_draw(t_game *game)
{
	t_sprite	*s_exit;

	if (game->redraw)
	{
		game->redraw = 0;
		map_draw(game->sily, &game->map);
		sily_input_draw(game->sily);
	}
	s_exit = game->ss_exit->frame[(game->sily->tick / 10)
		% game->ss_exit->frame_count];
	badeline_erase(game->sily, &game->badeline);
	player_erase(game->sily, game->player.old_pos);
	sprite_draw(game->sily, s_exit, game->map.exit[0], game->map.exit[1]);
	badeline_draw(game->sily, &game->badeline);
	player_draw(game->sily, &game->player);
	if (game->sily->prev_move_events != game->sily->move_events)
		sily_input_draw(game->sily);
}