1 /**************************************************************
2 * _____ __ _____ *
3 * / _ \ | | ____ ___ ___ / | | *
4 * / /_\ \ | | _/ __ \ \ \/ / / | |_ *
5 * / | \| |__\ ___/ > < / ^ / *
6 * \____|__ /|____/ \___ >/__/\_ \ \____ | *
7 * \/ \/ \/ |__| *
8 * *
9 **************************************************************
10 * (c) Free Lunch Design 2003 *
11 * Written by Johan Peitz *
12 * http://www.freelunchdesign.com *
13 **************************************************************
14 * This source code is released under the The GNU *
15 * General Public License (GPL). Please refer to the *
16 * document license.txt in the source directory or *
17 * http://www.gnu.org for license information. *
18 **************************************************************/
19
20
21
22
23
24 #include "player.h"
25 #include "timer.h"
26 #include "../data/data.h"
27
28 // draws the player depending on his state
draw_player(BITMAP * bmp,Tplayer * p,int x,int y)29 void draw_player(BITMAP *bmp, Tplayer *p, int x, int y) {
30 BITMAP *head, *body;
31
32 // if flashing, just bail out
33 if (p->wounded && (game_count % 2)) return;
34
35 if (p->actor->status == AC_DEAD) {
36 head = p->actor->data[HERO_NORM].dat;
37 body = p->actor->data[HERO_JUMP].dat;
38 draw_sprite_v_flip(bmp, body, x, y - 32);
39 draw_sprite_v_flip(bmp, head, x, y - 16);
40 }
41 else if (p->actor->status == AC_BALL) {
42 if (!p->actor->direction)
43 rotate_sprite(bmp, p->actor->data[HERO_BALL].dat, x, y-16, itofix(p->angle));
44 else
45 rotate_sprite_v_flip(bmp, p->actor->data[HERO_BALL].dat, x, y-16, itofix(p->angle + 128));
46 }
47 else if (p->actor->status != AC_EAT) {
48 if (p->actor->status == AC_FULL) head = p->actor->data[HERO_FULL].dat;
49 else if (p->actor->status == AC_SPIT) head = p->actor->data[HERO_SPIT].dat;
50 else head = p->actor->data[HERO_NORM].dat;
51
52 if (p->jumping)
53 body = p->actor->data[HERO_JUMP].dat;
54 else
55 body = p->actor->data[p->actor->frames[p->actor->frame]].dat;
56
57 if (p->actor->direction) {
58 draw_sprite_h_flip(bmp, body, x, y - 16);
59 draw_sprite_h_flip(bmp, head, x, y - 16);
60 }
61 else {
62 draw_sprite(bmp, body, x, y - 16);
63 draw_sprite(bmp, head, x, y - 16);
64 }
65 }
66 else {
67 if (!p->jumping) {
68 if (p->actor->direction) {
69 draw_sprite_h_flip(bmp, p->actor->data[HERO_EAT].dat, x, y - 16);
70 }
71 else {
72 draw_sprite(bmp, p->actor->data[HERO_EAT].dat, x - 16, y - 16);
73 }
74 }
75 else {
76 head = p->actor->data[HERO_SPIT].dat;
77 body = p->actor->data[HERO_JUMP].dat;
78 if (p->actor->direction) {
79 draw_sprite_h_flip(bmp, body, x, y - 16);
80 draw_sprite_h_flip(bmp, head, x, y - 16);
81 }
82 else {
83 draw_sprite(bmp, body, x, y - 16);
84 draw_sprite(bmp, head, x, y - 16);
85 }
86 }
87 }
88 }
89
90 // set player as dead
kill_player(Tplayer * p)91 void kill_player(Tplayer *p) {
92 p->lives --;
93 p->ammo = 0;
94 p->wounded = 0;
95 p->health = 0;
96 p->actor->status = AC_DEAD;
97 p->actor->dy = -15;
98 }
99
100 // decreases player health etc
wound_player(Tplayer * p)101 void wound_player(Tplayer *p) {
102 if (p->wounded) return;
103 p->health --;
104 p->wounded = 100;
105 if (p->health <= 0) kill_player(p);
106 }
107
108
109