/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Goal = Container.expand(function () {
var self = Container.call(this);
var goalBox = self.attachAsset('goalBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.goalData = {
id: 0,
title: 'Study Goal',
duration: 25,
difficulty: 1,
completed: false,
createdAt: Date.now()
};
self.updateGoal = function (data) {
self.goalData = data;
self.updateDisplay();
};
self.updateDisplay = function () {
self.removeChild(self.titleText);
self.removeChild(self.durationText);
self.removeChild(self.difficultyText);
self.titleText = new Text2(self.goalData.title.substring(0, 20), {
size: 32,
fill: '#ffffff'
});
self.titleText.anchor.set(0.5, 0);
self.titleText.position.set(0, -40);
self.addChild(self.titleText);
self.durationText = new Text2(self.goalData.duration + ' min', {
size: 24,
fill: '#00d4ff'
});
self.durationText.anchor.set(0.5, 0);
self.durationText.position.set(0, 0);
self.addChild(self.durationText);
var difficultyStr = self.goalData.difficulty === 1 ? 'Easy' : self.goalData.difficulty === 2 ? 'Medium' : 'Hard';
self.difficultyText = new Text2(difficultyStr, {
size: 20,
fill: '#ff6b6b'
});
self.difficultyText.anchor.set(0.5, 0);
self.difficultyText.position.set(0, 35);
self.addChild(self.difficultyText);
};
self.setCompleted = function () {
self.goalData.completed = true;
goalBox.tint = 0x00d4ff;
tween(goalBox, {
tint: 0x2E5090
}, {
duration: 2000
});
};
self.updateDisplay();
return self;
});
var MotivationalMessage = Container.expand(function () {
var self = Container.call(this);
var messages = ["You\'ve got this! Stay focused!", "Great progress! Keep it up!", "Every minute counts. Amazing work!", "Your future self will thank you!", "Consistency is key to success!", "You\'re building great habits!", "Focus now, celebrate later!", "One session closer to mastery!", "Discipline equals freedom!", "You are unstoppable!"];
self.messageText = new Text2('You\'ve got this!', {
size: 36,
fill: '#00d4ff'
});
self.messageText.anchor.set(0.5, 0.5);
self.addChild(self.messageText);
self.displayRandomMessage = function () {
var randomIndex = Math.floor(Math.random() * messages.length);
self.messageText.setText(messages[randomIndex]);
tween(self, {
alpha: 1
}, {
duration: 300
});
LK.setTimeout(function () {
tween(self, {
alpha: 0
}, {
duration: 300
});
}, 3000);
};
self.alpha = 0;
return self;
});
var ProgressTracker = Container.expand(function () {
var self = Container.call(this);
self.stats = {
totalSessionsCompleted: 0,
totalStudyMinutes: 0,
currentStreak: 0,
longestStreak: 0,
achievementsUnlocked: 0
};
self.titleText = new Text2('Progress Overview', {
size: 48,
fill: '#00d4ff'
});
self.titleText.anchor.set(0, 0);
self.titleText.position.set(-900, -1200);
self.addChild(self.titleText);
self.updateStats = function (newStats) {
self.stats = newStats;
self.updateDisplay();
};
self.updateDisplay = function () {
self.removeChild(self.sessionsText);
self.removeChild(self.minutesText);
self.removeChild(self.streakText);
self.removeChild(self.achievementsText);
self.sessionsText = new Text2('Sessions: ' + self.stats.totalSessionsCompleted, {
size: 28,
fill: '#ffffff'
});
self.sessionsText.anchor.set(0, 0);
self.sessionsText.position.set(-900, -1100);
self.addChild(self.sessionsText);
self.minutesText = new Text2('Study Time: ' + self.stats.totalStudyMinutes + ' min', {
size: 28,
fill: '#00d4ff'
});
self.minutesText.anchor.set(0, 0);
self.minutesText.position.set(-900, -1040);
self.addChild(self.minutesText);
self.streakText = new Text2('🔥 Streak: ' + self.stats.currentStreak + ' days', {
size: 28,
fill: '#ff6b6b'
});
self.streakText.anchor.set(0, 0);
self.streakText.position.set(-900, -980);
self.addChild(self.streakText);
self.achievementsText = new Text2('Achievements: ' + self.stats.achievementsUnlocked, {
size: 28,
fill: '#ffd60a'
});
self.achievementsText.anchor.set(0, 0);
self.achievementsText.position.set(-900, -920);
self.addChild(self.achievementsText);
};
self.updateDisplay();
return self;
});
var Timer = Container.expand(function () {
var self = Container.call(this);
var timerBg = self.attachAsset('timerBackground', {
anchorX: 0.5,
anchorY: 0.5
});
var timerCircle = self.attachAsset('timerCircle', {
anchorX: 0.5,
anchorY: 0.5
});
self.timerData = {
totalSeconds: 1500,
remainingSeconds: 1500,
isRunning: false,
isPaused: false
};
self.timeDisplay = new Text2('25:00', {
size: 120,
fill: '#00d4ff'
});
self.timeDisplay.anchor.set(0.5, 0.5);
self.timeDisplay.position.set(0, -30);
self.addChild(self.timeDisplay);
self.statusText = new Text2('Ready to focus', {
size: 32,
fill: '#ffffff'
});
self.statusText.anchor.set(0.5, 0.5);
self.statusText.position.set(0, 100);
self.addChild(self.statusText);
self.initializeTimer = function (seconds) {
self.timerData.totalSeconds = seconds;
self.timerData.remainingSeconds = seconds;
self.timerData.isRunning = false;
self.timerData.isPaused = false;
self.updateDisplay();
};
self.startTimer = function () {
if (!self.timerData.isRunning) {
self.timerData.isRunning = true;
self.timerData.isPaused = false;
self.statusText.setText('Focus in progress...');
LK.getSound('sessionStart').play();
}
};
self.pauseTimer = function () {
if (self.timerData.isRunning) {
self.timerData.isRunning = false;
self.timerData.isPaused = true;
self.statusText.setText('Paused');
}
};
self.resumeTimer = function () {
if (self.timerData.isPaused) {
self.timerData.isRunning = true;
self.statusText.setText('Focus in progress...');
}
};
self.resetTimer = function () {
self.timerData.isRunning = false;
self.timerData.isPaused = false;
self.timerData.remainingSeconds = self.timerData.totalSeconds;
self.statusText.setText('Ready to focus');
self.updateDisplay();
};
self.updateDisplay = function () {
var mins = Math.floor(self.timerData.remainingSeconds / 60);
var secs = self.timerData.remainingSeconds % 60;
var timeStr = (mins < 10 ? '0' : '') + mins + ':' + (secs < 10 ? '0' : '') + secs;
self.timeDisplay.setText(timeStr);
var progress = 1 - self.timerData.remainingSeconds / self.timerData.totalSeconds;
timerCircle.scaleX = 0.8 + progress * 0.2;
timerCircle.scaleY = 0.8 + progress * 0.2;
if (progress > 0.5) {
timerCircle.tint = 0xff6b6b;
} else if (progress > 0.75) {
timerCircle.tint = 0xffd60a;
} else {
timerCircle.tint = 0x16213e;
}
};
self.tick = function () {
if (self.timerData.isRunning && self.timerData.remainingSeconds > 0) {
self.timerData.remainingSeconds -= 1 / 60;
if (self.timerData.remainingSeconds < 0) {
self.timerData.remainingSeconds = 0;
self.timerData.isRunning = false;
self.statusText.setText('Session Complete!');
LK.getSound('sessionComplete').play();
}
self.updateDisplay();
}
};
self.initializeTimer(1500);
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0f0f1e
});
/****
* Game Code
****/
var gameState = {
currentView: 'main',
goals: [],
completedGoals: [],
stats: {
totalSessionsCompleted: 0,
totalStudyMinutes: 0,
currentStreak: 0,
longestStreak: 0,
achievementsUnlocked: 0,
lastSessionDate: null
},
currentSession: null,
inputValue: '',
selectedDifficulty: 1,
selectedDuration: 25
};
var goalsContainer = new Container();
goalsContainer.position.set(1024, 400);
game.addChild(goalsContainer);
var timer = new Timer();
timer.position.set(1024, 1366);
timer.alpha = 0;
game.addChild(timer);
var motivationalMessage = new MotivationalMessage();
motivationalMessage.position.set(1024, 600);
game.addChild(motivationalMessage);
var progressTracker = new ProgressTracker();
progressTracker.position.set(1024, 1366);
game.addChild(progressTracker);
var goalsTitle = new Text2('Your Study Goals', {
size: 52,
fill: '#00d4ff'
});
goalsTitle.anchor.set(0.5, 0);
goalsTitle.position.set(1024, 100);
game.addChild(goalsTitle);
var goalInputContainer = new Container();
goalInputContainer.position.set(1024, 250);
game.addChild(goalInputContainer);
var inputLabel = new Text2('Goal Title:', {
size: 28,
fill: '#ffffff'
});
inputLabel.anchor.set(0.5, 0);
inputLabel.position.set(-400, -80);
goalInputContainer.addChild(inputLabel);
var durationLabel = new Text2('Duration: ' + gameState.selectedDuration + ' min', {
size: 24,
fill: '#00d4ff'
});
durationLabel.anchor.set(0.5, 0);
durationLabel.position.set(0, -80);
goalInputContainer.addChild(durationLabel);
var difficultyLabel = new Text2('Difficulty:', {
size: 24,
fill: '#ff6b6b'
});
difficultyLabel.anchor.set(0.5, 0);
difficultyLabel.position.set(400, -80);
goalInputContainer.addChild(difficultyLabel);
var addGoalButton = new Container();
addGoalButton.position.set(1024, 350);
addGoalButton.interactive = true;
game.addChild(addGoalButton);
var addGoalButtonShape = addGoalButton.attachAsset('buttonStart', {
anchorX: 0.5,
anchorY: 0.5
});
var addGoalButtonText = new Text2('Add Goal', {
size: 32,
fill: '#1a1a2e'
});
addGoalButtonText.anchor.set(0.5, 0.5);
addGoalButton.addChild(addGoalButtonText);
var startSessionButton = new Container();
startSessionButton.position.set(1024, 2550);
startSessionButton.interactive = true;
game.addChild(startSessionButton);
var startButtonShape = startSessionButton.attachAsset('buttonStart', {
anchorX: 0.5,
anchorY: 0.5
});
var startButtonText = new Text2('Start Session', {
size: 32,
fill: '#1a1a2e'
});
startButtonText.anchor.set(0.5, 0.5);
startSessionButton.addChild(startButtonText);
var pauseButton = new Container();
pauseButton.position.set(500, 2550);
pauseButton.interactive = true;
pauseButton.alpha = 0;
game.addChild(pauseButton);
var pauseButtonShape = pauseButton.attachAsset('buttonPause', {
anchorX: 0.5,
anchorY: 0.5
});
var pauseButtonText = new Text2('Pause', {
size: 32,
fill: '#1a1a2e'
});
pauseButtonText.anchor.set(0.5, 0.5);
pauseButton.addChild(pauseButtonText);
var resetButton = new Container();
resetButton.position.set(1548, 2550);
resetButton.interactive = true;
resetButton.alpha = 0;
game.addChild(resetButton);
var resetButtonShape = resetButton.attachAsset('buttonReset', {
anchorX: 0.5,
anchorY: 0.5
});
var resetButtonText = new Text2('Reset', {
size: 32,
fill: '#1a1a2e'
});
resetButtonText.anchor.set(0.5, 0.5);
resetButton.addChild(resetButtonText);
var sessionActiveGoal = null;
function loadGameState() {
if (storage.gameState) {
gameState = storage.gameState;
}
if (storage.goals) {
gameState.goals = storage.goals;
}
if (storage.stats) {
gameState.stats = storage.stats;
}
displayGoals();
progressTracker.updateStats(gameState.stats);
}
function saveGameState() {
storage.gameState = gameState;
storage.goals = gameState.goals;
storage.stats = gameState.stats;
}
function displayGoals() {
goalsContainer.removeChildren();
var yOffset = -280;
for (var i = 0; i < gameState.goals.length; i++) {
var goalElement = new Goal();
goalElement.position.set(0, yOffset);
goalElement.updateGoal(gameState.goals[i]);
goalsContainer.addChild(goalElement);
yOffset += 180;
}
}
function createNewGoal() {
if (gameState.inputValue.length > 0) {
var newGoal = {
id: Date.now(),
title: gameState.inputValue,
duration: gameState.selectedDuration,
difficulty: gameState.selectedDifficulty,
completed: false,
createdAt: Date.now()
};
gameState.goals.push(newGoal);
gameState.inputValue = '';
gameState.selectedDuration = 25;
gameState.selectedDifficulty = 1;
displayGoals();
saveGameState();
motivationalMessage.displayRandomMessage();
}
}
addGoalButton.down = function () {
tween(addGoalButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(addGoalButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
var goalTitle = prompt('Enter your study goal:');
if (goalTitle) {
gameState.inputValue = goalTitle;
createNewGoal();
}
};
function startSession() {
if (gameState.goals.length > 0) {
for (var i = 0; i < gameState.goals.length; i++) {
if (!gameState.goals[i].completed) {
sessionActiveGoal = gameState.goals[i];
break;
}
}
if (sessionActiveGoal) {
timer.initializeTimer(sessionActiveGoal.duration * 60);
timer.startTimer();
tween(timer, {
alpha: 1
}, {
duration: 500
});
tween(goaliesTitle, {
alpha: 0
}, {
duration: 500
});
tween(goalInputContainer, {
alpha: 0
}, {
duration: 500
});
tween(addGoalButton, {
alpha: 0
}, {
duration: 500
});
tween(startSessionButton, {
alpha: 0
}, {
duration: 500
});
tween(pauseButton, {
alpha: 1
}, {
duration: 500
});
tween(resetButton, {
alpha: 1
}, {
duration: 500
});
goalsTitle.setText(sessionActiveGoal.title);
tween(goalsTitle, {
alpha: 1
}, {
duration: 500
});
goalsTitle.position.set(1024, 100);
gameState.currentSession = {
goalId: sessionActiveGoal.id,
startTime: Date.now(),
initialDuration: sessionActiveGoal.duration
};
}
}
}
;
startSessionButton.down = function () {
tween(startButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(startButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
startSession();
};
pauseButton.down = function () {
tween(pauseButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(pauseButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
if (timer.timerData.isRunning) {
timer.pauseTimer();
pauseButtonText.setText('Resume');
} else if (timer.timerData.isPaused) {
timer.resumeTimer();
pauseButtonText.setText('Pause');
}
};
resetButton.down = function () {
tween(resetButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(resetButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
timer.resetTimer();
timer.timerData.isRunning = false;
tween(timer, {
alpha: 0
}, {
duration: 500
});
tween(goalsTitle, {
alpha: 0
}, {
duration: 500
});
tween(pauseButton, {
alpha: 0
}, {
duration: 500
});
tween(resetButton, {
alpha: 0
}, {
duration: 500
});
tween(goaliesTitle, {
alpha: 1
}, {
duration: 500
});
tween(goalInputContainer, {
alpha: 1
}, {
duration: 500
});
tween(addGoalButton, {
alpha: 1
}, {
duration: 500
});
tween(startSessionButton, {
alpha: 1
}, {
duration: 500
});
goalsTitle.setText('Your Study Goals');
pauseButtonText.setText('Pause');
sessionActiveGoal = null;
gameState.currentSession = null;
};
game.move = function (x, y, obj) {
// Movement tracking
};
game.down = function (x, y, obj) {
// Touch down handling
};
game.up = function (x, y, obj) {
// Touch up handling
};
game.update = function () {
if (timer.timerData.isRunning) {
timer.tick();
if (timer.timerData.remainingSeconds <= 0 && sessionActiveGoal) {
sessionActiveGoal.completed = true;
gameState.stats.totalSessionsCompleted += 1;
gameState.stats.totalStudyMinutes += sessionActiveGoal.duration;
gameState.stats.currentStreak += 1;
gameState.stats.lastSessionDate = Date.now();
if (gameState.stats.currentStreak > gameState.stats.longestStreak) {
gameState.stats.longestStreak = gameState.stats.currentStreak;
}
if (gameState.stats.totalSessionsCompleted % 5 === 0) {
gameState.stats.achievementsUnlocked += 1;
LK.getSound('achievement').play();
}
saveGameState();
progressTracker.updateStats(gameState.stats);
timer.timerData.isRunning = false;
motivationalMessage.displayRandomMessage();
displayGoals();
}
}
};
loadGameState();
LK.playMusic('bgMusic', {
loop: true
}); /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Goal = Container.expand(function () {
var self = Container.call(this);
var goalBox = self.attachAsset('goalBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.goalData = {
id: 0,
title: 'Study Goal',
duration: 25,
difficulty: 1,
completed: false,
createdAt: Date.now()
};
self.updateGoal = function (data) {
self.goalData = data;
self.updateDisplay();
};
self.updateDisplay = function () {
self.removeChild(self.titleText);
self.removeChild(self.durationText);
self.removeChild(self.difficultyText);
self.titleText = new Text2(self.goalData.title.substring(0, 20), {
size: 32,
fill: '#ffffff'
});
self.titleText.anchor.set(0.5, 0);
self.titleText.position.set(0, -40);
self.addChild(self.titleText);
self.durationText = new Text2(self.goalData.duration + ' min', {
size: 24,
fill: '#00d4ff'
});
self.durationText.anchor.set(0.5, 0);
self.durationText.position.set(0, 0);
self.addChild(self.durationText);
var difficultyStr = self.goalData.difficulty === 1 ? 'Easy' : self.goalData.difficulty === 2 ? 'Medium' : 'Hard';
self.difficultyText = new Text2(difficultyStr, {
size: 20,
fill: '#ff6b6b'
});
self.difficultyText.anchor.set(0.5, 0);
self.difficultyText.position.set(0, 35);
self.addChild(self.difficultyText);
};
self.setCompleted = function () {
self.goalData.completed = true;
goalBox.tint = 0x00d4ff;
tween(goalBox, {
tint: 0x2E5090
}, {
duration: 2000
});
};
self.updateDisplay();
return self;
});
var MotivationalMessage = Container.expand(function () {
var self = Container.call(this);
var messages = ["You\'ve got this! Stay focused!", "Great progress! Keep it up!", "Every minute counts. Amazing work!", "Your future self will thank you!", "Consistency is key to success!", "You\'re building great habits!", "Focus now, celebrate later!", "One session closer to mastery!", "Discipline equals freedom!", "You are unstoppable!"];
self.messageText = new Text2('You\'ve got this!', {
size: 36,
fill: '#00d4ff'
});
self.messageText.anchor.set(0.5, 0.5);
self.addChild(self.messageText);
self.displayRandomMessage = function () {
var randomIndex = Math.floor(Math.random() * messages.length);
self.messageText.setText(messages[randomIndex]);
tween(self, {
alpha: 1
}, {
duration: 300
});
LK.setTimeout(function () {
tween(self, {
alpha: 0
}, {
duration: 300
});
}, 3000);
};
self.alpha = 0;
return self;
});
var ProgressTracker = Container.expand(function () {
var self = Container.call(this);
self.stats = {
totalSessionsCompleted: 0,
totalStudyMinutes: 0,
currentStreak: 0,
longestStreak: 0,
achievementsUnlocked: 0
};
self.titleText = new Text2('Progress Overview', {
size: 48,
fill: '#00d4ff'
});
self.titleText.anchor.set(0, 0);
self.titleText.position.set(-900, -1200);
self.addChild(self.titleText);
self.updateStats = function (newStats) {
self.stats = newStats;
self.updateDisplay();
};
self.updateDisplay = function () {
self.removeChild(self.sessionsText);
self.removeChild(self.minutesText);
self.removeChild(self.streakText);
self.removeChild(self.achievementsText);
self.sessionsText = new Text2('Sessions: ' + self.stats.totalSessionsCompleted, {
size: 28,
fill: '#ffffff'
});
self.sessionsText.anchor.set(0, 0);
self.sessionsText.position.set(-900, -1100);
self.addChild(self.sessionsText);
self.minutesText = new Text2('Study Time: ' + self.stats.totalStudyMinutes + ' min', {
size: 28,
fill: '#00d4ff'
});
self.minutesText.anchor.set(0, 0);
self.minutesText.position.set(-900, -1040);
self.addChild(self.minutesText);
self.streakText = new Text2('🔥 Streak: ' + self.stats.currentStreak + ' days', {
size: 28,
fill: '#ff6b6b'
});
self.streakText.anchor.set(0, 0);
self.streakText.position.set(-900, -980);
self.addChild(self.streakText);
self.achievementsText = new Text2('Achievements: ' + self.stats.achievementsUnlocked, {
size: 28,
fill: '#ffd60a'
});
self.achievementsText.anchor.set(0, 0);
self.achievementsText.position.set(-900, -920);
self.addChild(self.achievementsText);
};
self.updateDisplay();
return self;
});
var Timer = Container.expand(function () {
var self = Container.call(this);
var timerBg = self.attachAsset('timerBackground', {
anchorX: 0.5,
anchorY: 0.5
});
var timerCircle = self.attachAsset('timerCircle', {
anchorX: 0.5,
anchorY: 0.5
});
self.timerData = {
totalSeconds: 1500,
remainingSeconds: 1500,
isRunning: false,
isPaused: false
};
self.timeDisplay = new Text2('25:00', {
size: 120,
fill: '#00d4ff'
});
self.timeDisplay.anchor.set(0.5, 0.5);
self.timeDisplay.position.set(0, -30);
self.addChild(self.timeDisplay);
self.statusText = new Text2('Ready to focus', {
size: 32,
fill: '#ffffff'
});
self.statusText.anchor.set(0.5, 0.5);
self.statusText.position.set(0, 100);
self.addChild(self.statusText);
self.initializeTimer = function (seconds) {
self.timerData.totalSeconds = seconds;
self.timerData.remainingSeconds = seconds;
self.timerData.isRunning = false;
self.timerData.isPaused = false;
self.updateDisplay();
};
self.startTimer = function () {
if (!self.timerData.isRunning) {
self.timerData.isRunning = true;
self.timerData.isPaused = false;
self.statusText.setText('Focus in progress...');
LK.getSound('sessionStart').play();
}
};
self.pauseTimer = function () {
if (self.timerData.isRunning) {
self.timerData.isRunning = false;
self.timerData.isPaused = true;
self.statusText.setText('Paused');
}
};
self.resumeTimer = function () {
if (self.timerData.isPaused) {
self.timerData.isRunning = true;
self.statusText.setText('Focus in progress...');
}
};
self.resetTimer = function () {
self.timerData.isRunning = false;
self.timerData.isPaused = false;
self.timerData.remainingSeconds = self.timerData.totalSeconds;
self.statusText.setText('Ready to focus');
self.updateDisplay();
};
self.updateDisplay = function () {
var mins = Math.floor(self.timerData.remainingSeconds / 60);
var secs = self.timerData.remainingSeconds % 60;
var timeStr = (mins < 10 ? '0' : '') + mins + ':' + (secs < 10 ? '0' : '') + secs;
self.timeDisplay.setText(timeStr);
var progress = 1 - self.timerData.remainingSeconds / self.timerData.totalSeconds;
timerCircle.scaleX = 0.8 + progress * 0.2;
timerCircle.scaleY = 0.8 + progress * 0.2;
if (progress > 0.5) {
timerCircle.tint = 0xff6b6b;
} else if (progress > 0.75) {
timerCircle.tint = 0xffd60a;
} else {
timerCircle.tint = 0x16213e;
}
};
self.tick = function () {
if (self.timerData.isRunning && self.timerData.remainingSeconds > 0) {
self.timerData.remainingSeconds -= 1 / 60;
if (self.timerData.remainingSeconds < 0) {
self.timerData.remainingSeconds = 0;
self.timerData.isRunning = false;
self.statusText.setText('Session Complete!');
LK.getSound('sessionComplete').play();
}
self.updateDisplay();
}
};
self.initializeTimer(1500);
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x0f0f1e
});
/****
* Game Code
****/
var gameState = {
currentView: 'main',
goals: [],
completedGoals: [],
stats: {
totalSessionsCompleted: 0,
totalStudyMinutes: 0,
currentStreak: 0,
longestStreak: 0,
achievementsUnlocked: 0,
lastSessionDate: null
},
currentSession: null,
inputValue: '',
selectedDifficulty: 1,
selectedDuration: 25
};
var goalsContainer = new Container();
goalsContainer.position.set(1024, 400);
game.addChild(goalsContainer);
var timer = new Timer();
timer.position.set(1024, 1366);
timer.alpha = 0;
game.addChild(timer);
var motivationalMessage = new MotivationalMessage();
motivationalMessage.position.set(1024, 600);
game.addChild(motivationalMessage);
var progressTracker = new ProgressTracker();
progressTracker.position.set(1024, 1366);
game.addChild(progressTracker);
var goalsTitle = new Text2('Your Study Goals', {
size: 52,
fill: '#00d4ff'
});
goalsTitle.anchor.set(0.5, 0);
goalsTitle.position.set(1024, 100);
game.addChild(goalsTitle);
var goalInputContainer = new Container();
goalInputContainer.position.set(1024, 250);
game.addChild(goalInputContainer);
var inputLabel = new Text2('Goal Title:', {
size: 28,
fill: '#ffffff'
});
inputLabel.anchor.set(0.5, 0);
inputLabel.position.set(-400, -80);
goalInputContainer.addChild(inputLabel);
var durationLabel = new Text2('Duration: ' + gameState.selectedDuration + ' min', {
size: 24,
fill: '#00d4ff'
});
durationLabel.anchor.set(0.5, 0);
durationLabel.position.set(0, -80);
goalInputContainer.addChild(durationLabel);
var difficultyLabel = new Text2('Difficulty:', {
size: 24,
fill: '#ff6b6b'
});
difficultyLabel.anchor.set(0.5, 0);
difficultyLabel.position.set(400, -80);
goalInputContainer.addChild(difficultyLabel);
var addGoalButton = new Container();
addGoalButton.position.set(1024, 350);
addGoalButton.interactive = true;
game.addChild(addGoalButton);
var addGoalButtonShape = addGoalButton.attachAsset('buttonStart', {
anchorX: 0.5,
anchorY: 0.5
});
var addGoalButtonText = new Text2('Add Goal', {
size: 32,
fill: '#1a1a2e'
});
addGoalButtonText.anchor.set(0.5, 0.5);
addGoalButton.addChild(addGoalButtonText);
var startSessionButton = new Container();
startSessionButton.position.set(1024, 2550);
startSessionButton.interactive = true;
game.addChild(startSessionButton);
var startButtonShape = startSessionButton.attachAsset('buttonStart', {
anchorX: 0.5,
anchorY: 0.5
});
var startButtonText = new Text2('Start Session', {
size: 32,
fill: '#1a1a2e'
});
startButtonText.anchor.set(0.5, 0.5);
startSessionButton.addChild(startButtonText);
var pauseButton = new Container();
pauseButton.position.set(500, 2550);
pauseButton.interactive = true;
pauseButton.alpha = 0;
game.addChild(pauseButton);
var pauseButtonShape = pauseButton.attachAsset('buttonPause', {
anchorX: 0.5,
anchorY: 0.5
});
var pauseButtonText = new Text2('Pause', {
size: 32,
fill: '#1a1a2e'
});
pauseButtonText.anchor.set(0.5, 0.5);
pauseButton.addChild(pauseButtonText);
var resetButton = new Container();
resetButton.position.set(1548, 2550);
resetButton.interactive = true;
resetButton.alpha = 0;
game.addChild(resetButton);
var resetButtonShape = resetButton.attachAsset('buttonReset', {
anchorX: 0.5,
anchorY: 0.5
});
var resetButtonText = new Text2('Reset', {
size: 32,
fill: '#1a1a2e'
});
resetButtonText.anchor.set(0.5, 0.5);
resetButton.addChild(resetButtonText);
var sessionActiveGoal = null;
function loadGameState() {
if (storage.gameState) {
gameState = storage.gameState;
}
if (storage.goals) {
gameState.goals = storage.goals;
}
if (storage.stats) {
gameState.stats = storage.stats;
}
displayGoals();
progressTracker.updateStats(gameState.stats);
}
function saveGameState() {
storage.gameState = gameState;
storage.goals = gameState.goals;
storage.stats = gameState.stats;
}
function displayGoals() {
goalsContainer.removeChildren();
var yOffset = -280;
for (var i = 0; i < gameState.goals.length; i++) {
var goalElement = new Goal();
goalElement.position.set(0, yOffset);
goalElement.updateGoal(gameState.goals[i]);
goalsContainer.addChild(goalElement);
yOffset += 180;
}
}
function createNewGoal() {
if (gameState.inputValue.length > 0) {
var newGoal = {
id: Date.now(),
title: gameState.inputValue,
duration: gameState.selectedDuration,
difficulty: gameState.selectedDifficulty,
completed: false,
createdAt: Date.now()
};
gameState.goals.push(newGoal);
gameState.inputValue = '';
gameState.selectedDuration = 25;
gameState.selectedDifficulty = 1;
displayGoals();
saveGameState();
motivationalMessage.displayRandomMessage();
}
}
addGoalButton.down = function () {
tween(addGoalButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(addGoalButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
var goalTitle = prompt('Enter your study goal:');
if (goalTitle) {
gameState.inputValue = goalTitle;
createNewGoal();
}
};
function startSession() {
if (gameState.goals.length > 0) {
for (var i = 0; i < gameState.goals.length; i++) {
if (!gameState.goals[i].completed) {
sessionActiveGoal = gameState.goals[i];
break;
}
}
if (sessionActiveGoal) {
timer.initializeTimer(sessionActiveGoal.duration * 60);
timer.startTimer();
tween(timer, {
alpha: 1
}, {
duration: 500
});
tween(goaliesTitle, {
alpha: 0
}, {
duration: 500
});
tween(goalInputContainer, {
alpha: 0
}, {
duration: 500
});
tween(addGoalButton, {
alpha: 0
}, {
duration: 500
});
tween(startSessionButton, {
alpha: 0
}, {
duration: 500
});
tween(pauseButton, {
alpha: 1
}, {
duration: 500
});
tween(resetButton, {
alpha: 1
}, {
duration: 500
});
goalsTitle.setText(sessionActiveGoal.title);
tween(goalsTitle, {
alpha: 1
}, {
duration: 500
});
goalsTitle.position.set(1024, 100);
gameState.currentSession = {
goalId: sessionActiveGoal.id,
startTime: Date.now(),
initialDuration: sessionActiveGoal.duration
};
}
}
}
;
startSessionButton.down = function () {
tween(startButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(startButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
startSession();
};
pauseButton.down = function () {
tween(pauseButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(pauseButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
if (timer.timerData.isRunning) {
timer.pauseTimer();
pauseButtonText.setText('Resume');
} else if (timer.timerData.isPaused) {
timer.resumeTimer();
pauseButtonText.setText('Pause');
}
};
resetButton.down = function () {
tween(resetButtonShape, {
tint: 0xffd60a
}, {
duration: 100
});
LK.setTimeout(function () {
tween(resetButtonShape, {
tint: 0xffffff
}, {
duration: 100
});
}, 100);
timer.resetTimer();
timer.timerData.isRunning = false;
tween(timer, {
alpha: 0
}, {
duration: 500
});
tween(goalsTitle, {
alpha: 0
}, {
duration: 500
});
tween(pauseButton, {
alpha: 0
}, {
duration: 500
});
tween(resetButton, {
alpha: 0
}, {
duration: 500
});
tween(goaliesTitle, {
alpha: 1
}, {
duration: 500
});
tween(goalInputContainer, {
alpha: 1
}, {
duration: 500
});
tween(addGoalButton, {
alpha: 1
}, {
duration: 500
});
tween(startSessionButton, {
alpha: 1
}, {
duration: 500
});
goalsTitle.setText('Your Study Goals');
pauseButtonText.setText('Pause');
sessionActiveGoal = null;
gameState.currentSession = null;
};
game.move = function (x, y, obj) {
// Movement tracking
};
game.down = function (x, y, obj) {
// Touch down handling
};
game.up = function (x, y, obj) {
// Touch up handling
};
game.update = function () {
if (timer.timerData.isRunning) {
timer.tick();
if (timer.timerData.remainingSeconds <= 0 && sessionActiveGoal) {
sessionActiveGoal.completed = true;
gameState.stats.totalSessionsCompleted += 1;
gameState.stats.totalStudyMinutes += sessionActiveGoal.duration;
gameState.stats.currentStreak += 1;
gameState.stats.lastSessionDate = Date.now();
if (gameState.stats.currentStreak > gameState.stats.longestStreak) {
gameState.stats.longestStreak = gameState.stats.currentStreak;
}
if (gameState.stats.totalSessionsCompleted % 5 === 0) {
gameState.stats.achievementsUnlocked += 1;
LK.getSound('achievement').play();
}
saveGameState();
progressTracker.updateStats(gameState.stats);
timer.timerData.isRunning = false;
motivationalMessage.displayRandomMessage();
displayGoals();
}
}
};
loadGameState();
LK.playMusic('bgMusic', {
loop: true
});
Modern App Store icon, high definition, square with rounded corners, for a game titled "FocusFlow - Study Goals & Progress Tracker" and with the description "A gamified study companion that combines goal-setting, timed focus sessions, motivational messaging, and progress visualization to help students maintain discipline and build consistent learning habits.". No text on icon!
Create a goal box of a learning app .like regain app. In-Game asset. 2d. High contrast. No shadows. 3d based on study
Create a timer circle for this app. In-Game asset. 2d. High contrast. No shadows
Create a achivement for this learning app and this name is study king !. In-Game asset. 2d. High contrast. No shadows
Create a stylish start button. In-Game asset. 2d. High contrast. No shadows. #3d
Create progress fill image for this learning app. In-Game asset. 2d. High contrast. No shadows. #3d #stylish #realistic #based on study