File: monster2_timer.txt

package info (click to toggle)
nikwi 0.0.20120213-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 8,628 kB
  • ctags: 1,246
  • sloc: cpp: 7,111; ansic: 880; objc: 247; makefile: 142; sh: 48
file content (58 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download | duplicates (6)
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
#
# Timer code for monster 2
#

Object	obj = getThisObject();
Object	hero = getHero();
int	pos = getObjectVar(obj, 0);

if (pos == 0)
{
	int	objy = getObjectYPosition(obj);
	int	heroy = getObjectYPosition(hero);
	int	dist = absi(objy - heroy);
	
	if (dist < 20)
	{
		Object	projectile;
		
		playSample(makeCode("mon2"));

		if (getObjectOrientation(obj) == ORIENTATION_LEFT)
		{		
			projectile = createObject(makeCode("m4pj"),
				getObjectXPosition(obj) - 1, objy + 15);
			createMotionController(projectile);
			setObjectMovement(projectile, 8.0, 0.0);
			flipObjectOrientation(projectile);
		}
		else
		{
			projectile = createObject(makeCode("m4pj"),
				getObjectXPosition(obj) + 32, objy + 15);
			createMotionController(projectile);
			setObjectMovement(projectile, 8.0, 0.0);
		}
		setObjectGravity(projectile, 0.0);
				
		setObjectSprite(obj, "monster4");
	
		if (getLevel() < 5)
			setObjectVar(obj, 0, 64);
		else
			setObjectVar(obj, 0, 16);
	}
}
else 
{
	int	mpos;
	
	if (getLevel() < 5)
		mpos = 32;
	else
		mpos = 8;
	if (pos == mpos)
		setObjectSprite(obj, "monster3");
	setObjectVar(obj, 0, pos - 1);
}