var DustParticle = Container.expand(function () { var self = Container.call(this); var dustParticleGraphics = self.createAsset('dustParticle', 'Dust Particle', .5, .5); dustParticleGraphics.scale.set(1); self.move = function () { self.x += self.vx; self.y += self.vy; self.alpha -= 0.04; if (self.alpha <= 0) { self.destroy(); } }; LK.on('tick', function () { self.move(); }); }); var ToxicParticle = Container.expand(function () { var self = Container.call(this); var toxicParticleGraphics = self.createAsset('toxicParticle', 'Toxic Particle', .5, .5); toxicParticleGraphics.scale.set(1); self.move = function () { self.x += self.vx; self.y += self.vy; self.alpha -= 0.02; if (self.alpha <= 0) { self.destroy(); } }; LK.on('tick', function () { self.move(); }); }); var FlyTrajectory = Container.expand(function () { var self = Container.call(this); var trajectoryGraphics = self.addChild(LK.getAsset('trajectory', 'Trajectory', 0.5, 0.5)); trajectoryGraphics.scale.set(2); trajectoryGraphics.alpha = 0.5; LK.on('tick', function () { trajectoryGraphics.alpha = (Math.sin(LK.ticks / 5) + 1) / 2; }); self.setTrajectory = function (startX, startY, endX, endY) { var dx = endX - startX; var dy = endY - startY; var distance = Math.sqrt(dx * dx + dy * dy); var angle = Math.atan2(dy, dx); trajectoryGraphics.width = distance; trajectoryGraphics.rotation = angle; self.x = startX; self.y = startY; }; }); var ToxicFly = Container.expand(function () { var self = Container.call(this); var toxicFlyGraphics = self.createAsset('toxicFly', 'Toxic Fly', .5, .5); toxicFlyGraphics.scale.set(3); self.move = function () { self.x += self.vx; self.y += self.vy; for (var i = 0; i < 5; i++) { if (Math.random() < 0.2) { var toxicParticle = new ToxicParticle(); toxicParticle.x = self.x; toxicParticle.y = self.y; toxicParticle.vx = (Math.random() - 0.5) * 4; toxicParticle.vy = (Math.random() - 0.5) * 4; self.parent.addChild(toxicParticle); } } }; }); var Frog = Container.expand(function () { var self = Container.call(this); self.vx = 0; self.vy = 0; self.gravity = 0.5; var frogGraphics = self.createAsset('frog', 'Frog character', .5, .5); frogGraphics.scale.set(3); self.jump = function (targetX, targetY) { var dx = targetX - self.x; var dy = targetY - self.y; var angle = Math.atan2(dy, dx); self.vx = Math.cos(angle) * 20; self.vy = Math.sin(angle) * 30 + 5; if (targetX < self.x) { frogGraphics.scale.x = 3; } else { frogGraphics.scale.x = -3; } for (var i = 0; i < 10; i++) { var dustParticle = new DustParticle(); dustParticle.x = self.x; dustParticle.y = self.y; dustParticle.vx = (Math.random() - 0.5) * 8; dustParticle.vy = (Math.random() - 0.5) * 1; self.parent.addChild(dustParticle); } }; self.dodge = function (targetX, targetY) { var dx = targetX - self.x; var dy = targetY - self.y; var angle = Math.atan2(dy, dx); self.vx = Math.cos(angle) * 10; self.vy = Math.sin(angle) * 10; }; }); var LilyPad = Container.expand(function () { var self = Container.call(this); var lilyPadGraphics = self.createAsset('lilyPad', 'Lily pad', .5, .5); lilyPadGraphics.scale.set(3, 1); self.move = function () {}; self.checkCollision = function (otherLilyPad) { var dx = self.x - otherLilyPad.x; var dy = self.y - otherLilyPad.y; var distance = Math.sqrt(dx * dx + dy * dy); return distance < self.width / 2 + otherLilyPad.width / 2; }; }); var Danger = Container.expand(function () { var self = Container.call(this); var dangerGraphics = self.createAsset('danger', 'Danger', .5, .5); self.move = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background', 'Game Background', 0, 0); background.width = 2048; background.height = 2732; var frog = self.addChild(new Frog()); var lilyPads = []; for (var i = 0; i < 5; i++) { var lilyPad = new LilyPad(); do { lilyPad.x = Math.random() * 2048; lilyPad.y = Math.random() * 2732 / 2 + 2732 / 2; } while (lilyPads.some(function (otherLilyPad) { return lilyPad.checkCollision(otherLilyPad); })); lilyPads.push(lilyPad); self.addChild(lilyPad); } var dangers = []; var toxicFlies = []; frog.x = 2048 / 2; frog.y = 2732 / 2; var spawnToxicFly = function () { var edge = Math.floor(Math.random() * 4); var startX = edge == 0 || edge == 2 ? Math.random() * 2048 : edge == 1 ? 0 : 2048; var startY = edge == 0 || edge == 2 ? edge == 0 ? 0 : 2732 : Math.random() * 2732; var dx = frog.x - startX; var dy = frog.y - startY; var angle = Math.atan2(dy, dx); var trajectory = new FlyTrajectory(); trajectory.setTrajectory(startX, startY, frog.x, frog.y); self.addChild(trajectory); LK.setTimeout(function () { var toxicFly = new ToxicFly(); toxicFly.x = startX; toxicFly.y = startY; toxicFly.vx = Math.cos(angle) * 30; toxicFly.vy = Math.sin(angle) * 30; toxicFlies.push(toxicFly); self.addChild(toxicFly); trajectory.destroy(); }, 1000); }; LK.setInterval(spawnToxicFly, 3000); var score = 0; var scoreTxt = new Text2('0', { size: 200, fill: '#ffffff', fontWeight: 'bold', fontStyle: 'bold', stroke: '#000000', strokeThickness: 20 }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); LK.setInterval(function () { score++; scoreTxt.setText(score); }, 1000); LK.on('tick', function () { frog.x += frog.vx; if (frog.x < 0 || frog.x > 2048) { frog.vx *= -1; } frog.y += frog.vy; frog.vy += frog.gravity; if (frog.y < 0 || frog.y > 2732) { LK.showGameOver(); } for (var i = 0; i < lilyPads.length; i++) { if (frog.intersects(lilyPads[i])) { frog.vy = -10; } } for (var i = 0; i < toxicFlies.length; i++) { if (frog.intersects(toxicFlies[i])) { LK.showGameOver(); } } for (var i = 0; i < lilyPads.length; i++) { lilyPads[i].move(); if (lilyPads[i].x < -50) { lilyPads[i].destroy(); lilyPads.splice(i, 1); } } for (var i = 0; i < toxicFlies.length; i++) { toxicFlies[i].move(frog.x, frog.y); if (toxicFlies[i].x < -50 || toxicFlies[i].x > 2048 || toxicFlies[i].y < -50 || toxicFlies[i].y > 2732) { toxicFlies[i].destroy(); toxicFlies.splice(i, 1); } } }); stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); frog.jump(pos.x, pos.y); }); });
var DustParticle = Container.expand(function () {
var self = Container.call(this);
var dustParticleGraphics = self.createAsset('dustParticle', 'Dust Particle', .5, .5);
dustParticleGraphics.scale.set(1);
self.move = function () {
self.x += self.vx;
self.y += self.vy;
self.alpha -= 0.04;
if (self.alpha <= 0) {
self.destroy();
}
};
LK.on('tick', function () {
self.move();
});
});
var ToxicParticle = Container.expand(function () {
var self = Container.call(this);
var toxicParticleGraphics = self.createAsset('toxicParticle', 'Toxic Particle', .5, .5);
toxicParticleGraphics.scale.set(1);
self.move = function () {
self.x += self.vx;
self.y += self.vy;
self.alpha -= 0.02;
if (self.alpha <= 0) {
self.destroy();
}
};
LK.on('tick', function () {
self.move();
});
});
var FlyTrajectory = Container.expand(function () {
var self = Container.call(this);
var trajectoryGraphics = self.addChild(LK.getAsset('trajectory', 'Trajectory', 0.5, 0.5));
trajectoryGraphics.scale.set(2);
trajectoryGraphics.alpha = 0.5;
LK.on('tick', function () {
trajectoryGraphics.alpha = (Math.sin(LK.ticks / 5) + 1) / 2;
});
self.setTrajectory = function (startX, startY, endX, endY) {
var dx = endX - startX;
var dy = endY - startY;
var distance = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx);
trajectoryGraphics.width = distance;
trajectoryGraphics.rotation = angle;
self.x = startX;
self.y = startY;
};
});
var ToxicFly = Container.expand(function () {
var self = Container.call(this);
var toxicFlyGraphics = self.createAsset('toxicFly', 'Toxic Fly', .5, .5);
toxicFlyGraphics.scale.set(3);
self.move = function () {
self.x += self.vx;
self.y += self.vy;
for (var i = 0; i < 5; i++) {
if (Math.random() < 0.2) {
var toxicParticle = new ToxicParticle();
toxicParticle.x = self.x;
toxicParticle.y = self.y;
toxicParticle.vx = (Math.random() - 0.5) * 4;
toxicParticle.vy = (Math.random() - 0.5) * 4;
self.parent.addChild(toxicParticle);
}
}
};
});
var Frog = Container.expand(function () {
var self = Container.call(this);
self.vx = 0;
self.vy = 0;
self.gravity = 0.5;
var frogGraphics = self.createAsset('frog', 'Frog character', .5, .5);
frogGraphics.scale.set(3);
self.jump = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var angle = Math.atan2(dy, dx);
self.vx = Math.cos(angle) * 20;
self.vy = Math.sin(angle) * 30 + 5;
if (targetX < self.x) {
frogGraphics.scale.x = 3;
} else {
frogGraphics.scale.x = -3;
}
for (var i = 0; i < 10; i++) {
var dustParticle = new DustParticle();
dustParticle.x = self.x;
dustParticle.y = self.y;
dustParticle.vx = (Math.random() - 0.5) * 8;
dustParticle.vy = (Math.random() - 0.5) * 1;
self.parent.addChild(dustParticle);
}
};
self.dodge = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var angle = Math.atan2(dy, dx);
self.vx = Math.cos(angle) * 10;
self.vy = Math.sin(angle) * 10;
};
});
var LilyPad = Container.expand(function () {
var self = Container.call(this);
var lilyPadGraphics = self.createAsset('lilyPad', 'Lily pad', .5, .5);
lilyPadGraphics.scale.set(3, 1);
self.move = function () {};
self.checkCollision = function (otherLilyPad) {
var dx = self.x - otherLilyPad.x;
var dy = self.y - otherLilyPad.y;
var distance = Math.sqrt(dx * dx + dy * dy);
return distance < self.width / 2 + otherLilyPad.width / 2;
};
});
var Danger = Container.expand(function () {
var self = Container.call(this);
var dangerGraphics = self.createAsset('danger', 'Danger', .5, .5);
self.move = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Game Background', 0, 0);
background.width = 2048;
background.height = 2732;
var frog = self.addChild(new Frog());
var lilyPads = [];
for (var i = 0; i < 5; i++) {
var lilyPad = new LilyPad();
do {
lilyPad.x = Math.random() * 2048;
lilyPad.y = Math.random() * 2732 / 2 + 2732 / 2;
} while (lilyPads.some(function (otherLilyPad) {
return lilyPad.checkCollision(otherLilyPad);
}));
lilyPads.push(lilyPad);
self.addChild(lilyPad);
}
var dangers = [];
var toxicFlies = [];
frog.x = 2048 / 2;
frog.y = 2732 / 2;
var spawnToxicFly = function () {
var edge = Math.floor(Math.random() * 4);
var startX = edge == 0 || edge == 2 ? Math.random() * 2048 : edge == 1 ? 0 : 2048;
var startY = edge == 0 || edge == 2 ? edge == 0 ? 0 : 2732 : Math.random() * 2732;
var dx = frog.x - startX;
var dy = frog.y - startY;
var angle = Math.atan2(dy, dx);
var trajectory = new FlyTrajectory();
trajectory.setTrajectory(startX, startY, frog.x, frog.y);
self.addChild(trajectory);
LK.setTimeout(function () {
var toxicFly = new ToxicFly();
toxicFly.x = startX;
toxicFly.y = startY;
toxicFly.vx = Math.cos(angle) * 30;
toxicFly.vy = Math.sin(angle) * 30;
toxicFlies.push(toxicFly);
self.addChild(toxicFly);
trajectory.destroy();
}, 1000);
};
LK.setInterval(spawnToxicFly, 3000);
var score = 0;
var scoreTxt = new Text2('0', {
size: 200,
fill: '#ffffff',
fontWeight: 'bold',
fontStyle: 'bold',
stroke: '#000000',
strokeThickness: 20
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
LK.setInterval(function () {
score++;
scoreTxt.setText(score);
}, 1000);
LK.on('tick', function () {
frog.x += frog.vx;
if (frog.x < 0 || frog.x > 2048) {
frog.vx *= -1;
}
frog.y += frog.vy;
frog.vy += frog.gravity;
if (frog.y < 0 || frog.y > 2732) {
LK.showGameOver();
}
for (var i = 0; i < lilyPads.length; i++) {
if (frog.intersects(lilyPads[i])) {
frog.vy = -10;
}
}
for (var i = 0; i < toxicFlies.length; i++) {
if (frog.intersects(toxicFlies[i])) {
LK.showGameOver();
}
}
for (var i = 0; i < lilyPads.length; i++) {
lilyPads[i].move();
if (lilyPads[i].x < -50) {
lilyPads[i].destroy();
lilyPads.splice(i, 1);
}
}
for (var i = 0; i < toxicFlies.length; i++) {
toxicFlies[i].move(frog.x, frog.y);
if (toxicFlies[i].x < -50 || toxicFlies[i].x > 2048 || toxicFlies[i].y < -50 || toxicFlies[i].y > 2732) {
toxicFlies[i].destroy();
toxicFlies.splice(i, 1);
}
}
});
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
frog.jump(pos.x, pos.y);
});
});
Cartoon lilypad Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon tileable swamp background, dark Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon. Green nuclear toxic fly Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon cute fat toad Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.