-
Notifications
You must be signed in to change notification settings - Fork 0
/
Aquarius-.html
370 lines (265 loc) · 8.08 KB
/
Aquarius-.html
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Phaser - Marston V West</title>
<script src="phaser.js"></script>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(1000, 800, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
//game.load.image('wave1', 'assets/wavestest.png');
//game.load.image('wave2', 'assets/wavestest2.png');
//game.load.spritesheet('sea', 'assets/waves.png', 64, 64);
//game.load.image('sand', 'assets/sandtest.png');
game.load.spritesheet('ROV', 'assets/ROV.png', 32, 32);
game.load.tilemap('tilemap', 'assets/tilemaps/maps/testbed4.json', null, Phaser.Tilemap.TILED_JSON);
game.load.image('tiles', 'assets/tilemaps/tiles/sand2.png');
//spritesheets for plants and animals ROV can interact with
game.load.spritesheet('rockb', 'assets/rockbeauty.png',64,64);
game.load.spritesheet('hardfan', 'assets/hardfan.png',64,64);
game.load.spritesheet('lettuce', 'assets/sealettuce.png',64,64);
game.load.spritesheet('sponge', 'assets/sponge.png',64,64);
game.load.spritesheet('ray', 'assets/Stingray.png',64,64);
game.load.spritesheet('tgrass', 'assets/turtlegrass.png',64,64)
//Preload of note cards for plants and animalsd
game.load.image('raycard', 'assets/sr2.png');
game.load.image('rbcard', 'assets/rb.png');
game.load.image('tgcard', 'assets/tg.png');
}
var cursors;
var controller;
var User;
var controlpad;
var wavetime;
var sand;
var map;
var layer;
var layer2;
var layer3;
var layer4;
var layer5;
var stingray;
var ray;
var sponge;
var spon;
var hardfan;
var har;
var lettuce;
var lett;
var rockb;
var roc;
var tgrass;
var raycard;
function create() {
game.physics.startSystem(Phaser.Physics.ARCADE);
game.world.setBounds(0, 0, 1920, 1920);
map = game.add.tilemap('tilemap');
map.addTilesetImage('sand2','tiles');
//map.addTilesetImage('waves1','tiles2');
//map.setCollisionBetween(23,26);
map.setCollision(23);
layer2 = map.createLayer('Tile Layer 2');
layer = map.createLayer('Tile Layer 1');
User = new ROV('ROV', 100, 1120, 980);
layer3 = map.createLayer('Tile Layer 3');
layer3.alpha = 0.4;
layer4 = map.createLayer('Tile Layer 4');
layer4.alpha = 0;
layer5 = map.createLayer('Tile Layer 5');
layer5.alpha = 0;
//layer.resizeWorld();
wavetime = 0;
User.character.anchor.setTo(0.5);
//User.character.alpha = 0.85;
// We need to enable physics on the player
game.physics.arcade.enable(User.character);
// Player physics properties. Give ROV slight bounce.
User.character.body.bounce.y = 0.4;
User.character.body.drag.set(70);
User.character.body.maxVelocity.set(200);
//User.character.body.gravity.y = 400;
User.character.body.collideWorldBounds = true;
//idle animation for ROV
User.character.animations.add('alert', [2,3], 5, true);
User.character.animations.add('go', [0, 1], 10, true);
User.character.scale.x = 2.5;
User.character.scale.y = 2.5;
controlpad = new Object();
controlpad = game.input.keyboard.addKeys({ 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D , 'inspect': Phaser.KeyCode.I});
game.camera.follow(User.character);
game.camera.deadzone = new Phaser.Rectangle(300, 200, 300, 200);
//ray = new Animal('ray',768, 1536);
ray = game.add.sprite(768, 1536, 'ray');
ray.animations.add('awake', [1, 2,3,4, 5], 5, true);
rockb = game.add.sprite(768,512, 'rockb');
rockb.animations.add('awake', [1, 2], 5, true);
hardfan = game.add.sprite(1792,1728, 'hardfan');
hardfan.animations.add('awake', [1,2], 5, true);
sponge = game.add.sprite(1600, 0, 'sponge');
sponge.animations.add('awake', [1,2], 5, true);
sealettuce = game.add.sprite(1536,1152, 'lettuce');
sealettuce.animations.add('awake', [1,2], 5, true);
tgrass = game.add.sprite(256,1216, 'tgrass');
tgrass.animations.add('awake', [1,2], 5, true);
game.physics.arcade.enable([ray, rockb, hardfan, sponge, sealettuce, tgrass]);
ray.body.immovable = true;
rockb.body.immovable = true;
hardfan.body.immovable = true;
sponge.body.immovable = true;
sealettuce.body.immovable = true;
tgrass.body.immovable = true;
}
function update() {
game.physics.arcade.collide(User.character, layer);
/*game.physics.arcade.collide(User.character,ray);
game.physics.arcade.collide(User.character,rockb);
game.physics.arcade.collide(User.character,hardfan);
game.physics.arcade.collide(User.character,sponge);
game.physics.arcade.collide(User.character,sealettuce);
game.physics.arcade.collide(User.character,tgrass);
*/
if (game.physics.arcade.overlap(User.character, ray))
{
ray.animations.play('awake');
raycard = game.add.image(830, 1500, 'raycard');
}
if (game.physics.arcade.overlap(User.character, rockb))
{
rockb.animations.play('awake');
raycard = game.add.image(780, 580, 'rbcard');
raycard.destroy;
}
if (game.physics.arcade.overlap(User.character, hardfan))
{
hardfan.animations.play('awake');
}
if (game.physics.arcade.overlap(User.character, sponge))
{
sponge.animations.play('awake');
}
if (game.physics.arcade.overlap(User.character, sealettuce))
{
sealettuce.animations.play('awake');
}
if (game.physics.arcade.overlap(User.character, tgrass))
{
tgrass.animations.play('awake');
}
// bumpcheck(User,ray);
/*if(game.physics.arcade.collide(User.character,ray)){layer3.alpha = 1;
layer4.alpha = 1;
layer5.alpha = 1}
*/
//waves(wavetime);
wavetime = wavetime + 1;
if (wavetime == 60)
{
layer3.alpha = 0;
layer4.alpha = 0.4;
layer5.alpha = 0;
}
else if (wavetime == 120)
{
layer3.alpha = 0;
layer4.alpha = 0;
layer5.alpha = 0.4;
}
else if (wavetime == 180)
{
layer3.alpha = 0.4;
layer4.alpha = 0;
layer5.alpha = 0;
wavetime = 0;
}
if (controlpad.up.isDown)
{
//Propel ROV forward
game.physics.arcade.accelerationFromRotation(User.character.rotation, 250, User.character.body.acceleration);
User.character.animations.play('go');
}
else
{
User.character.body.acceleration.set(0);
}
if (controlpad.left.isDown)
{
//Rotate ROV left
User.character.body.angularVelocity = -80;
User.character.animations.play('go');
}
else if (controlpad.right.isDown)
{
//Rotate ROV right
User.character.body.angularVelocity = 80;
User.character.animations.play('go');
}
else if (controlpad.inspect.isDown)
{
//call on inspect function
User.character.animations.play('alert');
}
else
{
User.character.body.angularVelocity = 0;
}
}
//fighter class
function ROV(character,health,startx,starty)
{
this.health = 100;//player start health
this.log = 0; //number of plants and animals catalogued
this.startx = startx;
this.starty = starty;
this.character = game.add.sprite(startx, starty, character);//player character variable to access sprite from phaser and all its properties character variable is name of spritesheet to use
this.journal = []; //array to store what has already been catalogued
}
function Animal(character,startx,starty)
{
this.startx = startx;
this.starty = starty;
this.character = game.add.sprite(startx, starty, character);
this.bumped = false;
}
function bumpcheck(ROV, Animal)
{
if (game.physics.arcade.overlap(this.ROV, this.Animal))
{
this.Animal.bumped = true;
}
return;
}
function inspect()
{
}
function waves(wavetime)
{
wavetime = wavetime + 1;
if (wavetime == 60)
{
layer3.alpha = 0;
layer4.alpha = 0.5;
layer5.alpha = 0;
}
else if (wavetime == 120)
{
layer3.alpha = 0;
layer4.alpha = 0;
layer5.alpha = 0.5;
}
else if (wavetime == 180)
{
layer3.alpha = 0.5;
layer4.alpha = 0;
layer5.alpha = 0;
}
}
</script>
</body>
</html>