-
Notifications
You must be signed in to change notification settings - Fork 0
/
player3.c
75 lines (69 loc) · 1.84 KB
/
player3.c
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
** EPITECH PROJECT, 2022
** player3.c
** File description:
** player3
*/
#include "my_runner.h"
void change_sprite(player_t *player)
{
if (player->invisibility > 0) {
if (player->anim == anim_jump) {
player->anim = anim_jump_tr;
player->texture = player->plr_anim->jump_t;
}
if (player->anim == anim_run) {
player->anim = anim_run_tr;
player->texture = player->plr_anim->run_t;
}
}
change_sprite3(player);
change_sprite2(player);
}
void change_sprite2(player_t *player)
{
if (player->invisibility > 0) {
if (player->anim == fall) {
player->anim = fall_tr;
player->texture = player->plr_anim->jump_t;
}
}
if (player->invisibility == 0) {
if (player->anim == fall_tr) {
player->anim = fall;
player->texture = player->plr_anim->jump;
}
}
}
void change_sprite3(player_t *player)
{
if (player->invisibility == 0) {
if (player->anim == anim_jump_tr) {
player->anim = anim_jump;
player->texture = player->plr_anim->jump;
}
if (player->anim == anim_run_tr) {
player->anim = anim_run;
player->texture = player->plr_anim->run;
}
}
}
int is_game_over2(player_t *player, game_object_t **obj, int i)
{
if (is_in_screen(obj[i])) {
if (player->pos.x - 2 < 0 && is_colliding(player, obj[i]) == 1
&& obj[i]->type != end && obj[i]->type != enemy) {
player->game_over = sfTrue;
return 1;
}
}
return 0;
}
void update_score(player_t *player, sfClock *clock)
{
player->last_time = get_time_sec(clock);
if (player->move.right == sfTrue && player->move.left == sfFalse)
player->score->score += 8;
else
player->score->score += 5;
}