var PlayerHealth = Container.expand(function () { var self = Container.call(this); self.hp = 10; var healthBarBackground = self.createAsset('healthBarBackground', 'Health Bar Background', 0, 0); var healthBarForeground = self.createAsset('healthBarForeground', 'Health Bar Foreground', 0, 0); healthBarForeground.tint = 0x00FF00; self.updateHealthBar = function () { healthBarForeground.scale.x = self.hp / 10; if (!self.healthText) { self.healthText = new Text2('', { size: 50, fill: "#ffffff" }); self.healthText.anchor.set(0.5, 0.5); self.healthText.x = healthBarBackground.width / 2; self.healthText.y = healthBarBackground.height / 2; self.addChild(self.healthText); } self.healthText.setText(self.hp.toString()); if (!self.livenessMeterText) { self.livenessMeterText = new Text2('Liveness Meter', { size: 50, fill: "#ffffff" }); self.livenessMeterText.anchor.set(0.5, 0); self.livenessMeterText.x = healthBarBackground.width + 100; self.livenessMeterText.y = healthBarBackground.height + 30; self.addChild(self.livenessMeterText); } }; self.updateHealthBar(); }); var BeatColumn1 = Container.expand(function () { var self = Container.call(this); var beatGraphics = self.createAsset('beatColumn1', 'Beat Graphics Column 1', .5, .5); self.speed = 5; self.move = function () { self.y += self.speed; }; }); var BeatColumn2 = Container.expand(function () { var self = Container.call(this); var beatGraphics = self.createAsset('beatColumn2', 'Beat Graphics Column 2', .5, .5); self.speed = 5; self.move = function () { self.y += self.speed; }; }); var BeatColumn3 = Container.expand(function () { var self = Container.call(this); var beatGraphics = self.createAsset('beatColumn3', 'Beat Graphics Column 3', .5, .5); self.speed = 5; self.move = function () { self.y += self.speed; }; }); var BeatColumn4 = Container.expand(function () { var self = Container.call(this); var beatGraphics = self.createAsset('beatColumn4', 'Beat Graphics Column 4', .5, .5); self.speed = 5; self.move = function () { self.y += self.speed; }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player Graphics', .5, .5); self.dance = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); self.gameTimer = 180; self.timerText = new Text2(self.gameTimer.toString(), { size: 150, fill: "#000000" }); self.timerText.anchor.set(0.5, 0); LK.gui.topCenter.addChild(self.timerText); self.updateTimer = function () { if (self.gameTimer > 0) { self.gameTimer--; self.timerText.setText(self.gameTimer.toString()); } else { LK.showGameOver('You Are Buck!'); } }; self.timerInterval = LK.setInterval(self.updateTimer, 1000); var score = 0; var scoreTxt = new Text2(score.toString(), { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(1, 0); LK.gui.topRight.addChild(scoreTxt); var playerHealth = self.addChild(new PlayerHealth()); playerHealth.x = 10; playerHealth.y = 10; LK.gui.topLeft.addChild(playerHealth); var background = self.createAsset('background', 'Background Image', 0, 0); self.addChildAt(background, 0); var beats = []; var player = self.addChild(new Player()); player.x = 2048 / 2; var floorHeight = 100; var playerFloorOffset = player.height / 2 + floorHeight; player.y = 2732 - playerFloorOffset; var floor = self.createAsset('floor', 'Floor Graphics', 0, 1); floor.y = 2732 - floorHeight; self.addChildAt(floor, 1); LK.on('tick', function () { player.dance(); for (var a = beats.length - 1; a >= 0; a--) { var beat = beats[a]; beat.move(); if (player.intersects(beat)) { score += 100; scoreTxt.setText(score.toString()); playerHealth.hp += 1; playerHealth.updateHealthBar(); if (playerHealth.hp >= 100) { LK.showGameOver('You Are Buck!'); } else if (playerHealth.hp <= 0) { LK.showGameOver('You Are Buck!'); } if (playerHealth.hp <= 0) { LK.showGameOver(); } beat.destroy(); beats.splice(a, 1); } else if (beat.y > 2732) { score -= 50; scoreTxt.setText(score.toString()); if (score <= 0) { LK.showGameOver('Game Over! Your score reached 0.'); } beat.destroy(); beats.splice(a, 1); } } if (LK.ticks % 60 == 0) { var columnWidth = 2048 / 4; var columnIndex = Math.floor(Math.random() * 4); var newBeat; switch (columnIndex) { case 0: newBeat = new BeatColumn1(); break; case 1: newBeat = new BeatColumn2(); break; case 2: newBeat = new BeatColumn3(); break; case 3: newBeat = new BeatColumn4(); break; } newBeat.x = columnIndex * columnWidth + columnWidth / 2; newBeat.y = 0; beats.push(newBeat); self.addChild(newBeat); } }); stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); var columnWidth = 2048 / 4; var columnIndex = Math.floor(pos.x / columnWidth); player.x = columnIndex * columnWidth + columnWidth / 2; }); });
var PlayerHealth = Container.expand(function () {
var self = Container.call(this);
self.hp = 10;
var healthBarBackground = self.createAsset('healthBarBackground', 'Health Bar Background', 0, 0);
var healthBarForeground = self.createAsset('healthBarForeground', 'Health Bar Foreground', 0, 0);
healthBarForeground.tint = 0x00FF00;
self.updateHealthBar = function () {
healthBarForeground.scale.x = self.hp / 10;
if (!self.healthText) {
self.healthText = new Text2('', {
size: 50,
fill: "#ffffff"
});
self.healthText.anchor.set(0.5, 0.5);
self.healthText.x = healthBarBackground.width / 2;
self.healthText.y = healthBarBackground.height / 2;
self.addChild(self.healthText);
}
self.healthText.setText(self.hp.toString());
if (!self.livenessMeterText) {
self.livenessMeterText = new Text2('Liveness Meter', {
size: 50,
fill: "#ffffff"
});
self.livenessMeterText.anchor.set(0.5, 0);
self.livenessMeterText.x = healthBarBackground.width + 100;
self.livenessMeterText.y = healthBarBackground.height + 30;
self.addChild(self.livenessMeterText);
}
};
self.updateHealthBar();
});
var BeatColumn1 = Container.expand(function () {
var self = Container.call(this);
var beatGraphics = self.createAsset('beatColumn1', 'Beat Graphics Column 1', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var BeatColumn2 = Container.expand(function () {
var self = Container.call(this);
var beatGraphics = self.createAsset('beatColumn2', 'Beat Graphics Column 2', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var BeatColumn3 = Container.expand(function () {
var self = Container.call(this);
var beatGraphics = self.createAsset('beatColumn3', 'Beat Graphics Column 3', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var BeatColumn4 = Container.expand(function () {
var self = Container.call(this);
var beatGraphics = self.createAsset('beatColumn4', 'Beat Graphics Column 4', .5, .5);
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.createAsset('player', 'Player Graphics', .5, .5);
self.dance = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.gameTimer = 180;
self.timerText = new Text2(self.gameTimer.toString(), {
size: 150,
fill: "#000000"
});
self.timerText.anchor.set(0.5, 0);
LK.gui.topCenter.addChild(self.timerText);
self.updateTimer = function () {
if (self.gameTimer > 0) {
self.gameTimer--;
self.timerText.setText(self.gameTimer.toString());
} else {
LK.showGameOver('You Are Buck!');
}
};
self.timerInterval = LK.setInterval(self.updateTimer, 1000);
var score = 0;
var scoreTxt = new Text2(score.toString(), {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
var playerHealth = self.addChild(new PlayerHealth());
playerHealth.x = 10;
playerHealth.y = 10;
LK.gui.topLeft.addChild(playerHealth);
var background = self.createAsset('background', 'Background Image', 0, 0);
self.addChildAt(background, 0);
var beats = [];
var player = self.addChild(new Player());
player.x = 2048 / 2;
var floorHeight = 100;
var playerFloorOffset = player.height / 2 + floorHeight;
player.y = 2732 - playerFloorOffset;
var floor = self.createAsset('floor', 'Floor Graphics', 0, 1);
floor.y = 2732 - floorHeight;
self.addChildAt(floor, 1);
LK.on('tick', function () {
player.dance();
for (var a = beats.length - 1; a >= 0; a--) {
var beat = beats[a];
beat.move();
if (player.intersects(beat)) {
score += 100;
scoreTxt.setText(score.toString());
playerHealth.hp += 1;
playerHealth.updateHealthBar();
if (playerHealth.hp >= 100) {
LK.showGameOver('You Are Buck!');
} else if (playerHealth.hp <= 0) {
LK.showGameOver('You Are Buck!');
}
if (playerHealth.hp <= 0) {
LK.showGameOver();
}
beat.destroy();
beats.splice(a, 1);
} else if (beat.y > 2732) {
score -= 50;
scoreTxt.setText(score.toString());
if (score <= 0) {
LK.showGameOver('Game Over! Your score reached 0.');
}
beat.destroy();
beats.splice(a, 1);
}
}
if (LK.ticks % 60 == 0) {
var columnWidth = 2048 / 4;
var columnIndex = Math.floor(Math.random() * 4);
var newBeat;
switch (columnIndex) {
case 0:
newBeat = new BeatColumn1();
break;
case 1:
newBeat = new BeatColumn2();
break;
case 2:
newBeat = new BeatColumn3();
break;
case 3:
newBeat = new BeatColumn4();
break;
}
newBeat.x = columnIndex * columnWidth + columnWidth / 2;
newBeat.y = 0;
beats.push(newBeat);
self.addChild(newBeat);
}
});
stage.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
var columnWidth = 2048 / 4;
var columnIndex = Math.floor(pos.x / columnWidth);
player.x = columnIndex * columnWidth + columnWidth / 2;
});
});
a forward facing brick with the writing "Stomp" Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a forward facing brick with the writing "Jab" Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A Krump Dancer wearing a snapback and Timberlands shoes Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a forward facing brick with the writing "Chest Pop" Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a forward facing brick with the writing "Arm Swing" Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
an urban street road near a boom box Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a concrete floor Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.