File size: 1,961 Bytes
87b3b3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#BEGIN_PROPERTIES#
{
	"version": "1.0",
	"commandsIntroduced": []
}
#END_PROPERTIES#
/******************
 * darkAlley.jsx *
 * by aquang9124 *
 ******************
 *
 * Good evening, Dr.
 *
 * You wake up in a dark alleyway and have no recollection of
 * how you got here. There's nothing in your pockets except 
 * lint. You hear footsteps closing in on your location...
 *
 */

function startLevel(map) {
#START_OF_START_LEVEL#

	map.defineObject('thug', {
		'symbol': String.fromCharCode(0x2620),
		'onCollision': function(player) {
			if ( !player.hasItem('goldengun') ) {
				player.killedBy('vicious thug');
			} else {
				map.writeStatus('You are invincible!');
			}
		}
	});

	map.defineObject('bluedoor', {
		'symbol': '-',
		'color': 'blue',
		'impassable': function(player) {
			if (player.getColor() === '#0f0') {
				player.setColor('orange');
				this.color = 'red';
				return false;
			}
			return true;
		}
	});

	map.defineObject('goldengun', {
		'symbol': String.fromCharCode(0x122),
		type: 'item',
		'onPickUp': function(player) {
			map.writeStatus('You have the golden gun!');
			
			if (player.getColor() === "orange") {
				player.setColor('#0f0');
			}
		}
	});

	var alleyX = parseInt(map.getWidth() / 2);
	var alleyY = parseInt(map.getHeight() / 2) - 5;

	map.createFromGrid(['#######',
						'# 	E  #',
						'#     #',
						'#     #',
						'#     #',
						'#     #',
						'#  T  #',
						'#     T',
						'#T   ##',
						'#L#TLL#',
						'#     #',
						'###T#L#',
						'#  P  #',
						'#######'],
					{
						'E': 'exit',
						'#': 'block',
						'G': 'goldengun',
						'T': 'thug',
						'L': 'bluedoor',
						'P': 'player'
					}, alleyX, alleyY);
#BEGIN_EDITABLE#
	map.placeObject(20, 20, 'goldengun');
#END_EDITABLE#

#END_OF_START_LEVEL#
}

function onExit(map) {
	map.writeStatus("You have escaped the dark alley.");
	return true;
}

function validateLevel(map) {
	map.validateExactlyXManyObjects(1, 'exit');
}