Code edit (9 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Play a sound effect just before calling showGameOver
Code edit (1 edits merged)
Please save this source code
User prompt
In mouse up use a different sound effect, let's call it place
User prompt
Add a sound effect on mouse up that plays if cells exists
User prompt
Play a pickup sound when you press a block
User prompt
Migrate to the latest version of LK
User prompt
Write the tagline for this game
User prompt
in sortCellsByFilled first sort on filtered, then sort on y position. Make sure you modify the original array
Code edit (1 edits merged)
Please save this source code
User prompt
in sortCellsByFilled first sort on filtered, then sort on y position
User prompt
in sortCellsByFilled reverse the sort order
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,76 +1,7 @@
/****
* Classes
-****/
-var Particle = Container.expand(function (tint) {
- var self = Container.call(this);
- self.tint = tint;
- var particleGraphics = self.attachAsset('particle', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- particleGraphics.rotation = Math.random() * Math.PI * 2;
- particleGraphics.tint = self.tint;
- self.vx = Math.random() * 4 - 2;
- self.vy = Math.random() * 4 - 2;
- self.alpha = 1;
- self.lifetime = 60;
- self.tick = function () {
- self.x += self.vx;
- self.y += self.vy;
- self.alpha -= 1 / self.lifetime;
- if (self.alpha <= 0) {
- self.destroy();
- }
- };
-});
-var Cell = Container.expand(function () {
- var self = Container.call(this);
- self.filled = false;
- var empty = self.attachAsset('cell', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- empty.alpa = .8;
- var filled;
- var currentOffset;
- empty.y = 2;
- self.currentTint = 0xffffff;
- self.setFill = function (isFilled, asset, offset) {
- self.filled = isFilled;
- empty.visible = !self.filled;
- if (isFilled) {
- if (asset) {
- asset.x = 0;
- asset.y = brickYOffsets[offset] || -15;
- currentOffset = offset;
- self.addChild(asset);
- filled = asset;
- }
- } else {
- if (filled) {
- filled.destroy();
- filled = null;
- }
- }
- };
- self.tick = function (i, j) {
- if (filled) {
- var offset = Math.cos(((i + j) * 3 + LK.ticks / 2) / 6) / 20;
- var ty = brickYOffsets[currentOffset] || -15;
- filled.y = ty + Math.abs(offset * 200) - 5;
- filled.rotation = offset;
- }
- };
- self.getTint = function () {
- return self.currentTint;
- };
- self.setTint = function (tint) {
- self.currentTint = tint;
- empty.tint = tint;
- };
- self.setFill(false);
-});
+****/
var Block = Container.expand(function (board) {
var self = Container.call(this);
var hsvToRgb = function hsvToRgb(h, s, v) {
var r, g, b;
@@ -177,9 +108,9 @@
this.targetY += oy / 5;
this.x = currentX - this.targetX;
this.y = currentY - this.targetY;
};
- self.move = function (x, y) {
+ self._move_migrated = function (x, y) {
currentX = x;
currentY = y;
self.x = x - this.targetX;
self.y = y - this.targetY;
@@ -324,23 +255,92 @@
}
};
self.placeBlock = function () {};
});
+var Cell = Container.expand(function () {
+ var self = Container.call(this);
+ self.filled = false;
+ var empty = self.attachAsset('cell', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ empty.alpa = .8;
+ var filled;
+ var currentOffset;
+ empty.y = 2;
+ self.currentTint = 0xffffff;
+ self.setFill = function (isFilled, asset, offset) {
+ self.filled = isFilled;
+ empty.visible = !self.filled;
+ if (isFilled) {
+ if (asset) {
+ asset.x = 0;
+ asset.y = brickYOffsets[offset] || -15;
+ currentOffset = offset;
+ self.addChild(asset);
+ filled = asset;
+ }
+ } else {
+ if (filled) {
+ filled.destroy();
+ filled = null;
+ }
+ }
+ };
+ self.tick = function (i, j) {
+ if (filled) {
+ var offset = Math.cos(((i + j) * 3 + LK.ticks / 2) / 6) / 20;
+ var ty = brickYOffsets[currentOffset] || -15;
+ filled.y = ty + Math.abs(offset * 200) - 5;
+ filled.rotation = offset;
+ }
+ };
+ self.getTint = function () {
+ return self.currentTint;
+ };
+ self.setTint = function (tint) {
+ self.currentTint = tint;
+ empty.tint = tint;
+ };
+ self.setFill(false);
+});
+var Particle = Container.expand(function (tint) {
+ var self = Container.call(this);
+ self.tint = tint;
+ var particleGraphics = self.attachAsset('particle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ particleGraphics.rotation = Math.random() * Math.PI * 2;
+ particleGraphics.tint = self.tint;
+ self.vx = Math.random() * 4 - 2;
+ self.vy = Math.random() * 4 - 2;
+ self.alpha = 1;
+ self.lifetime = 60;
+ self.tick = function () {
+ self.x += self.vx;
+ self.y += self.vy;
+ self.alpha -= 1 / self.lifetime;
+ if (self.alpha <= 0) {
+ self.destroy();
+ }
+ };
+});
/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
backgroundColor: 0x80acc2
});
/****
* Game Code
-****/
+****/
/****
* Game Code
* 'Match & Dance: Align the happy blocks and groove to victory!'
-****/
+****/
var brickYOffsets = [2, -10, 2, 2, 2, -20];
var gameBackground = game.attachAsset('gameBackground', {
anchorX: 0.5,
anchorY: 0.5
@@ -367,26 +367,26 @@
block.y = 2732 + block.height;
block.setStartPosition(block.x, 2732 - block.height / 2 - 30);
blocks.push(block);
game.addChild(block);
- block.on('down', function (obj) {
+ block.on('down', function (x, y, obj) {
dragTarget = this;
- var pos = obj.event.getLocalPosition(this);
- var targetPos = obj.event.getLocalPosition(game);
+ var pos = this.toLocal(obj.global);
+ var targetPos = game.toLocal(obj.global);
this.targetX = pos.x;
this.targetY = pos.y;
- dragTarget.move(targetPos.x, targetPos.y);
+ dragTarget._move_migrated(targetPos.x, targetPos.y);
});
};
-game.on('move', function (obj) {
+game.on('move', function (x, y, obj) {
if (dragTarget) {
board.removeTint();
- var pos = obj.event.getLocalPosition(game);
- dragTarget.move(pos.x, pos.y);
+ var pos = game.toLocal(obj.global);
+ dragTarget._move_migrated(pos.x, pos.y);
dragTarget.showOverlap();
}
});
-game.on('up', function (obj) {
+game.on('up', function (x, y, obj) {
if (dragTarget) {
var cells = dragTarget.getOverlappingCells();
if (cells) {
for (var a = 0; a < cells.length; a++) {
@@ -425,9 +425,9 @@
stroke: '#2a636e',
strokeThickness: 16
});
scoreTxt.anchor.set(.5, 0);
-LK.gui.topCenter.addChild(scoreTxt);
+LK.gui.top.addChild(scoreTxt);
game.isMovePossible = function () {
for (var a = 0; a < blocks.length; a++) {
if (blocks[a]) {
for (var i = 0; i < 10; i++) {
White square with tight round corners, flat shaded, hyper casual game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White particle cloud. Cartoon. Bright outline. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Perfectly square yellow Christmas decoration. Cartoon style. Cute art style. Simple vector style.
Perfectly square bright purple Christmas decoration with cute happyy face. Cartoon style. Cute art style. Simple vector style.
Perfectly square bright green game piece with cute happy face. Cartoon style. Cute art style. Simple vector style. No Shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
No background
Perfectly square red game piece with cute happy face. Cartoon style. Cute art style. Simple vector style. No Shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Perfectly square bright dark blue game piece with cute happy face. Cartoon style. Cute art style. Simple vector style. No Shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows..