menu
@@ -320,19 +320,20 @@ class Collider
320
320
{
321
321
if (this.enabled)
322
322
{
323
let pressed = GameInput.mousePressed();
324
let held = GameInput.mouseHeld();
325
if (pressed.left || pressed.middle || pressed.right)
326
{
327
this.checkClick(true, pressed);
328
}
323
this.checkCollisions();
324
}
329
325
330
if (held.left || held.middle || held.right)
331
{
332
this.checkClick(false, held);
333
}
326
let pressed = GameInput.mousePressed();
327
let held = GameInput.mouseHeld();
334
328
335
this.checkCollisions();
329
if (pressed.left || pressed.middle || pressed.right)
330
{
331
this.checkClick(true, pressed);
332
}
333
334
if (held.left || held.middle || held.right)
335
{
336
this.checkClick(false, held);
336
337
}
337
338
}
338
339
@@ -413,11 +414,9 @@ class Collider
413
414
this.gameObject.transform.position.y + hh
414
415
];
415
416
416
if (points[0] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw ||
417
points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
417
if (points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)
418
418
{
419
if (points[2] > o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh ||
420
points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
419
if (points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)
421
420
{
422
421
hit = true;
423
422
}
@@ -616,12 +615,64 @@ class Renderer
616
615
*/
617
616
class Transform
618
617
{
619
position = null;
620
scale = null;
618
get position ()
619
{
620
if (!this.g_position)
621
this.g_position = new vector(0, 0);
622
623
return this.g_position;
624
}
625
626
set position (v)
627
{
628
if (!this.g_position)
629
this.g_position = new vector(v.x, v.y);
630
631
this.g_position.x = v.x;
632
this.g_position.y = v.y;
633
}
634
635
get scale ()
636
{
637
if (!this.g_scale)
638
this.g_scale = new vector(0, 0);
639
640
return this.g_scale;
641
}
642
643
set scale (v)
644
{
645
if (!this.g_scale)
646
this.g_scale = new vector(v.x, v.y);
647
648
this.g_scale.x = v.x;
649
this.g_scale.y = v.y;
650
}
651
652
get velocity ()
653
{
654
if (!this.g_velocity)
655
this.g_velocity = new vector(0, 0);
656
657
return this.g_velocity;
658
}
659
660
set velocity (v)
661
{
662
if (!this.g_velocity)
663
this.g_velocity = new vector(v.x, v.y);
664
665
this.g_velocity.x = v.x;
666
this.g_velocity.y = v.y;
667
}
668
669
g_position = null;
670
671
g_scale = null;
621
672
rotation = 0;
622
673
gameObject = null;
623
674
624
velocity = null;
675
g_velocity = null;
625
676
angularVelocity = 0;
626
677
627
678
get size ()
@@ -817,7 +868,7 @@ class Scene
817
868
818
869
if (this.pendingRemoval.length)
819
870
{
820
this.pendingRemoval.sort();
871
this.pendingRemoval.sort((a, b) => a - b);
821
872
822
873
for (let i = this.pendingRemoval.length - 1; i >= 0; i--)
823
874
{
@@ -320,19 +320,20 @@ class Collider320
{320
{321
if (this.enabled)321
if (this.enabled)322
{322
{323
let pressed = GameInput.mousePressed();323
this.checkCollisions();324
let held = GameInput.mouseHeld();324
}325
if (pressed.left || pressed.middle || pressed.right)326
{327
this.checkClick(true, pressed);328
}329
325
330
if (held.left || held.middle || held.right)326
let pressed = GameInput.mousePressed();331
{327
let held = GameInput.mouseHeld();332
this.checkClick(false, held);333
}334
328
335
this.checkCollisions();329
if (pressed.left || pressed.middle || pressed.right)330
{331
this.checkClick(true, pressed);332
}333
334
if (held.left || held.middle || held.right)335
{336
this.checkClick(false, held);336
}337
}337
}338
}338
339
@@ -413,11 +414,9 @@ class Collider413
this.gameObject.transform.position.y + hh414
this.gameObject.transform.position.y + hh414
];415
];415
416
416
if (points[0] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw ||417
if (points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)417
points[1] >= o2.transform.position.x - ohw && points[0] <= o2.transform.position.x + ohw)418
{418
{419
if (points[2] > o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh ||419
if (points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)420
points[3] >= o2.transform.position.y - ohh && points[2] <= o2.transform.position.y + ohh)421
{420
{422
hit = true;421
hit = true;423
}422
}@@ -616,12 +615,64 @@ class Renderer616
*/ 615
*/ 617
class Transform616
class Transform618
{617
{619
position = null;618
get position ()620
scale = null;619
{620
if (!this.g_position)621
this.g_position = new vector(0, 0);622
623
return this.g_position;624
}625
626
set position (v)627
{628
if (!this.g_position)629
this.g_position = new vector(v.x, v.y);630
631
this.g_position.x = v.x;632
this.g_position.y = v.y;633
}634
635
get scale ()636
{637
if (!this.g_scale)638
this.g_scale = new vector(0, 0);639
640
return this.g_scale;641
}642
643
set scale (v)644
{645
if (!this.g_scale)646
this.g_scale = new vector(v.x, v.y);647
648
this.g_scale.x = v.x;649
this.g_scale.y = v.y;650
}651
652
get velocity ()653
{654
if (!this.g_velocity)655
this.g_velocity = new vector(0, 0);656
657
return this.g_velocity;658
}659
660
set velocity (v)661
{662
if (!this.g_velocity)663
this.g_velocity = new vector(v.x, v.y);664
665
this.g_velocity.x = v.x;666
this.g_velocity.y = v.y;667
}668
669
g_position = null;670
671
g_scale = null;621
rotation = 0;672
rotation = 0;622
gameObject = null;673
gameObject = null;623
674
624
velocity = null;675
g_velocity = null;625
angularVelocity = 0;676
angularVelocity = 0;626
677
627
get size ()678
get size ()@@ -817,7 +868,7 @@ class Scene817
868
818
if (this.pendingRemoval.length)869
if (this.pendingRemoval.length)819
{870
{820
this.pendingRemoval.sort();871
this.pendingRemoval.sort((a, b) => a - b);821
872
822
for (let i = this.pendingRemoval.length - 1; i >= 0; i--) 873
for (let i = this.pendingRemoval.length - 1; i >= 0; i--) 823
{874
{@@ -31,7 +31,13 @@ window.onload = function ()
31
31
{ name: "chao_yellow", url: "images/character/chao/yellow.png", subImgTotal: 67, perRow: 9 },
32
32
{ name: "tile_floor_brown", url: "images/tile/tile_floor_brown.png" },
33
33
{ name: "tile_floor_explosion", url: "images/tile/tile_floor_explosion_anim.png", subImgTotal: 10, perRow: 5 },
34
{ name: "fruit", url: "images/object/fruit.png", subImgTotal: 15, perRow: 8 }
34
{ name: "fruit", url: "images/object/fruit.png", subImgTotal: 15, perRow: 8 },
35
36
{ name: "menuButton", url: "images/buttons/menubutton.png", subImgTotal: 1, perRow: 1 },
37
{ name: "btnFruit", url: "images/buttons/menubutton_fruit.png", subImgTotal: 1, perRow: 1 },
38
{ name: "btnToys", url: "images/buttons/menubutton_toys.png", subImgTotal: 1, perRow: 1 },
39
{ name: "btnGames", url: "images/buttons/menubutton_games.png", subImgTotal: 1, perRow: 1 },
40
{ name: "btnPlants", url: "images/buttons/menubutton_plants.png", subImgTotal: 1, perRow: 1 }
35
41
]
36
42
, function ()
37
43
{
@@ -119,6 +125,8 @@ createMainScene = function (game)
119
125
chao = new Chao(60, 60, game.images.chao_default, 0);
120
126
scene.addObject(chao);
121
127
128
scene.addObject(new MenuManager(0, 150, game.images.menuButton, 0));
129
122
130
createSubScene(scene);
123
131
};
124
132
@@ -31,7 +31,13 @@ window.onload = function ()31
{ name: "chao_yellow", url: "images/character/chao/yellow.png", subImgTotal: 67, perRow: 9 },31
{ name: "chao_yellow", url: "images/character/chao/yellow.png", subImgTotal: 67, perRow: 9 },32
{ name: "tile_floor_brown", url: "images/tile/tile_floor_brown.png" },32
{ name: "tile_floor_brown", url: "images/tile/tile_floor_brown.png" },33
{ name: "tile_floor_explosion", url: "images/tile/tile_floor_explosion_anim.png", subImgTotal: 10, perRow: 5 },33
{ name: "tile_floor_explosion", url: "images/tile/tile_floor_explosion_anim.png", subImgTotal: 10, perRow: 5 },34
{ name: "fruit", url: "images/object/fruit.png", subImgTotal: 15, perRow: 8 }34
{ name: "fruit", url: "images/object/fruit.png", subImgTotal: 15, perRow: 8 },35
36
{ name: "menuButton", url: "images/buttons/menubutton.png", subImgTotal: 1, perRow: 1 },37
{ name: "btnFruit", url: "images/buttons/menubutton_fruit.png", subImgTotal: 1, perRow: 1 },38
{ name: "btnToys", url: "images/buttons/menubutton_toys.png", subImgTotal: 1, perRow: 1 },39
{ name: "btnGames", url: "images/buttons/menubutton_games.png", subImgTotal: 1, perRow: 1 },40
{ name: "btnPlants", url: "images/buttons/menubutton_plants.png", subImgTotal: 1, perRow: 1 }35
]41
]36
, function ()42
, function ()37
{43
{@@ -119,6 +125,8 @@ createMainScene = function (game)119
chao = new Chao(60, 60, game.images.chao_default, 0);125
chao = new Chao(60, 60, game.images.chao_default, 0);120
scene.addObject(chao);126
scene.addObject(chao);121
127
128
scene.addObject(new MenuManager(0, 150, game.images.menuButton, 0));129
122
createSubScene(scene);130
createSubScene(scene);123
};131
};124
132