/****
* Classes
****/
// Define the Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroBlue = self.createAsset('heroBlue', 'Hero character blue', 0.5, 0.5);
var heroYellow = self.createAsset('heroYellow', 'Hero character yellow', 0.5, 0.5);
heroBlue.visible = true;
heroYellow.visible = false;
// Toggle hero color
self.toggleColor = function () {
heroBlue.visible = !heroBlue.visible;
heroYellow.visible = !heroYellow.visible;
};
self.speedY = 0;
// Hero is static in the center of the screen
self.update = function () {};
});
// Define the Coin_Blue class
var Coin_Blue = Container.expand(function (x, y) {
var self = Container.call(this);
var coinGraphics = self.createAsset('coinBlue', 'Blue Coin', 0.5, 0.5);
self.x = x;
self.y = y;
// Move the coin
self.speed = 5;
self.acceleration = 0.1;
self.move = function () {
var dx = game.width / 2 - self.x;
var dy = game.height / 2 - self.y;
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
self.speed += self.acceleration;
};
// Check if the coin is off-screen
self.isOffScreen = function () {
return self.x < -coinGraphics.width;
};
});
// Define the Coin_Yellow class
var Coin_Yellow = Container.expand(function (x, y) {
var self = Container.call(this);
var coinGraphics = self.createAsset('coinYellow', 'Yellow Coin', 0.5, 0.5);
self.x = x;
self.y = y;
// Move the coin
self.speed = 5;
self.acceleration = 0.1;
self.move = function () {
var dx = game.width / 2 - self.x;
var dy = game.height / 2 - self.y;
var angle = Math.atan2(dy, dx);
self.x += Math.cos(angle) * self.speed;
self.y += Math.sin(angle) * self.speed;
self.speed += self.acceleration;
};
// Check if the coin is off-screen
self.isOffScreen = function () {
return self.x < -coinGraphics.width;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Create and add a background image
var background = game.addChild(LK.getAsset('background', 'Game background', 0.5, 0.5));
background.x = game.width / 2;
background.y = game.height / 2;
background.width = game.width;
background.height = game.height;
// Initialize important asset arrays and game variables
var hero;
var obstacles = [];
var colors = [0xFF0000, 0x00FF00, 0x0000FF]; // Red, Green, Blue
var score = 0;
var scoreCounter = 0;
var messages = ['Find peace in each breath.', 'Balance is the path.', 'Harmony within the moment.', 'Inhale, exhale, be here now.', 'Zen master tranquility.', 'Flow like a gentle stream.', 'Mind still as tranquil waters.', 'Breathe in, let go.', ' Present moment, eternal bliss .', ' Seek serenity within yourself.', ' Embrace the yin and yang.', ' Surrender to the present.', ' Calm the mind, collect serenity.', ' Silence speaks the truth.', ' Peace in every step.', ' Awaken the inner zen.', ' Balance, unity, serenity.', ' Meditate, find your center.', ' In stillness, find strength.', ' Harmonize with the universe.', ' Find serenity within the silence.', ' Breathe deeply, be here now.', ' Flow with the rhythm of life.', ' Balance is the key to peace.', ' In the moment, all is calm.', ' Seek stillness in motion.', ' Mindfulness is your guide.', ' Zen masters wisdom shines.', ' Each step a meditation.', ' Present moment, eternal grace.', ' Embrace the dance of yin and yang.', ' Quiet the mind, find clarity.', ' Silent mind, open heart.', ' Peaceful heart, tranquil soul.', ' Calm waters run deep.', ' Let go, find your center.', ' In the stillness, discover truth.', ' Awaken your inner zen.', ' Unity in diversity.', ' Breathe, focus, meditate.', ' Harmony with the cosmos.', ' Meditation is the key.', ' The journey within begins.', ' Serenity in simplicity.', ' Flow like a gentle breeze.', ' Balance, bliss, and beauty.', ' Find calm amid chaos.', ' The answer is in stillness.', ' Yin and yang, two halves.', ' In this moment, all is well.', ' Inner peace, your true treasure.', ' Let stillness reveal your path.', ' Surrender to the flow within.', ' Eyes closed, heart wide open.', ' Mindfulness lights the way.', ' Harmony whispers in silence.', ' Awaken the inner observer.', ' Find the calm in chaos.', ' Inhale serenity, exhale gratitude.', ' Peace blooms in the present.', ' Embrace the power of now.', ' Breathe, and just be.', ' Meditation: your sacred sanctuary.', ' Flow like water, find peace.', ' With each breath, find stillness.', ' Balance your souls scales.', ' In stillness, find your strength.', ' Zen moments, infinite wisdom.', ' Awaken the dormant universe within.', ' Through meditation, we transcend.', ' Mindfully tread lifes path.', ' Be the calm in the storm.', ' Meditate, illuminate, elevate.', ' Zen is the art of living.', ' One breath, one world.', ' In the present, all is well.', ' Serenity flows from within.', ' Unlock your inner zen master.', ' Through stillness, find clarity.', ' Meditation: the journey inward.', ' Silent mind, boundless horizons.', ' Meditate, and the answers unfold.', ' Find peace in the here and now.', ' Flow with grace, embrace change.', ' In stillness, you are complete.', ' Serenity blossoms within your breath.', ' Awaken the tranquil warrior within.', ' Peace is the journey and destination.', ' Mind like water, always present.', ' Through mindfulness, discover miracles.', ' Breathe in, let go, be free.', ' In the present, all is perfect.', ' Harmony dances in every moment.', ' Your essence is pure tranquility.', ' Quiet the mind, find your essence.', ' Meditation is the key to presence.', ' Find the universe within your breath.', ' Simplicity is the ultimate sophistication.', ' Stillness reveals the infinite within.', ' With each breath, you awaken.'];
var scoreTxt;
var obstacleTimer = 0;
var gameOver = false;
// Create the hero and set initial color to blue
hero = game.addChild(new Hero());
hero.x = game.width / 2;
hero.y = game.height / 2;
// Create the score text
scoreTxt = new Text2('0', {
size: 120,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 10
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.y -= 80;
LK.gui.center.addChild(scoreTxt);
// Create a new UI element at the bottom of the board
var messageTxt = new Text2('Remember to breathe.', {
size: 75,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 20
});
messageTxt.anchor.set(0.5, 0.5);
messageTxt.x = game.width / 100;
messageTxt.y = game.height / 25;
LK.gui.top.addChild(messageTxt);
// Handle the tap event to toggle the hero's color
game.on('down', function (obj) {
if (!gameOver) {
hero.toggleColor();
}
});
// Game tick event
LK.on('tick', function () {
if (!gameOver) {
// Update the hero
hero.update();
var spawnPoints = [{
x: 0,
y: 0
}, {
x: game.width,
y: 0
}, {
x: 0,
y: game.height
}, {
x: game.width,
y: game.height
}];
// Add a new coin every 60 frames (1 second)
obstacleTimer++;
if (obstacleTimer >= Math.max(33, 90 - score)) {
obstacleTimer = 0;
// If all spawn points have been used, replenish them
if (spawnPoints.length === 0) {
spawnPoints = [{
x: 0,
y: 0
}, {
x: game.width,
y: 0
}, {
x: 0,
y: game.height
}, {
x: game.width,
y: game.height
}];
}
// Select a random spawn point and remove it from the array
var spawnIndex = Math.floor(Math.random() * spawnPoints.length);
var spawnPoint = spawnPoints[spawnIndex];
spawnPoints.splice(spawnIndex, 1);
// Generate a random coin type
var coinType = Math.random() < 0.5 ? Coin_Blue : Coin_Yellow;
// Spawn the coin at the selected spawn point
var coin = new coinType(spawnPoint.x, spawnPoint.y);
obstacles.push(coin);
game.addChild(coin);
}
// Update coins
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].move();
// Check for collision
if (hero.intersects(obstacles[i])) {
if (obstacles[i] instanceof Coin_Blue && hero.children[0].visible || obstacles[i] instanceof Coin_Yellow && hero.children[1].visible) {
// Increment score when correct coin is collected
score++;
scoreCounter++;
scoreTxt.setText(score.toString());
if (scoreCounter % 3 == 0) {
if (messages.length == 0) {
messages = ['Find peace in each breath.', 'Balance is the path.', 'Harmony within the moment.', 'Inhale, exhale, be here now.', 'Zen master tranquility.', 'Flow like a gentle stream.', 'Mind still as tranquil waters.', 'Breathe in, let go.'];
}
var messageIndex = Math.floor(Math.random() * messages.length);
messageTxt.setText(messages[messageIndex]);
messages.splice(messageIndex, 1);
}
// Add animation to score text
scoreTxt.anchor.set(0.5, 0.1);
scoreTxt.scale.set(1.25, 1.25);
LK.setTimeout(function () {
scoreTxt.scale.set(1, 1);
scoreTxt.anchor.set(0.5, 0.1);
}, 100);
obstacles[i].destroy();
obstacles.splice(i, 1);
} else {
gameOver = true;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Remove off-screen coins
if (obstacles[i] && obstacles[i].isOffScreen()) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
}
}
});
minimalist meditation background. no elements. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. High contrast. No shadows.
black 8-ball biliard ball. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white round ball with black edges. has a black infinity logo inprinted on it. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round black circle. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white circle with a thin black paintbrushed outline. minimalist. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.