Okay, this is what I have after a few days. This is kind of a mess. I'll include the warnings/errors under the code.
#ifndef __ENEMY_H__
# define __ENEMY_H__
# define ENEMY_TILE_COUNT (4)
/*
typedef enum
{
NONE,
} e_ship;
*/
typedef struct
{
int anim_id;
char alive;
char status;
char max_anim_frames;
char timer;
// int x;
// int y;
// int speed;
// t_ship_horiz_move move;
char first_dead_sprite_id;
// char is_moving_horizontaly;
// char reverse_animation;
// int shield_pos_x;
// int shield_pos_y;
// int shield_angle;
// int score;
} e_ship;
#endif /* !__ENEMY_H__ */
I'm still not clear on what char items should be included in the structure and the implementation connection with the main file.
#include "enemy.h"
static e_ship enemy;
static int enemy_sprite_id;
static int enemy_dead_sprite_id;
inline bool explodeEnemy(jo_node *node)
{
Sint32 curtime = jo_get_ticks();
if(explodeEnemy != true)
{
jo_sprite_draw3D(enemy_sprite_id, node->data.coord.x, node->data.coord.y, 520);
}
else if(explodeEnemy == true)
{
jo_sprite_draw3D(enemy_dead_sprite_id, node->data.coord.x, node->data.coord.y, 520);
}
if(curtime > 99)
{
jo_sprite_draw3D(enemy_sprite_id, node->data.coord.x, node->data.coord.y, 520);
}
}
inline void renderEnemy(e_ship * enemy, char alive, char status, char max_anim_frames, char timer, jo_node *node)
{
if (enemy->status & alive)
Display(enemy);
else if (enemy->timer ++ < max_anim_frames)
Display(enemy + enemy->timer);
else
enemy->timer=max_anim_frames;
}
inline void start_enemy_animation(e_ship enemy, char first_dead_sprite_id)
{
jo_start_sprite_anim(enemy.anim_id);
// enemy.reverse_animation = reverse_animation;
enemy.anim_id = jo_create_sprite_anim(first_dead_sprite_id, 4, 2);
}
void init_game(void)
{
jo_tile enemy_tileset[ENEMY_TILE_COUNT] =
{
{0, 0, 40, 40},
{40, 0, 40, 40},
{80, 0, 40, 40},
{120, 0, 40, 40},
};
enemy_dead_sprite_id = jo_sprite_add_tga_tileset(JO_ROOT_DIR, "ENEMY.TGA", JO_COLOR_Blue, enemy_tileset, ENEMY_TILE_COUNT);
enemy_sprite_id = jo_sprite_add_tga(JO_ROOT_DIR, "EN.TGA", JO_COLOR_Blue);
enemy.anim_id = jo_create_sprite_anim(enemy_dead_sprite_id, ENEMY_TILE_COUNT, 4);
The compiler warns me that my early mention of static e_ship enemy shadows the global declaration. With the if explode enemy is true, the warning is about the comparison between pointer and integer. At the end of the explode section, it warns that there is no return statement in function returning non-void. There is a warning/error about using the term "display," because it doesn't know where this comes from and doesn't seem to be embedded in the engine. In the renderEnemy section, the status, timer, and node go unused. I realize that these are just mentioned, but not implemented. I don't know enough about it to do this. It also warns that at the end of the explodeEnemy section, "control reaches end of non-void function." I'm wondering if there is an easier way to implement an explosion, but I haven't figured it out yet.