-
Notifications
You must be signed in to change notification settings - Fork 3
/
erobotdeath.cpp
99 lines (77 loc) · 1.96 KB
/
erobotdeath.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "erobotdeath.h"
bool ERobotDeath::finished_init = false;
ZSDL_Surface ERobotDeath::melt[MAX_TEAM_TYPES][17];
ZSDL_Surface ERobotDeath::die[4][MAX_TEAM_TYPES][10];
const int die_max_i[4] = {10, 10, 10, 8};
ERobotDeath::ERobotDeath(ZTime *ztime_, int x_, int y_, int team, bool do_melt_death) : ZEffect(ztime_)
{
double &the_time = ztime->ztime;
if(!finished_init)
{
killme = true;
return;
}
die_i = rand() % 4;
render_i = 0;
owner = team;
x = x_;
y = y_;
if(owner == NULL_TEAM)
{
killme = true;
return;
}
next_process_time = the_time + 0.16;
if(do_melt_death)
{
max_render_i = 17;
render_img = melt[owner];
}
else
{
max_render_i = die_max_i[die_i];
render_img = die[die_i][owner];
}
}
void ERobotDeath::Init()
{
int i, j, k;
char filename_c[500];
for(i=1;i<MAX_TEAM_TYPES;i++)
{
for(j=0;j<4;j++)
for(k=0;k<die_max_i[j];k++)
{
sprintf(filename_c, "assets/units/robots/die%d_%s_n%02d.png", j+1, team_type_string[i].c_str(), k);
//die[j][i][k].LoadBaseImage(filename_c);// = IMG_Load_Error(filename_c);
ZTeam::LoadZSurface(i, die[j][ZTEAM_BASE_TEAM][k], die[j][i][k], filename_c);
}
for(k=0;k<17;k++)
{
sprintf(filename_c, "assets/units/robots/melt_%s_n%02d.png", team_type_string[i].c_str(), k);
//melt[i][k].LoadBaseImage(filename_c);// = IMG_Load_Error(filename_c);
ZTeam::LoadZSurface(i, melt[ZTEAM_BASE_TEAM][k], melt[i][k], filename_c);
}
}
finished_init = true;
}
void ERobotDeath::Process()
{
double &the_time = ztime->ztime;
if(killme) return;
if(the_time >= next_process_time)
{
next_process_time = the_time + 0.16;
render_i++;
if(render_i>=max_render_i)
killme = true;
}
}
void ERobotDeath::DoRender(ZMap &zmap, SDL_Surface *dest)
{
SDL_Rect from_rect, to_rect;
if(killme) return;
zmap.RenderZSurface(&render_img[render_i], x, y);
//if(zmap.GetBlitInfo(render_img[render_i], x, y, from_rect, to_rect))
// SDL_BlitSurface( render_img[render_i], &from_rect, dest, &to_rect);
}