/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var KeyboardButton = Container.expand(function (label) {
var self = Container.call(this);
self.label = label;
self.background = self.addChild(LK.getAsset('A', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.5
}));
self.background.alpha = 0.5;
self.text = self.addChild(new Text2(label, {
size: 28,
fill: 0xFFFFFF
}));
self.text.anchor.set(0.5, 0.5);
self.down = function (x, y, obj) {
// This will be handled by parent keyboard
};
return self;
});
var PinballGame = Container.expand(function () {
var self = Container.call(this);
self.isActive = false;
self.ball = null;
self.paddles = [];
self.score = 0;
self.ballSpeed = {
x: 5,
y: 5
};
self.start = function () {
self.isActive = true;
// Create ball
self.ball = self.addChild(LK.getAsset('Balls', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
}));
self.ball.x = 1024;
self.ball.y = 1366;
// Create single paddle
var paddle = self.addChild(LK.getAsset('A', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 1
}));
paddle.x = 1024;
paddle.y = 2200;
self.paddles.push(paddle);
// Update title to show pinball mode
titleText.setText('Game Time!');
};
self.update = function () {
if (!self.isActive || !self.ball) return;
// Move ball
self.ball.x += self.ballSpeed.x;
self.ball.y += self.ballSpeed.y;
// Bounce off walls
if (self.ball.x <= 50 || self.ball.x >= 1998) {
self.ballSpeed.x = -self.ballSpeed.x;
}
if (self.ball.y <= 50) {
self.ballSpeed.y = -self.ballSpeed.y;
}
// Check paddle collisions
for (var i = 0; i < self.paddles.length; i++) {
if (self.ball.intersects(self.paddles[i])) {
self.ballSpeed.y = -Math.abs(self.ballSpeed.y); // Always bounce up
self.score += 10;
// Play bounce sound
LK.getSound('Sound').play();
}
}
// Ball falls off bottom - game over
if (self.ball.y > 2732) {
self.stop();
}
};
self.move = function (x, y, obj) {
if (self.isActive && self.paddles.length > 0) {
// Move paddle to follow finger position
self.paddles[0].x = x;
// Keep paddle within screen bounds
if (self.paddles[0].x < 100) self.paddles[0].x = 100;
if (self.paddles[0].x > 1948) self.paddles[0].x = 1948;
}
};
self.stop = function () {
self.isActive = false;
if (self.ball) {
self.removeChild(self.ball);
self.ball = null;
}
for (var i = 0; i < self.paddles.length; i++) {
self.removeChild(self.paddles[i]);
}
self.paddles = [];
titleText.setText('Johnathan T. Mantleholder');
// Hide input field and keyboard
textInputField.hide();
virtualKeyboard.visible = false;
};
return self;
});
var TextInputField = Container.expand(function () {
var self = Container.call(this);
self.inputText = '';
self.isActive = false;
self.responseText = null;
// Create input display background
self.inputBackground = self.addChild(LK.getAsset('A', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 0.8
}));
self.inputBackground.alpha = 0.3;
// Create input text display
self.displayText = self.addChild(new Text2('', {
size: 60,
fill: 0xFFFFFF
}));
self.displayText.anchor.set(0.5, 0.5);
self.show = function () {
self.isActive = true;
self.inputText = '';
self.displayText.setText('');
self.visible = true;
};
self.hide = function () {
self.isActive = false;
self.inputText = '';
self.displayText.setText('');
self.visible = false;
if (self.responseText) {
self.removeChild(self.responseText);
self.responseText = null;
}
};
self.addCharacter = function (_char) {
if (!self.isActive) return;
if (self.inputText.length < 30) {
self.inputText += _char;
self.displayText.setText(self.inputText);
}
};
self.removeCharacter = function () {
if (!self.isActive) return;
self.inputText = self.inputText.slice(0, -1);
self.displayText.setText(self.inputText);
};
self.submitInput = function () {
if (!self.isActive) return;
var lowerInput = self.inputText.toLowerCase();
var response = '';
if (lowerInput.indexOf('what') === 0 || lowerInput.indexOf('why') === 0 || lowerInput.indexOf('when') === 0 || lowerInput.indexOf('how') === 0) {
response = 'idk dude';
} else {
var rand = Math.random() * 100;
if (rand < 40) {
response = 'yes';
} else if (rand < 80) {
response = 'no';
} else if (rand < 90) {
response = 'definitely';
} else if (rand < 98) {
response = 'definitely not';
} else {
response = 'maybe';
}
}
// Remove old response if exists
if (self.responseText) {
self.removeChild(self.responseText);
}
// Create response text
self.responseText = self.addChild(new Text2(response, {
size: 80,
fill: 0x00FF00
}));
self.responseText.anchor.set(0.5, 0.5);
self.responseText.y = -150;
// Clear input
self.inputText = '';
self.displayText.setText('');
};
self.visible = false;
return self;
});
var TransformButton = Container.expand(function () {
var self = Container.call(this);
// Array of button states
self.buttonStates = ['button1'];
self.soundStates = ['Sound'];
self.currentState = 0;
// Create initial button graphics
self.buttonGraphics = self.attachAsset(self.buttonStates[0], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
self.transformToNext = function () {
// Add shrinking animation
tween(self.buttonGraphics, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
// Return to full size
tween(self.buttonGraphics, {
scaleX: 2.0,
scaleY: 2.0
}, {
duration: 100,
easing: tween.easeOut
});
}
});
// Cycle to next state
self.currentState = (self.currentState + 1) % self.buttonStates.length;
// Remove current graphics
self.removeChild(self.buttonGraphics);
// Add new graphics
self.buttonGraphics = self.attachAsset(self.buttonStates[self.currentState], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
// Play corresponding sound
LK.getSound(self.soundStates[self.currentState]).play();
};
self.down = function (x, y, obj) {
// Track click time
var currentTime = Date.now();
clickTimes.push(currentTime);
// Keep only clicks from the last second
clickTimes = clickTimes.filter(function (time) {
return currentTime - time <= 1000;
});
// Check if we have 7 clicks in the last second
if (clickTimes.length >= 7 && !hasTriggeredSpecialMode) {
hasTriggeredSpecialMode = true;
// Play music
LK.playMusic('Music');
// Change text to "Johnathan T. Mantleholder"
titleText.setText('Johnathan T. Mantleholder');
// Show input field and keyboard
textInputField.show();
virtualKeyboard.visible = true;
}
// Pattern detection logic (only active after special mode is triggered)
if (hasTriggeredSpecialMode) {
// Check if enough time has passed since last click to consider this a new pattern step
var timeSinceLastClick = currentTime - lastClickTime;
var expectedClicks = patternSequence[currentPatternStep];
var isRapidClickStep = currentPatternStep === 3; // Last step requires rapid clicks
if (timeSinceLastClick > waitThreshold && patternClickCount > 0) {
// We've waited long enough, check if previous step was completed correctly
if (patternClickCount === expectedClicks) {
currentPatternStep++;
patternClickCount = 0;
if (currentPatternStep >= patternSequence.length) {
// Pattern completed! Start pinball game with 1 second delay
LK.setTimeout(function () {
startPinballGame();
}, 1000);
// Reset pattern tracking
currentPatternStep = 0;
patternClickCount = 0;
}
} else {
// Wrong number of clicks, reset pattern
currentPatternStep = 0;
patternClickCount = 0;
}
}
// Count this click for current pattern step
patternClickCount++;
lastClickTime = currentTime;
// For rapid click step, check timing between clicks
if (isRapidClickStep && patternClickCount > 1) {
if (timeSinceLastClick > rapidClickThreshold) {
// Too slow between rapid clicks, reset pattern
currentPatternStep = 0;
patternClickCount = 0;
}
}
}
self.transformToNext();
};
return self;
});
var VirtualKeyboard = Container.expand(function (inputField) {
var self = Container.call(this);
self.inputField = inputField;
self.buttons = [];
var keyboardLayout = [['Q', 'W', 'E', 'R', 'T', 'Y'], ['A', 'S', 'D', 'F', 'G', 'H'], ['Z', 'X', 'C', 'V', 'B', 'N']];
var startX = 400;
var startY = 2048;
var buttonSpacing = 180;
for (var row = 0; row < keyboardLayout.length; row++) {
for (var col = 0; col < keyboardLayout[row].length; col++) {
var letter = keyboardLayout[row][col];
var btn = self.addChild(new KeyboardButton(letter));
btn.x = startX + col * buttonSpacing;
btn.y = startY + row * buttonSpacing;
btn.isKeyButton = true;
btn.keyChar = letter.toLowerCase();
self.buttons.push(btn);
}
}
// Add space button
var spaceBtn = self.addChild(new KeyboardButton('SPACE'));
spaceBtn.x = 1024;
spaceBtn.y = startY + 3 * buttonSpacing;
spaceBtn.background.scaleX = 3;
spaceBtn.keyChar = ' ';
spaceBtn.isKeyButton = true;
self.buttons.push(spaceBtn);
// Add delete button
var delBtn = self.addChild(new KeyboardButton('DEL'));
delBtn.x = 700;
delBtn.y = startY + 4 * buttonSpacing;
delBtn.isDeleteButton = true;
self.buttons.push(delBtn);
// Add enter button
var enterBtn = self.addChild(new KeyboardButton('ENTER'));
enterBtn.x = 1348;
enterBtn.y = startY + 4 * buttonSpacing;
enterBtn.background.scaleX = 1.2;
enterBtn.isSubmitButton = true;
self.buttons.push(enterBtn);
self.handleKeyPress = function (keyChar) {
if (keyChar === ' ') {
self.inputField.addCharacter(' ');
} else {
self.inputField.addCharacter(keyChar);
}
};
self.visible = false;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Add background
var background = game.addChild(LK.getAsset('Background', {
anchorX: 0,
anchorY: 0,
scaleX: 20.48,
scaleY: 27.32
}));
background.x = 0;
background.y = 0;
// Start continuous floating animation for background
function startBackgroundFloatingAnimation() {
tween(background, {
x: -50
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(background, {
x: 0
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: startBackgroundFloatingAnimation
});
}
});
}
// Start the background floating animation
startBackgroundFloatingAnimation();
// Click tracking variables
var clickTimes = [];
var hasTriggeredSpecialMode = false;
// Pattern tracking variables for pinball sequence
var patternSequence = [1, 2, 2, 5]; // Expected pattern: 1 click, wait, 2 clicks, wait, 2 clicks, wait, 5 clicks
var currentPatternStep = 0;
var patternClickCount = 0;
var lastClickTime = 0;
var waitThreshold = 500; // 0.5 second wait between pattern steps
var rapidClickThreshold = 500; // Max time between rapid clicks (for the "5 quickly" part)
// Create title text
var titleText = new Text2('John Mantle', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 2732 / 2 - 400;
game.addChild(titleText);
// Create the transform button
var transformButton = game.addChild(new TransformButton());
// Position button at center of screen
transformButton.x = 2048 / 2;
transformButton.y = 2732 / 2;
// Start continuous up and down movement animation
function startFloatingAnimation() {
tween(transformButton, {
y: transformButton.y - 50
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(transformButton, {
y: transformButton.y + 50
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: startFloatingAnimation
});
}
});
}
// Start the floating animation
startFloatingAnimation();
// Create text input field
var textInputField = game.addChild(new TextInputField());
textInputField.x = 1024;
textInputField.y = 1366 + 300;
// Create virtual keyboard
var virtualKeyboard = game.addChild(new VirtualKeyboard(textInputField));
virtualKeyboard.x = 0;
virtualKeyboard.y = 0;
// Create pinball game instance
var pinballGame = game.addChild(new PinballGame());
// Function to start pinball game
function startPinballGame() {
pinballGame.start();
}
game.down = function (x, y, obj) {
// Check if clicking on keyboard buttons
if (virtualKeyboard.visible) {
for (var i = 0; i < virtualKeyboard.buttons.length; i++) {
var btn = virtualKeyboard.buttons[i];
if (obj === btn || obj && obj.parent === btn) {
if (btn.isDeleteButton) {
textInputField.removeCharacter();
} else if (btn.isSubmitButton) {
textInputField.submitInput();
} else if (btn.isKeyButton) {
textInputField.addCharacter(btn.keyChar);
}
return;
}
}
}
};
game.move = function (x, y, obj) {
// Delegate move events to pinball game
pinballGame.move(x, y, obj);
};
game.update = function () {
// Update pinball game if active
pinballGame.update();
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var KeyboardButton = Container.expand(function (label) {
var self = Container.call(this);
self.label = label;
self.background = self.addChild(LK.getAsset('A', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7,
scaleY: 0.5
}));
self.background.alpha = 0.5;
self.text = self.addChild(new Text2(label, {
size: 28,
fill: 0xFFFFFF
}));
self.text.anchor.set(0.5, 0.5);
self.down = function (x, y, obj) {
// This will be handled by parent keyboard
};
return self;
});
var PinballGame = Container.expand(function () {
var self = Container.call(this);
self.isActive = false;
self.ball = null;
self.paddles = [];
self.score = 0;
self.ballSpeed = {
x: 5,
y: 5
};
self.start = function () {
self.isActive = true;
// Create ball
self.ball = self.addChild(LK.getAsset('Balls', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5
}));
self.ball.x = 1024;
self.ball.y = 1366;
// Create single paddle
var paddle = self.addChild(LK.getAsset('A', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 1
}));
paddle.x = 1024;
paddle.y = 2200;
self.paddles.push(paddle);
// Update title to show pinball mode
titleText.setText('Game Time!');
};
self.update = function () {
if (!self.isActive || !self.ball) return;
// Move ball
self.ball.x += self.ballSpeed.x;
self.ball.y += self.ballSpeed.y;
// Bounce off walls
if (self.ball.x <= 50 || self.ball.x >= 1998) {
self.ballSpeed.x = -self.ballSpeed.x;
}
if (self.ball.y <= 50) {
self.ballSpeed.y = -self.ballSpeed.y;
}
// Check paddle collisions
for (var i = 0; i < self.paddles.length; i++) {
if (self.ball.intersects(self.paddles[i])) {
self.ballSpeed.y = -Math.abs(self.ballSpeed.y); // Always bounce up
self.score += 10;
// Play bounce sound
LK.getSound('Sound').play();
}
}
// Ball falls off bottom - game over
if (self.ball.y > 2732) {
self.stop();
}
};
self.move = function (x, y, obj) {
if (self.isActive && self.paddles.length > 0) {
// Move paddle to follow finger position
self.paddles[0].x = x;
// Keep paddle within screen bounds
if (self.paddles[0].x < 100) self.paddles[0].x = 100;
if (self.paddles[0].x > 1948) self.paddles[0].x = 1948;
}
};
self.stop = function () {
self.isActive = false;
if (self.ball) {
self.removeChild(self.ball);
self.ball = null;
}
for (var i = 0; i < self.paddles.length; i++) {
self.removeChild(self.paddles[i]);
}
self.paddles = [];
titleText.setText('Johnathan T. Mantleholder');
// Hide input field and keyboard
textInputField.hide();
virtualKeyboard.visible = false;
};
return self;
});
var TextInputField = Container.expand(function () {
var self = Container.call(this);
self.inputText = '';
self.isActive = false;
self.responseText = null;
// Create input display background
self.inputBackground = self.addChild(LK.getAsset('A', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 0.8
}));
self.inputBackground.alpha = 0.3;
// Create input text display
self.displayText = self.addChild(new Text2('', {
size: 60,
fill: 0xFFFFFF
}));
self.displayText.anchor.set(0.5, 0.5);
self.show = function () {
self.isActive = true;
self.inputText = '';
self.displayText.setText('');
self.visible = true;
};
self.hide = function () {
self.isActive = false;
self.inputText = '';
self.displayText.setText('');
self.visible = false;
if (self.responseText) {
self.removeChild(self.responseText);
self.responseText = null;
}
};
self.addCharacter = function (_char) {
if (!self.isActive) return;
if (self.inputText.length < 30) {
self.inputText += _char;
self.displayText.setText(self.inputText);
}
};
self.removeCharacter = function () {
if (!self.isActive) return;
self.inputText = self.inputText.slice(0, -1);
self.displayText.setText(self.inputText);
};
self.submitInput = function () {
if (!self.isActive) return;
var lowerInput = self.inputText.toLowerCase();
var response = '';
if (lowerInput.indexOf('what') === 0 || lowerInput.indexOf('why') === 0 || lowerInput.indexOf('when') === 0 || lowerInput.indexOf('how') === 0) {
response = 'idk dude';
} else {
var rand = Math.random() * 100;
if (rand < 40) {
response = 'yes';
} else if (rand < 80) {
response = 'no';
} else if (rand < 90) {
response = 'definitely';
} else if (rand < 98) {
response = 'definitely not';
} else {
response = 'maybe';
}
}
// Remove old response if exists
if (self.responseText) {
self.removeChild(self.responseText);
}
// Create response text
self.responseText = self.addChild(new Text2(response, {
size: 80,
fill: 0x00FF00
}));
self.responseText.anchor.set(0.5, 0.5);
self.responseText.y = -150;
// Clear input
self.inputText = '';
self.displayText.setText('');
};
self.visible = false;
return self;
});
var TransformButton = Container.expand(function () {
var self = Container.call(this);
// Array of button states
self.buttonStates = ['button1'];
self.soundStates = ['Sound'];
self.currentState = 0;
// Create initial button graphics
self.buttonGraphics = self.attachAsset(self.buttonStates[0], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
self.transformToNext = function () {
// Add shrinking animation
tween(self.buttonGraphics, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
// Return to full size
tween(self.buttonGraphics, {
scaleX: 2.0,
scaleY: 2.0
}, {
duration: 100,
easing: tween.easeOut
});
}
});
// Cycle to next state
self.currentState = (self.currentState + 1) % self.buttonStates.length;
// Remove current graphics
self.removeChild(self.buttonGraphics);
// Add new graphics
self.buttonGraphics = self.attachAsset(self.buttonStates[self.currentState], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.0,
scaleY: 2.0
});
// Play corresponding sound
LK.getSound(self.soundStates[self.currentState]).play();
};
self.down = function (x, y, obj) {
// Track click time
var currentTime = Date.now();
clickTimes.push(currentTime);
// Keep only clicks from the last second
clickTimes = clickTimes.filter(function (time) {
return currentTime - time <= 1000;
});
// Check if we have 7 clicks in the last second
if (clickTimes.length >= 7 && !hasTriggeredSpecialMode) {
hasTriggeredSpecialMode = true;
// Play music
LK.playMusic('Music');
// Change text to "Johnathan T. Mantleholder"
titleText.setText('Johnathan T. Mantleholder');
// Show input field and keyboard
textInputField.show();
virtualKeyboard.visible = true;
}
// Pattern detection logic (only active after special mode is triggered)
if (hasTriggeredSpecialMode) {
// Check if enough time has passed since last click to consider this a new pattern step
var timeSinceLastClick = currentTime - lastClickTime;
var expectedClicks = patternSequence[currentPatternStep];
var isRapidClickStep = currentPatternStep === 3; // Last step requires rapid clicks
if (timeSinceLastClick > waitThreshold && patternClickCount > 0) {
// We've waited long enough, check if previous step was completed correctly
if (patternClickCount === expectedClicks) {
currentPatternStep++;
patternClickCount = 0;
if (currentPatternStep >= patternSequence.length) {
// Pattern completed! Start pinball game with 1 second delay
LK.setTimeout(function () {
startPinballGame();
}, 1000);
// Reset pattern tracking
currentPatternStep = 0;
patternClickCount = 0;
}
} else {
// Wrong number of clicks, reset pattern
currentPatternStep = 0;
patternClickCount = 0;
}
}
// Count this click for current pattern step
patternClickCount++;
lastClickTime = currentTime;
// For rapid click step, check timing between clicks
if (isRapidClickStep && patternClickCount > 1) {
if (timeSinceLastClick > rapidClickThreshold) {
// Too slow between rapid clicks, reset pattern
currentPatternStep = 0;
patternClickCount = 0;
}
}
}
self.transformToNext();
};
return self;
});
var VirtualKeyboard = Container.expand(function (inputField) {
var self = Container.call(this);
self.inputField = inputField;
self.buttons = [];
var keyboardLayout = [['Q', 'W', 'E', 'R', 'T', 'Y'], ['A', 'S', 'D', 'F', 'G', 'H'], ['Z', 'X', 'C', 'V', 'B', 'N']];
var startX = 400;
var startY = 2048;
var buttonSpacing = 180;
for (var row = 0; row < keyboardLayout.length; row++) {
for (var col = 0; col < keyboardLayout[row].length; col++) {
var letter = keyboardLayout[row][col];
var btn = self.addChild(new KeyboardButton(letter));
btn.x = startX + col * buttonSpacing;
btn.y = startY + row * buttonSpacing;
btn.isKeyButton = true;
btn.keyChar = letter.toLowerCase();
self.buttons.push(btn);
}
}
// Add space button
var spaceBtn = self.addChild(new KeyboardButton('SPACE'));
spaceBtn.x = 1024;
spaceBtn.y = startY + 3 * buttonSpacing;
spaceBtn.background.scaleX = 3;
spaceBtn.keyChar = ' ';
spaceBtn.isKeyButton = true;
self.buttons.push(spaceBtn);
// Add delete button
var delBtn = self.addChild(new KeyboardButton('DEL'));
delBtn.x = 700;
delBtn.y = startY + 4 * buttonSpacing;
delBtn.isDeleteButton = true;
self.buttons.push(delBtn);
// Add enter button
var enterBtn = self.addChild(new KeyboardButton('ENTER'));
enterBtn.x = 1348;
enterBtn.y = startY + 4 * buttonSpacing;
enterBtn.background.scaleX = 1.2;
enterBtn.isSubmitButton = true;
self.buttons.push(enterBtn);
self.handleKeyPress = function (keyChar) {
if (keyChar === ' ') {
self.inputField.addCharacter(' ');
} else {
self.inputField.addCharacter(keyChar);
}
};
self.visible = false;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Add background
var background = game.addChild(LK.getAsset('Background', {
anchorX: 0,
anchorY: 0,
scaleX: 20.48,
scaleY: 27.32
}));
background.x = 0;
background.y = 0;
// Start continuous floating animation for background
function startBackgroundFloatingAnimation() {
tween(background, {
x: -50
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(background, {
x: 0
}, {
duration: 4000,
easing: tween.easeInOut,
onFinish: startBackgroundFloatingAnimation
});
}
});
}
// Start the background floating animation
startBackgroundFloatingAnimation();
// Click tracking variables
var clickTimes = [];
var hasTriggeredSpecialMode = false;
// Pattern tracking variables for pinball sequence
var patternSequence = [1, 2, 2, 5]; // Expected pattern: 1 click, wait, 2 clicks, wait, 2 clicks, wait, 5 clicks
var currentPatternStep = 0;
var patternClickCount = 0;
var lastClickTime = 0;
var waitThreshold = 500; // 0.5 second wait between pattern steps
var rapidClickThreshold = 500; // Max time between rapid clicks (for the "5 quickly" part)
// Create title text
var titleText = new Text2('John Mantle', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 2732 / 2 - 400;
game.addChild(titleText);
// Create the transform button
var transformButton = game.addChild(new TransformButton());
// Position button at center of screen
transformButton.x = 2048 / 2;
transformButton.y = 2732 / 2;
// Start continuous up and down movement animation
function startFloatingAnimation() {
tween(transformButton, {
y: transformButton.y - 50
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(transformButton, {
y: transformButton.y + 50
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: startFloatingAnimation
});
}
});
}
// Start the floating animation
startFloatingAnimation();
// Create text input field
var textInputField = game.addChild(new TextInputField());
textInputField.x = 1024;
textInputField.y = 1366 + 300;
// Create virtual keyboard
var virtualKeyboard = game.addChild(new VirtualKeyboard(textInputField));
virtualKeyboard.x = 0;
virtualKeyboard.y = 0;
// Create pinball game instance
var pinballGame = game.addChild(new PinballGame());
// Function to start pinball game
function startPinballGame() {
pinballGame.start();
}
game.down = function (x, y, obj) {
// Check if clicking on keyboard buttons
if (virtualKeyboard.visible) {
for (var i = 0; i < virtualKeyboard.buttons.length; i++) {
var btn = virtualKeyboard.buttons[i];
if (obj === btn || obj && obj.parent === btn) {
if (btn.isDeleteButton) {
textInputField.removeCharacter();
} else if (btn.isSubmitButton) {
textInputField.submitInput();
} else if (btn.isKeyButton) {
textInputField.addCharacter(btn.keyChar);
}
return;
}
}
}
};
game.move = function (x, y, obj) {
// Delegate move events to pinball game
pinballGame.move(x, y, obj);
};
game.update = function () {
// Update pinball game if active
pinballGame.update();
};