File: enemy_drager.c

package info (click to toggle)
ketm 0.0.6-17sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,356 kB
  • ctags: 875
  • sloc: ansic: 7,303; sh: 410; makefile: 185
file content (62 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (3)
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
#include "enemy.h"

extern SDL_Surface *screen;
extern SPRITE *player;
extern double fps_factor;

typedef struct {
	ENEMY_BASE b;
	int anim_dir;
	int anim_speed;
	int anim_count;
	int level;
} DRAGER_DATA;

void enemy_drager_add(int lv)
{
	int i;
	SPRITE *s;
	DRAGER_DATA *data;

	for(i=0;i<2;i++) {
		s=sprite_add_file("iris.bmp",11,PR_ENEMY);
		s->type=SP_EN_DRAGER;
		s->flags|=(SP_FLAG_VISIBLE|SP_FLAG_COLCHECK);
		s->mover=enemy_drager_move;
		s->anim_speed=0;
		s->aktframe=0;
		s->x=100+500*i;
		s->y=-30;
		data=mmalloc(sizeof(DRAGER_DATA));
		s->data=data;
		data->b.score=15;
		data->b.health=3;
		data->anim_dir=0;
		data->anim_speed=5;
		data->anim_count=0;
		data->level=lv;
	}
}

void enemy_drager_move(SPRITE *s)
{
	DRAGER_DATA *d=(DRAGER_DATA *)s->data;

	d->anim_count++;
	if(d->anim_count==d->anim_speed) {
		d->anim_count=0;
		if(d->anim_dir==0) {
			s->aktframe++;
			if(s->aktframe==10)
				d->anim_dir=1;
		} else {
			s->aktframe--;
			if(s->aktframe==0)
				d->anim_dir=0;
		}
	}

	s->y+=1.5*fps_factor;
	if(s->y>480)
		s->type=-1;
}