/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Drummer class: sits in front of building, can be tapped to play drum
var Drummer = Container.expand(function () {
var self = Container.call(this);
self.scaleX = 1.5;
self.scaleY = 1.5;
// Drummer body
var body = self.attachAsset('drummer', {
anchorX: 0.5,
anchorY: 1
});
// Drum
var drum = self.attachAsset('drum', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -40
});
// Drumstick (left)
var stickL = self.attachAsset('drumstick', {
anchorX: 0.5,
anchorY: 0.1,
x: -40,
y: -120,
rotation: -0.3
});
// Drumstick (right)
var stickR = self.attachAsset('drumstick', {
anchorX: 0.5,
anchorY: 0.1,
x: 40,
y: -120,
rotation: 0.3
});
// Animate drum hit
self.hit = function () {
// Animate both sticks down and up
tween(stickL, {
rotation: -1.2,
y: -60
}, {
duration: 80,
easing: tween.cubicIn,
onFinish: function onFinish() {
tween(stickL, {
rotation: -0.3,
y: -120
}, {
duration: 120,
easing: tween.cubicOut
});
}
});
tween(stickR, {
rotation: 1.2,
y: -60
}, {
duration: 80,
easing: tween.cubicIn,
onFinish: function onFinish() {
tween(stickR, {
rotation: 0.3,
y: -120
}, {
duration: 120,
easing: tween.cubicOut
});
}
});
// Animate drum scale
tween(drum, {
scaleY: 0.7
}, {
duration: 60,
easing: tween.linear,
onFinish: function onFinish() {
tween(drum, {
scaleY: 1
}, {
duration: 100,
easing: tween.linear
});
}
});
};
// On tap: play drum sound and animate
self.down = function (x, y, obj) {
LK.getSound('drumhit').play();
self.hit();
// Track drum tap count globally
if (typeof drumTapCount === "undefined") {
drumTapCount = 0;
}
drumTapCount++;
// Burst: spawn 8-12 people instantly on every drum tap
if (typeof spawnPerson === "function" && typeof people !== "undefined") {
// Always spawn a random number of people (8-12) on every drum tap
var burstCount = 8 + Math.floor(Math.random() * 5); // 8,9,10,11,12
for (var i = 0; i < burstCount; i++) {
spawnPerson();
}
}
};
return self;
});
// Person class: appears in a window, can be tapped for points
var Person = Container.expand(function () {
var self = Container.call(this);
// Attach person asset (random color)
var colors = [0x3498db, 0xe74c3c, 0x2ecc71, 0xf1c40f, 0x9b59b6, 0x1abc9c];
var color = colors[Math.floor(Math.random() * colors.length)];
var personAsset = self.attachAsset('person', {
anchorX: 0.5,
anchorY: 0.5,
tint: color
});
// State: is this person already tapped?
self.tapped = false;
// Animate person popping up
personAsset.scaleY = 0.1;
tween(personAsset, {
scaleY: 1
}, {
duration: 200,
easing: tween.bounceOut
});
// On tap: collect points, animate out, destroy
self.down = function (x, y, obj) {
if (self.tapped) return;
self.tapped = true;
// Animate shrink and fade
tween(personAsset, {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
self.destroy();
}
});
// Add points
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x22223b
});
/****
* Game Code
****/
// Sound: drum hit
// Drumstick (rectangle, yellow)
// Drum (ellipse, white)
// Drummer (rectangle, brown)
// Person (circle, random color)
// Window (smaller rectangles for people to appear in)
// Building (large rectangle)
// Background asset (behind building)
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 0
});
game.addChild(background);
// Centered building
var building = LK.getAsset('building', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 180
});
game.addChild(building);
// Window grid (positions for people to appear)
var windowRows = 8;
var windowCols = 6;
var windowSpacingX = 170;
var windowSpacingY = 220;
var windowStartX = building.x - building.width / 2 + 160;
var windowStartY = building.y + 120;
var windowPositions = [];
for (var row = 0; row < windowRows; row++) {
for (var col = 0; col < windowCols; col++) {
var wx = windowStartX + col * windowSpacingX;
var wy = windowStartY + row * windowSpacingY;
// Optionally, draw window frames (for visual)
var win = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: wx,
y: wy
});
game.addChild(win);
windowPositions.push({
x: wx,
y: wy
});
}
}
// Draw vertical lines between each window column (except the last column)
for (var col = 1; col < windowCols; col++) {
var lineX = windowStartX + col * windowSpacingX - windowSpacingX / 2;
var lineHeight = windowRows * windowSpacingY - windowSpacingY / 2;
var line = LK.getAsset('window', {
width: 10,
height: lineHeight,
color: 0x888888,
shape: 'box',
anchorX: 0.5,
anchorY: 0,
x: lineX,
y: windowStartY
});
game.addChild(line);
}
// Drummer in front of building, centered horizontally, near bottom
var drummer = new Drummer();
drummer.x = 2048 / 2;
drummer.y = building.y + building.height + 60;
game.addChild(drummer);
// Score text (top center, avoid top left 100x100)
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
// Track how many times the drum has been tapped
var drumTapCount = 0;
// Array to track current people
var people = [];
// Function to spawn a person in a random window
function spawnPerson() {
// Find available windows (not already occupied)
var occupied = {};
for (var i = 0; i < people.length; i++) {
occupied[people[i].windowIdx] = true;
}
var freeWindows = [];
for (var i = 0; i < windowPositions.length; i++) {
if (!occupied[i]) freeWindows.push(i);
}
// Always pick a random window, even if all are full
var idx = Math.floor(Math.random() * windowPositions.length);
// Animate out and destroy the person currently in that window, but do not remove from array here
for (var i = people.length - 1; i >= 0; i--) {
if (people[i].windowIdx === idx) {
if (!people[i].destroyed) {
people[i].tapped = true;
tween(people[i].children[0], {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function (p) {
return function () {
p.destroy();
};
}(people[i])
});
}
break;
}
}
var pos = windowPositions[idx];
// Create person
var p = new Person();
p.x = pos.x;
p.y = pos.y;
p.windowIdx = idx;
people.push(p);
game.addChild(p);
}
// Remove destroyed people from array
function cleanupPeople() {
for (var i = people.length - 1; i >= 0; i--) {
if (people[i].destroyed) {
people.splice(i, 1);
}
}
}
// People now only spawn when drum is tapped, not periodically
// Periodically clean up destroyed people
var cleanupTimer = LK.setInterval(cleanupPeople, 500);
// Remove people after a while if not tapped
var personLifetimes = {};
game.update = function () {
// Remove people after 3 seconds if not tapped
for (var i = people.length - 1; i >= 0; i--) {
var p = people[i];
if (!personLifetimes[p.windowIdx]) {
personLifetimes[p.windowIdx] = LK.ticks;
}
if (!p.tapped && LK.ticks - personLifetimes[p.windowIdx] > 180) {
// Animate out
p.tapped = true;
tween(p.children[0], {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
p.destroy();
}
});
}
if (p.destroyed) {
delete personLifetimes[p.windowIdx];
}
}
};
// Touch handling: handled by LK via .down on Person and Drummer classes
// No need for game.move, as all interaction is via tapping people or drummer
// No music, pause, or game over logic needed per guidelines; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Drummer class: sits in front of building, can be tapped to play drum
var Drummer = Container.expand(function () {
var self = Container.call(this);
self.scaleX = 1.5;
self.scaleY = 1.5;
// Drummer body
var body = self.attachAsset('drummer', {
anchorX: 0.5,
anchorY: 1
});
// Drum
var drum = self.attachAsset('drum', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -40
});
// Drumstick (left)
var stickL = self.attachAsset('drumstick', {
anchorX: 0.5,
anchorY: 0.1,
x: -40,
y: -120,
rotation: -0.3
});
// Drumstick (right)
var stickR = self.attachAsset('drumstick', {
anchorX: 0.5,
anchorY: 0.1,
x: 40,
y: -120,
rotation: 0.3
});
// Animate drum hit
self.hit = function () {
// Animate both sticks down and up
tween(stickL, {
rotation: -1.2,
y: -60
}, {
duration: 80,
easing: tween.cubicIn,
onFinish: function onFinish() {
tween(stickL, {
rotation: -0.3,
y: -120
}, {
duration: 120,
easing: tween.cubicOut
});
}
});
tween(stickR, {
rotation: 1.2,
y: -60
}, {
duration: 80,
easing: tween.cubicIn,
onFinish: function onFinish() {
tween(stickR, {
rotation: 0.3,
y: -120
}, {
duration: 120,
easing: tween.cubicOut
});
}
});
// Animate drum scale
tween(drum, {
scaleY: 0.7
}, {
duration: 60,
easing: tween.linear,
onFinish: function onFinish() {
tween(drum, {
scaleY: 1
}, {
duration: 100,
easing: tween.linear
});
}
});
};
// On tap: play drum sound and animate
self.down = function (x, y, obj) {
LK.getSound('drumhit').play();
self.hit();
// Track drum tap count globally
if (typeof drumTapCount === "undefined") {
drumTapCount = 0;
}
drumTapCount++;
// Burst: spawn 8-12 people instantly on every drum tap
if (typeof spawnPerson === "function" && typeof people !== "undefined") {
// Always spawn a random number of people (8-12) on every drum tap
var burstCount = 8 + Math.floor(Math.random() * 5); // 8,9,10,11,12
for (var i = 0; i < burstCount; i++) {
spawnPerson();
}
}
};
return self;
});
// Person class: appears in a window, can be tapped for points
var Person = Container.expand(function () {
var self = Container.call(this);
// Attach person asset (random color)
var colors = [0x3498db, 0xe74c3c, 0x2ecc71, 0xf1c40f, 0x9b59b6, 0x1abc9c];
var color = colors[Math.floor(Math.random() * colors.length)];
var personAsset = self.attachAsset('person', {
anchorX: 0.5,
anchorY: 0.5,
tint: color
});
// State: is this person already tapped?
self.tapped = false;
// Animate person popping up
personAsset.scaleY = 0.1;
tween(personAsset, {
scaleY: 1
}, {
duration: 200,
easing: tween.bounceOut
});
// On tap: collect points, animate out, destroy
self.down = function (x, y, obj) {
if (self.tapped) return;
self.tapped = true;
// Animate shrink and fade
tween(personAsset, {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
self.destroy();
}
});
// Add points
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x22223b
});
/****
* Game Code
****/
// Sound: drum hit
// Drumstick (rectangle, yellow)
// Drum (ellipse, white)
// Drummer (rectangle, brown)
// Person (circle, random color)
// Window (smaller rectangles for people to appear in)
// Building (large rectangle)
// Background asset (behind building)
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 0
});
game.addChild(background);
// Centered building
var building = LK.getAsset('building', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 180
});
game.addChild(building);
// Window grid (positions for people to appear)
var windowRows = 8;
var windowCols = 6;
var windowSpacingX = 170;
var windowSpacingY = 220;
var windowStartX = building.x - building.width / 2 + 160;
var windowStartY = building.y + 120;
var windowPositions = [];
for (var row = 0; row < windowRows; row++) {
for (var col = 0; col < windowCols; col++) {
var wx = windowStartX + col * windowSpacingX;
var wy = windowStartY + row * windowSpacingY;
// Optionally, draw window frames (for visual)
var win = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: wx,
y: wy
});
game.addChild(win);
windowPositions.push({
x: wx,
y: wy
});
}
}
// Draw vertical lines between each window column (except the last column)
for (var col = 1; col < windowCols; col++) {
var lineX = windowStartX + col * windowSpacingX - windowSpacingX / 2;
var lineHeight = windowRows * windowSpacingY - windowSpacingY / 2;
var line = LK.getAsset('window', {
width: 10,
height: lineHeight,
color: 0x888888,
shape: 'box',
anchorX: 0.5,
anchorY: 0,
x: lineX,
y: windowStartY
});
game.addChild(line);
}
// Drummer in front of building, centered horizontally, near bottom
var drummer = new Drummer();
drummer.x = 2048 / 2;
drummer.y = building.y + building.height + 60;
game.addChild(drummer);
// Score text (top center, avoid top left 100x100)
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
// Track how many times the drum has been tapped
var drumTapCount = 0;
// Array to track current people
var people = [];
// Function to spawn a person in a random window
function spawnPerson() {
// Find available windows (not already occupied)
var occupied = {};
for (var i = 0; i < people.length; i++) {
occupied[people[i].windowIdx] = true;
}
var freeWindows = [];
for (var i = 0; i < windowPositions.length; i++) {
if (!occupied[i]) freeWindows.push(i);
}
// Always pick a random window, even if all are full
var idx = Math.floor(Math.random() * windowPositions.length);
// Animate out and destroy the person currently in that window, but do not remove from array here
for (var i = people.length - 1; i >= 0; i--) {
if (people[i].windowIdx === idx) {
if (!people[i].destroyed) {
people[i].tapped = true;
tween(people[i].children[0], {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function (p) {
return function () {
p.destroy();
};
}(people[i])
});
}
break;
}
}
var pos = windowPositions[idx];
// Create person
var p = new Person();
p.x = pos.x;
p.y = pos.y;
p.windowIdx = idx;
people.push(p);
game.addChild(p);
}
// Remove destroyed people from array
function cleanupPeople() {
for (var i = people.length - 1; i >= 0; i--) {
if (people[i].destroyed) {
people.splice(i, 1);
}
}
}
// People now only spawn when drum is tapped, not periodically
// Periodically clean up destroyed people
var cleanupTimer = LK.setInterval(cleanupPeople, 500);
// Remove people after a while if not tapped
var personLifetimes = {};
game.update = function () {
// Remove people after 3 seconds if not tapped
for (var i = people.length - 1; i >= 0; i--) {
var p = people[i];
if (!personLifetimes[p.windowIdx]) {
personLifetimes[p.windowIdx] = LK.ticks;
}
if (!p.tapped && LK.ticks - personLifetimes[p.windowIdx] > 180) {
// Animate out
p.tapped = true;
tween(p.children[0], {
scaleX: 0.1,
scaleY: 0.1,
alpha: 0
}, {
duration: 200,
easing: tween.easeIn,
onFinish: function onFinish() {
p.destroy();
}
});
}
if (p.destroyed) {
delete personLifetimes[p.windowIdx];
}
}
};
// Touch handling: handled by LK via .down on Person and Drummer classes
// No need for game.move, as all interaction is via tapping people or drummer
// No music, pause, or game over logic needed per guidelines;
pencere. In-Game asset. 2d. High contrast. No shadows
meme kurbağa. In-Game asset. 2d. High contrast. No shadows
davul. In-Game asset. 2d. High contrast. No shadows
davul çubuğu. In-Game asset. 2d. High contrast. No shadows
kemal sunal. In-Game asset. 2d. High contrast. No shadows
Cami ve masmavi gokyuzu. In-Game asset. 2d. High contrast. No shadows