var globalSpeed = 5; var particleCounter = 0; var Particle = Container.expand(function () { var self = Container.call(this); var particleGraphics = self.createAsset('particle', 'Particle Graphics', .5, .5); particleGraphics.scale.set(1.0); particleGraphics.alpha = 0.5; self.lifetime = 0.2; self.move = function () { var randomX = (Math.random() - 0.5) * 2; var randomY = (Math.random() - 0.5) * 2; self.x += randomX; self.y += randomY; }; LK.setTimeout(function () { self.destroy(); }, self.lifetime * 1000); }); var TKOGraphic = Container.expand(function () { var self = Container.call(this); var tkoGraphic = self.createAsset('tko', 'TKO Graphic', .5, .5); tkoGraphic.scale.set(10); tkoGraphic.alpha = 1; var fadeOutInterval = LK.setInterval(function () { tkoGraphic.alpha -= 0.0167; if (tkoGraphic.alpha <= 0) { LK.clearInterval(fadeOutInterval); self.destroy(); particleCounter--; } }, 16.67); LK.setTimeout(function () { self.destroy(); }, 1000); }); var FlungOpponent = Container.expand(function () { var self = Container.call(this); var opponentGraphics = self.createAsset('opponent', 'Opponent Graphics', .5, .5); opponentGraphics.scale.set(3, 3); self.speed = 20; self.move = function () { self.x += self.speed; }; self.flung = function () { var flungInterval = LK.setInterval(function () { self.move(); self.rotation += 0.5; if (self.x > LK.stage.width) { LK.clearInterval(flungInterval); self.destroy(); } }, 16.67); }; }); var HitGraphic = Container.expand(function () { var self = Container.call(this); var hitGraphic = self.createAsset('hit', 'Hit Graphic', .5, .5); hitGraphic.scale.set(3); hitGraphic.alpha = 1; var fadeOutInterval = LK.setInterval(function () { hitGraphic.alpha -= 0.0167; if (hitGraphic.alpha <= 0) { LK.clearInterval(fadeOutInterval); self.destroy(); } }, 16.67); LK.setTimeout(function () { self.destroy(); }, 1000); }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.createAsset('star', 'Star Graphics', .5, .5); self.lifetime = 3000; self.spawnTime = LK.ticks; var pulseDirection = 1; var minScale = 1.2; var maxScale = 1.8; var pulseSpeed = 0.005; self.pulse = function () { var currentScale = starGraphics.scale.x; if (currentScale >= maxScale) pulseDirection = -1; if (currentScale <= minScale) pulseDirection = 1; var newScale = currentScale + pulseSpeed * pulseDirection; starGraphics.scale.set(newScale); }; LK.on('tick', self.pulse); }); var Opponent = Container.expand(function () { var self = Container.call(this); var opponentGraphics = self.createAsset('opponent', 'Opponent Graphics', .5, .5); opponentGraphics.scale.set(3, 3); self.speed = globalSpeed; self.hitPoints = 3; self.move = function (heroX, heroY) { var dx = heroX - self.x; var dy = heroY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); self.x += self.speed * (dx / distance); self.y += self.speed * (dy / distance); }; self.hit = function (punchX, punchY) { self.hitPoints--; var dx = self.x - punchX; var dy = self.y - punchY; var distance = Math.sqrt(dx * dx + dy * dy); var knockBackMultiplier = 1.2; self.x += 100 * knockBackMultiplier * (dx / distance); self.y += 100 * knockBackMultiplier * (dy / distance); if (self.hitPoints <= 0) { globalSpeed += 1; Punch.prototype.speed += 1; var hitGraphic = new HitGraphic(); hitGraphic.x = self.x; hitGraphic.y = self.y; self.parent.addChild(hitGraphic); if (self.parent && self.parent.opponents) { var index = self.parent.opponents.indexOf(self); if (index > -1) { self.parent.opponents.splice(index, 1); } } self.destroy(); } }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5); heroGraphics.scale.set(-6, 6); self.speed = 5; self.move = function () {}; self.punch = function () {}; }); var Punch = Container.expand(function () { var self = Container.call(this); self.velocity = { x: 0, y: 0 }; self.setVelocity = function (targetX, targetY) { var dx = targetX - self.x; var dy = targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); self.velocity.x = self.speed * (dx / distance); self.velocity.y = self.speed * (dy / distance); var angle = Math.atan2(dy, dx); self.rotation = angle; }; self.move = function () { self.x += self.velocity.x; self.y += self.velocity.y; }; var punchGraphics = self.createAsset('punch', 'Punch Graphics', .5, .5); punchGraphics.scale.set(2); punchGraphics.rotation = Math.PI / 2; self.speed = globalSpeed * 3; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('boxingRing', 'Boxing Ring Background', 0, 0); background.width = 2048; background.height = 2732; self.addChildAt(background, 0); var hero = self.addChild(new Hero()); var enemies = []; var punches = []; var opponents = []; var opponentSpawnRate = 120; var opponentSpawnCounter = 0; var lastStarSpawnTime = 0; var star = null; var scoreBox = new Container(); var scoreBoxGraphics = scoreBox.createAsset('scoreBox', 'Score Box Background', 0.5, 0); scoreBoxGraphics.width = 800; scoreBoxGraphics.height = 300; scoreBoxGraphics.alpha = 0.8; scoreBoxGraphics.tint = 0x000000; self.addChild(scoreBox); scoreBox.x = LK.stage.width / 2 - scoreBoxGraphics.width / 2 + 395; scoreBox.y = scoreBoxGraphics.height / 2 - 160; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreBox.addChild(scoreTxt); LK.gui.topCenter.addChild(scoreTxt); scoreTxt.anchor.set(0.5, 0); var isGameOver = false; var tickOffset = 0; var glovesKillsCount = 0; var speedIncreaseTimer = 0; var speedIncreaseInterval = 300; var speedMultiplier = 1; hero.x = hero.width / 2 + 90 + 50; hero.y = 2732 / 2 - 160 - 40; var punchCooldown = 500; var lastPunchTime = 0; LK.stage.on('down', function (obj) { var currentTime = Date.now(); if (currentTime - lastPunchTime >= punchCooldown) { var event = obj.event; var tapPosition = event.getLocalPosition(self); var punch = new Punch(); punch.particles = []; punch.x = hero.x; punch.y = hero.y; punch.setVelocity(tapPosition.x, tapPosition.y); punches.push(punch); self.addChild(punch); LK.effects.flashObject(hero, 0xffcc00, 100); lastPunchTime = currentTime; } }); LK.on('tick', function () { hero.move(); for (var i = punches.length - 1; i >= 0; i--) { var punch = punches[i]; if (punch) punch.move(); var starHit = false; for (var j = opponents.length - 1; j >= 0; j--) { var opponent = opponents[j]; if (star && punch.intersects(star)) { starHit = true; star.destroy(); LK.effects.flashScreen(0xffcc00, 100); var tkoGraphic = new TKOGraphic(); tkoGraphic.x = star.x; tkoGraphic.y = star.y; self.addChild(tkoGraphic); glovesKillsCount += 10; scoreTxt.setText(glovesKillsCount.toString()); star = null; punches.forEach(function (p) { p.destroy(); }); punches = []; self.children.forEach(function (child) { if (child instanceof Particle) { child.destroy(); } }); } else if (punch.intersects(opponent)) { opponent.hit(punch.x, punch.y); if (opponent.hitPoints <= 0) { glovesKillsCount++; scoreTxt.setText(glovesKillsCount.toString()); opponents.splice(j, 1); } else { var hitGraphic = new HitGraphic(); hitGraphic.x = (opponent.x + punch.x) / 2; hitGraphic.y = (opponent.y + punch.y) / 2; self.addChild(hitGraphic); LK.effects.flashObject(hitGraphic, 0xffffff, 1000); } starHit = false; punch.particles.forEach(function (particle) { particle.destroy(); }); punch.destroy(); punches.splice(i, 1); break; } } if (starHit) { opponents.forEach(function (opponent) { opponent.destroy(); var flungOpponent = new FlungOpponent(); flungOpponent.x = opponent.x; flungOpponent.y = opponent.y; self.addChild(flungOpponent); flungOpponent.flung(); }); opponents = []; globalSpeed = 5; Punch.prototype.speed = globalSpeed * 2; } punches.forEach(function (punch) { var particle = new Particle(); particle.x = punch.x; particle.y = punch.y; punch.particles.push(particle); self.addChildAt(particle, self.getChildIndex(punch)); }); } if (star && LK.ticks - star.spawnTime >= star.lifetime) { star.destroy(); star = null; } if (!star && LK.ticks - lastStarSpawnTime >= 5 * 60 + 120) { star = new Star(); star.x = LK.stage.width / 3 + Math.random() * (LK.stage.width * 2 / 3); star.y = LK.stage.height * 0.1 + Math.random() * (LK.stage.height * 0.8); self.addChild(star); lastStarSpawnTime = LK.ticks; } speedIncreaseTimer++; if (speedIncreaseTimer >= speedIncreaseInterval) { if (LK.ticks % (5 * 60) === 0) { speedMultiplier += 0.2; } globalSpeed *= speedMultiplier; speedIncreaseTimer = 0; } if (opponentSpawnCounter++ >= opponentSpawnRate) { var opponent = new Opponent(); opponent.speed += 0.5 + Math.random(); opponent.x = LK.stage.width; opponent.y = Math.random() * (LK.stage.height - opponent.height) + opponent.height / 2; opponents.push(opponent); self.addChild(opponent); opponentSpawnCounter = 0; } for (var j = opponents.length - 1; j >= 0; j--) { var opponent = opponents[j]; opponent.move(hero.x, hero.y); if (opponent.intersects(hero)) { isGameOver = true; } if (opponent.x + opponent.width / 2 < 0) { opponent.destroy(); opponents.splice(j, 1); } } if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); });
var globalSpeed = 5;
var particleCounter = 0;
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.createAsset('particle', 'Particle Graphics', .5, .5);
particleGraphics.scale.set(1.0);
particleGraphics.alpha = 0.5;
self.lifetime = 0.2;
self.move = function () {
var randomX = (Math.random() - 0.5) * 2;
var randomY = (Math.random() - 0.5) * 2;
self.x += randomX;
self.y += randomY;
};
LK.setTimeout(function () {
self.destroy();
}, self.lifetime * 1000);
});
var TKOGraphic = Container.expand(function () {
var self = Container.call(this);
var tkoGraphic = self.createAsset('tko', 'TKO Graphic', .5, .5);
tkoGraphic.scale.set(10);
tkoGraphic.alpha = 1;
var fadeOutInterval = LK.setInterval(function () {
tkoGraphic.alpha -= 0.0167;
if (tkoGraphic.alpha <= 0) {
LK.clearInterval(fadeOutInterval);
self.destroy();
particleCounter--;
}
}, 16.67);
LK.setTimeout(function () {
self.destroy();
}, 1000);
});
var FlungOpponent = Container.expand(function () {
var self = Container.call(this);
var opponentGraphics = self.createAsset('opponent', 'Opponent Graphics', .5, .5);
opponentGraphics.scale.set(3, 3);
self.speed = 20;
self.move = function () {
self.x += self.speed;
};
self.flung = function () {
var flungInterval = LK.setInterval(function () {
self.move();
self.rotation += 0.5;
if (self.x > LK.stage.width) {
LK.clearInterval(flungInterval);
self.destroy();
}
}, 16.67);
};
});
var HitGraphic = Container.expand(function () {
var self = Container.call(this);
var hitGraphic = self.createAsset('hit', 'Hit Graphic', .5, .5);
hitGraphic.scale.set(3);
hitGraphic.alpha = 1;
var fadeOutInterval = LK.setInterval(function () {
hitGraphic.alpha -= 0.0167;
if (hitGraphic.alpha <= 0) {
LK.clearInterval(fadeOutInterval);
self.destroy();
}
}, 16.67);
LK.setTimeout(function () {
self.destroy();
}, 1000);
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.createAsset('star', 'Star Graphics', .5, .5);
self.lifetime = 3000;
self.spawnTime = LK.ticks;
var pulseDirection = 1;
var minScale = 1.2;
var maxScale = 1.8;
var pulseSpeed = 0.005;
self.pulse = function () {
var currentScale = starGraphics.scale.x;
if (currentScale >= maxScale) pulseDirection = -1;
if (currentScale <= minScale) pulseDirection = 1;
var newScale = currentScale + pulseSpeed * pulseDirection;
starGraphics.scale.set(newScale);
};
LK.on('tick', self.pulse);
});
var Opponent = Container.expand(function () {
var self = Container.call(this);
var opponentGraphics = self.createAsset('opponent', 'Opponent Graphics', .5, .5);
opponentGraphics.scale.set(3, 3);
self.speed = globalSpeed;
self.hitPoints = 3;
self.move = function (heroX, heroY) {
var dx = heroX - self.x;
var dy = heroY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
self.x += self.speed * (dx / distance);
self.y += self.speed * (dy / distance);
};
self.hit = function (punchX, punchY) {
self.hitPoints--;
var dx = self.x - punchX;
var dy = self.y - punchY;
var distance = Math.sqrt(dx * dx + dy * dy);
var knockBackMultiplier = 1.2;
self.x += 100 * knockBackMultiplier * (dx / distance);
self.y += 100 * knockBackMultiplier * (dy / distance);
if (self.hitPoints <= 0) {
globalSpeed += 1;
Punch.prototype.speed += 1;
var hitGraphic = new HitGraphic();
hitGraphic.x = self.x;
hitGraphic.y = self.y;
self.parent.addChild(hitGraphic);
if (self.parent && self.parent.opponents) {
var index = self.parent.opponents.indexOf(self);
if (index > -1) {
self.parent.opponents.splice(index, 1);
}
}
self.destroy();
}
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5);
heroGraphics.scale.set(-6, 6);
self.speed = 5;
self.move = function () {};
self.punch = function () {};
});
var Punch = Container.expand(function () {
var self = Container.call(this);
self.velocity = {
x: 0,
y: 0
};
self.setVelocity = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
self.velocity.x = self.speed * (dx / distance);
self.velocity.y = self.speed * (dy / distance);
var angle = Math.atan2(dy, dx);
self.rotation = angle;
};
self.move = function () {
self.x += self.velocity.x;
self.y += self.velocity.y;
};
var punchGraphics = self.createAsset('punch', 'Punch Graphics', .5, .5);
punchGraphics.scale.set(2);
punchGraphics.rotation = Math.PI / 2;
self.speed = globalSpeed * 3;
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('boxingRing', 'Boxing Ring Background', 0, 0);
background.width = 2048;
background.height = 2732;
self.addChildAt(background, 0);
var hero = self.addChild(new Hero());
var enemies = [];
var punches = [];
var opponents = [];
var opponentSpawnRate = 120;
var opponentSpawnCounter = 0;
var lastStarSpawnTime = 0;
var star = null;
var scoreBox = new Container();
var scoreBoxGraphics = scoreBox.createAsset('scoreBox', 'Score Box Background', 0.5, 0);
scoreBoxGraphics.width = 800;
scoreBoxGraphics.height = 300;
scoreBoxGraphics.alpha = 0.8;
scoreBoxGraphics.tint = 0x000000;
self.addChild(scoreBox);
scoreBox.x = LK.stage.width / 2 - scoreBoxGraphics.width / 2 + 395;
scoreBox.y = scoreBoxGraphics.height / 2 - 160;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreBox.addChild(scoreTxt);
LK.gui.topCenter.addChild(scoreTxt);
scoreTxt.anchor.set(0.5, 0);
var isGameOver = false;
var tickOffset = 0;
var glovesKillsCount = 0;
var speedIncreaseTimer = 0;
var speedIncreaseInterval = 300;
var speedMultiplier = 1;
hero.x = hero.width / 2 + 90 + 50;
hero.y = 2732 / 2 - 160 - 40;
var punchCooldown = 500;
var lastPunchTime = 0;
LK.stage.on('down', function (obj) {
var currentTime = Date.now();
if (currentTime - lastPunchTime >= punchCooldown) {
var event = obj.event;
var tapPosition = event.getLocalPosition(self);
var punch = new Punch();
punch.particles = [];
punch.x = hero.x;
punch.y = hero.y;
punch.setVelocity(tapPosition.x, tapPosition.y);
punches.push(punch);
self.addChild(punch);
LK.effects.flashObject(hero, 0xffcc00, 100);
lastPunchTime = currentTime;
}
});
LK.on('tick', function () {
hero.move();
for (var i = punches.length - 1; i >= 0; i--) {
var punch = punches[i];
if (punch) punch.move();
var starHit = false;
for (var j = opponents.length - 1; j >= 0; j--) {
var opponent = opponents[j];
if (star && punch.intersects(star)) {
starHit = true;
star.destroy();
LK.effects.flashScreen(0xffcc00, 100);
var tkoGraphic = new TKOGraphic();
tkoGraphic.x = star.x;
tkoGraphic.y = star.y;
self.addChild(tkoGraphic);
glovesKillsCount += 10;
scoreTxt.setText(glovesKillsCount.toString());
star = null;
punches.forEach(function (p) {
p.destroy();
});
punches = [];
self.children.forEach(function (child) {
if (child instanceof Particle) {
child.destroy();
}
});
} else if (punch.intersects(opponent)) {
opponent.hit(punch.x, punch.y);
if (opponent.hitPoints <= 0) {
glovesKillsCount++;
scoreTxt.setText(glovesKillsCount.toString());
opponents.splice(j, 1);
} else {
var hitGraphic = new HitGraphic();
hitGraphic.x = (opponent.x + punch.x) / 2;
hitGraphic.y = (opponent.y + punch.y) / 2;
self.addChild(hitGraphic);
LK.effects.flashObject(hitGraphic, 0xffffff, 1000);
}
starHit = false;
punch.particles.forEach(function (particle) {
particle.destroy();
});
punch.destroy();
punches.splice(i, 1);
break;
}
}
if (starHit) {
opponents.forEach(function (opponent) {
opponent.destroy();
var flungOpponent = new FlungOpponent();
flungOpponent.x = opponent.x;
flungOpponent.y = opponent.y;
self.addChild(flungOpponent);
flungOpponent.flung();
});
opponents = [];
globalSpeed = 5;
Punch.prototype.speed = globalSpeed * 2;
}
punches.forEach(function (punch) {
var particle = new Particle();
particle.x = punch.x;
particle.y = punch.y;
punch.particles.push(particle);
self.addChildAt(particle, self.getChildIndex(punch));
});
}
if (star && LK.ticks - star.spawnTime >= star.lifetime) {
star.destroy();
star = null;
}
if (!star && LK.ticks - lastStarSpawnTime >= 5 * 60 + 120) {
star = new Star();
star.x = LK.stage.width / 3 + Math.random() * (LK.stage.width * 2 / 3);
star.y = LK.stage.height * 0.1 + Math.random() * (LK.stage.height * 0.8);
self.addChild(star);
lastStarSpawnTime = LK.ticks;
}
speedIncreaseTimer++;
if (speedIncreaseTimer >= speedIncreaseInterval) {
if (LK.ticks % (5 * 60) === 0) {
speedMultiplier += 0.2;
}
globalSpeed *= speedMultiplier;
speedIncreaseTimer = 0;
}
if (opponentSpawnCounter++ >= opponentSpawnRate) {
var opponent = new Opponent();
opponent.speed += 0.5 + Math.random();
opponent.x = LK.stage.width;
opponent.y = Math.random() * (LK.stage.height - opponent.height) + opponent.height / 2;
opponents.push(opponent);
self.addChild(opponent);
opponentSpawnCounter = 0;
}
for (var j = opponents.length - 1; j >= 0; j--) {
var opponent = opponents[j];
opponent.move(hero.x, hero.y);
if (opponent.intersects(hero)) {
isGameOver = true;
}
if (opponent.x + opponent.width / 2 < 0) {
opponent.destroy();
opponents.splice(j, 1);
}
}
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
});
Boxing glove, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A golden glowing star, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art "bap!" explosion Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art explosion that says "TKO" Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
ball of fire sprite art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute anthropomorphic cat wearing boxing shorts and boxing gloves, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art view from inside boxing ring, floor near middle of image Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
anthropomorphic dog wearing boxing shorts and boxing gloves, boxer, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.