-
Notifications
You must be signed in to change notification settings - Fork 0
/
entityGenerator.js
117 lines (101 loc) · 4.73 KB
/
entityGenerator.js
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
var utils = class{
constructor(){}
random(s,e){
return Math.floor(Math.random() * (e - s + 1)) + s;
}
}
var Utils = new utils();
var Entity = class {
constructor(level){
this.demonData = {'A':
{
"data": "demon",
"width": 240,
"original_width": 128,
"layers": {
"LW": "",
"RW": "",
"LB": "",
"HE": "",
"BO":""
}
}
}
this.aliens;
this.demonData[gC.level]['layers'].LW= Utils.random(1,36).toString();
this.demonData[gC.level]['layers'].RW= this.demonData[gC.level]['layers'].LW;
this.demonData[gC.level]['layers'].LB= Utils.random(1,36).toString();
this.demonData[gC.level]['layers'].HE= Utils.random(1,36).toString();
this.demonData[gC.level]['layers'].BO= Utils.random(1,36).toString();
game.load.image('invaderLW', 'assets/games/demons/dem_'+gC.level+'_LW_1_'+this.demonData[gC.level]['layers'].LW.padStart(2,0)+'.png', 128, 128);
game.load.image('invaderRW', 'assets/games/demons/dem_'+gC.level+'_RW_1_'+this.demonData[gC.level]['layers'].RW.padStart(2,0)+'.png', 128, 128);
game.load.image('invaderLB', 'assets/games/demons/dem_'+gC.level+'_LB_2_'+this.demonData[gC.level]['layers'].LB.padStart(2,0)+'.png', 128, 128);
game.load.image('invaderBO', 'assets/games/demons/dem_'+gC.level+'_BO_3_'+this.demonData[gC.level]['layers'].BO.padStart(2,0)+'.png', 128, 128);
game.load.image('invaderHE', 'assets/games/demons/dem_'+gC.level+'_HE_4_'+this.demonData[gC.level]['layers'].HE.padStart(2,0)+'.png', 128, 128);
//this.create();
}
create(){
this.aliens = game.add.group();
this.aliens.enableBody = true;
this.aliens.physicsBodyType = Phaser.Physics.ARCADE;
//nome immagine personalizzato
//game.load.image('invaderLW', 'assets/games/demons/dem_'+gC.level+'_LW_1_'+this.demonData[gC.level]['layers'].LW.padStart(2,0)+'.png', 128, 128);
console.log('assets/games/demons/dem_'+gC.level+'_LW_1_'+this.demonData[gC.level]['layers'].LW.padStart(2,0)+'.png')
let alienlw = this.aliens.create(400, 400, 'invaderLW');
alienlw.anchor.setTo(0.5, 0.5);
//game.load.image('invaderRW', 'assets/games/demons/dem_'+gC.level+'_RW_1_'+this.demonData[gC.level]['layers'].RW.padStart(2,0)+'.png', 128, 128);
console.log('assets/games/demons/dem_'+gC.level+'_RW_1_'+this.demonData[gC.level]['layers'].RW.padStart(2,0)+'.png')
let alienrw = this.aliens.create(400, 400, 'invaderRW');
alienrw.anchor.setTo(0.5, 0.5);
//game.load.image('invaderLB', 'assets/games/demons/dem_'+gC.level+'_LB_2_'+this.demonData[gC.level]['layers'].LB.padStart(2,0)+'.png', 128, 128);
console.log('assets/games/demons/dem_'+gC.level+'_LB_1_'+this.demonData[gC.level]['layers'].LB.padStart(2,0)+'.png')
let alienlb = this.aliens.create(400, 400, 'invaderLB');
alienlb.anchor.setTo(0.5, 0.5);
//game.load.image('invaderBO', 'assets/games/demons/dem_'+gC.level+'_BO_3_'+this.demonData[gC.level]['layers'].BO.padStart(2,0)+'.png', 128, 128);
console.log('assets/games/demons/dem_'+gC.level+'_BO_1_'+this.demonData[gC.level]['layers'].BO.padStart(2,0)+'.png')
let alienbo = this.aliens.create(400, 400, 'invaderBO');
alienbo.anchor.setTo(0.5, 0.5);
//game.load.image('invaderHE', 'assets/games/demons/dem_'+gC.level+'_HE_4_'+this.demonData[gC.level]['layers'].HE.padStart(2,0)+'.png', 128, 128);
console.log('assets/games/demons/dem_'+gC.level+'_HE_1_'+this.demonData[gC.level]['layers'].HE.padStart(2,0)+'.png')
let alienhe = this.aliens.create(400, 400, 'invaderHE');
alienhe.anchor.setTo(0.5, 0.5);
var tween = game.add.tween(this.aliens).to( { x: 150 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
tween.onLoop.add(()=>{this.aliens.y += 10;}, this);
}
move(x,y){
}
fire(){
}
hit(){
}
}
//var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var gC = {
width: 600,
height: 448,
level:'A'
};
var game = new Phaser.Game(
gC.width,
gC.height,
Phaser.AUTO,
'phaser-example',
{
preload: preload,
create: create,
update: update,
render: render
}
);
var dem
function preload() {
dem = new Entity();
}
function create() {
dem.create()
}
var aliens;
function update() {
}
function render() {
}