User prompt
Remove the platforms at the very top of the screen
User prompt
The player can't spawn at the top of the screen
User prompt
The player can't spawn in the top or bottom corners
User prompt
The player can't spawn at the very top of the screen
User prompt
Make sure all platforms are on screen
User prompt
Make sure every platform is within jumping or double jumping distance with its nahbor
User prompt
Add a double jump
User prompt
Every time the player falls off spawn the player on a random platform without a guitar pick
User prompt
Make the player spawn on a random platform without a guitar pick upon starting the game
User prompt
Make all the platforms close enough to jump from one to another but not so close that some platforms are unaccessible .
User prompt
The player should not be able to spawn on the same platform as a guitar pick
User prompt
Remove the ability to win by picking up ten guitar picks
User prompt
Guitar picks can only spawn on top of platforms
User prompt
Make it so that the player will not win instead the game starts over when the player falls off
User prompt
Make sure there are always 12 guitar picks
User prompt
You win when you get 100 points
User prompt
Make the platforms closer to the player spawn point
User prompt
Stop making the game impossible by having so much space between platforms
User prompt
Make it playable with a keyboard using the arrow keys
User prompt
The platforms are still too far away from each other
User prompt
Make the platforms closer together
User prompt
The screen shouldn't scroll up or down
User prompt
The player should always spawn at the bottom of the map and work there way up
User prompt
The score should only go up by one
User prompt
Make the score only go up when a guitar pick is collected
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Guitar = Container.expand(function () {
var self = Container.call(this);
var guitarGraphics = self.attachAsset('guitar', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 0;
self.vy = 0;
self.isJumping = false;
self.canJump = true;
self.gravity = 0.8;
self.jumpForce = -20;
self.moveSpeed = 10;
self.hasWhammy = false;
self.hasAmp = false;
self.ampTimer = 0;
self.whammyTimer = 0;
self.jump = function () {
if (self.canJump) {
self.vy = self.jumpForce;
self.isJumping = true;
self.canJump = false;
LK.getSound('jump').play();
}
};
self.update = function () {
// Apply gravity
self.vy += self.gravity;
// Move guitar
self.y += self.vy;
// Update powerup timers
if (self.hasAmp) {
self.ampTimer--;
if (self.ampTimer <= 0) {
self.hasAmp = false;
guitarGraphics.tint = 0xFFFFFF;
}
}
if (self.hasWhammy) {
self.whammyTimer--;
if (self.whammyTimer <= 0) {
self.hasWhammy = false;
guitarGraphics.alpha = 1;
}
}
};
self.activateAmplifier = function () {
self.hasAmp = true;
self.ampTimer = 300; // 5 seconds at 60fps
guitarGraphics.tint = 0xFF00FF; // Change color to indicate amplified
};
self.activateWhammy = function () {
self.hasWhammy = true;
self.whammyTimer = 300; // 5 seconds at 60fps
guitarGraphics.alpha = 0.6; // Fade to indicate whammy bar protection
};
self.reset = function () {
self.vx = 0;
self.vy = 0;
self.isJumping = false;
self.canJump = true;
self.hasWhammy = false;
self.hasAmp = false;
guitarGraphics.tint = 0xFFFFFF;
guitarGraphics.alpha = 1;
};
return self;
});
var GuitarPick = Container.expand(function () {
var self = Container.call(this);
var pickGraphics = self.attachAsset('guitarPick', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5; // Move at the same speed as platforms
self.active = true;
self.collected = false;
self.update = function () {
if (self.active && !self.collected) {
self.y += scrollSpeed;
// Rotation for nice visual effect
pickGraphics.rotation += 0.02;
// Remove if off-screen (above or below)
if (self.y > 2832 || self.y < -100) {
self.active = false;
}
}
};
self.collect = function () {
self.collected = true;
self.visible = false;
LK.getSound('pickCollect').play();
};
self.reset = function () {
self.active = true;
self.collected = false;
self.visible = true;
};
return self;
});
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5; // Default platform speed
self.active = true;
self.update = function () {
if (self.active) {
self.y += scrollSpeed;
// Remove platform if it's off-screen (above or below)
if (self.y > 2832 || self.y < -100) {
self.active = false;
}
}
};
self.reset = function () {
self.active = true;
};
return self;
});
var PowerUp = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'amplifier'; // Default to amplifier
var powerupGraphics = self.attachAsset(self.type, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5; // Move at the same speed as platforms
self.active = true;
self.collected = false;
self.update = function () {
if (self.active && !self.collected) {
self.y += scrollSpeed;
// Rotation for nice visual effect
powerupGraphics.rotation += 0.01;
// Remove if off-screen (above or below)
if (self.y > 2832 || self.y < -100) {
self.active = false;
}
}
};
self.collect = function () {
self.collected = true;
self.visible = false;
LK.getSound('powerUp').play();
};
self.reset = function () {
self.active = true;
self.collected = false;
self.visible = true;
};
return self;
});
var StringCutter = Container.expand(function () {
var self = Container.call(this);
var cutterGraphics = self.attachAsset('stringCutter', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 7; // Slightly faster than platforms
self.active = true;
self.update = function () {
if (self.active) {
self.y += scrollSpeed + 2;
// Simple animation
cutterGraphics.rotation += 0.04;
// Remove if off-screen (above or below)
if (self.y > 2832 || self.y < -100) {
self.active = false;
}
}
};
self.reset = function () {
self.active = true;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x202020
});
/****
* Game Code
****/
// Game state variables
var scrollSpeed = 0; // Set to 0 to stop screen scrolling
var score = 0;
var gameRunning = true;
var difficulty = 1;
var platformSpawnTimer = 0;
var pickSpawnTimer = 0;
var cutterSpawnTimer = 0;
var powerupSpawnTimer = 0;
var lastPlatformY = 0;
// Arrays to hold game objects
var platforms = [];
var picks = [];
var cutters = [];
var powerups = [];
// Set up background
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
game.addChild(background);
// Create player guitar
var guitar = new Guitar();
guitar.x = 2048 / 2;
guitar.y = 2732 / 2;
game.addChild(guitar);
// Create UI elements
var scoreTxt = new Text2('SCORE: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Spawner functions
function spawnPlatform() {
// Don't spawn new platforms if scrollSpeed is 0
if (scrollSpeed === 0) {
return;
}
var platform = new Platform();
platform.x = Math.random() * (2048 - 300) + 150; // Random position within screen bounds
platform.y = -50; // Start above the screen
// Track the Y-position for spawning objects on platforms
lastPlatformY = platform.y;
platforms.push(platform);
game.addChild(platform);
// Randomly decide if we should spawn a pick on this platform
if (Math.random() < 0.5) {
spawnPickOnPlatform(platform.x, platform.y);
}
// Randomly spawn a powerup (less frequently)
if (Math.random() < 0.15) {
spawnPowerupOnPlatform(platform.x, platform.y);
}
}
function spawnPickOnPlatform(x, y) {
var pick = new GuitarPick();
pick.x = x;
pick.y = y - 50; // Position slightly above the platform
picks.push(pick);
game.addChild(pick);
}
function spawnPowerupOnPlatform(x, y) {
var type = Math.random() < 0.5 ? 'amplifier' : 'whammyBar';
var powerup = new PowerUp(type);
powerup.x = x;
powerup.y = y - 70; // Position above the platform
powerups.push(powerup);
game.addChild(powerup);
}
function spawnCutter() {
var cutter = new StringCutter();
cutter.x = Math.random() * (2048 - 100) + 50; // Random position
cutter.y = -50; // Start above the screen
cutters.push(cutter);
game.addChild(cutter);
}
// Collision check functions
function checkPlatformCollisions() {
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (platform.active && guitar.vy > 0) {
// Only check when falling
if (guitar.intersects(platform)) {
// Land on the platform
guitar.y = platform.y - (platform.height / 2 + guitar.height / 2) + 10;
guitar.vy = 0;
guitar.isJumping = false;
guitar.canJump = true;
}
}
}
}
function checkPickCollisions() {
for (var i = 0; i < picks.length; i++) {
var pick = picks[i];
if (pick.active && !pick.collected && guitar.intersects(pick)) {
pick.collect();
score += 10;
scoreTxt.setText('SCORE: ' + score);
}
}
}
function checkCutterCollisions() {
for (var i = 0; i < cutters.length; i++) {
var cutter = cutters[i];
if (cutter.active && guitar.intersects(cutter)) {
if (guitar.hasWhammy) {
// Whammy bar protects from one hit
guitar.hasWhammy = false;
cutter.active = false;
cutter.visible = false;
} else {
// Game over
LK.getSound('guitarSqueal').play();
LK.effects.flashScreen(0xFF0000, 500);
gameRunning = false;
LK.showGameOver();
}
}
}
}
function checkPowerupCollisions() {
for (var i = 0; i < powerups.length; i++) {
var powerup = powerups[i];
if (powerup.active && !powerup.collected && guitar.intersects(powerup)) {
powerup.collect();
if (powerup.type === 'amplifier') {
guitar.activateAmplifier();
} else if (powerup.type === 'whammyBar') {
guitar.activateWhammy();
}
}
}
}
function checkBoundaries() {
// Don't let guitar go off the sides
if (guitar.x < guitar.width / 2) {
guitar.x = guitar.width / 2;
} else if (guitar.x > 2048 - guitar.width / 2) {
guitar.x = 2048 - guitar.width / 2;
}
// Game over if guitar goes off the top or falls off the bottom
if (guitar.y > 2732 + guitar.height || guitar.y < -guitar.height) {
LK.getSound('guitarSqueal').play();
LK.effects.flashScreen(0xFF0000, 500);
gameRunning = false;
LK.showGameOver();
}
}
// Event handlers
game.down = function (x, y, obj) {
// Jump when tapping upper half of screen
if (y < 2732 / 2) {
guitar.jump();
}
// Move left/right when tapping bottom half
else {
if (x < 2048 / 2) {
guitar.x -= guitar.moveSpeed * 5; // Move left
} else {
guitar.x += guitar.moveSpeed * 5; // Move right
}
}
};
game.move = function (x, y, obj) {
// No dragging implementation for now
};
game.up = function (x, y, obj) {
// Release handling
};
// Update function
game.update = function () {
if (!gameRunning) {
return;
}
// Increase difficulty over time
if (LK.ticks % 600 === 0 && difficulty < 5) {
difficulty += 0.5;
// Keep scrollSpeed at 0 (no movement)
scrollSpeed = 0;
}
// Update guitar
guitar.update();
// Update platforms
for (var i = platforms.length - 1; i >= 0; i--) {
platforms[i].update();
if (!platforms[i].active) {
platforms[i].destroy();
platforms.splice(i, 1);
}
}
// Update picks
for (var i = picks.length - 1; i >= 0; i--) {
picks[i].update();
if (!picks[i].active || picks[i].collected) {
picks[i].destroy();
picks.splice(i, 1);
}
}
// Update cutters
for (var i = cutters.length - 1; i >= 0; i--) {
cutters[i].update();
if (!cutters[i].active) {
cutters[i].destroy();
cutters.splice(i, 1);
}
}
// Update powerups
for (var i = powerups.length - 1; i >= 0; i--) {
powerups[i].update();
if (!powerups[i].active || powerups[i].collected) {
powerups[i].destroy();
powerups.splice(i, 1);
}
}
// Check collisions
checkPlatformCollisions();
checkPickCollisions();
checkCutterCollisions();
checkPowerupCollisions();
checkBoundaries();
// Spawn objects
platformSpawnTimer++;
cutterSpawnTimer++;
// Only spawn platforms if we're scrolling
if (scrollSpeed != 0 && platformSpawnTimer > 30) {
// Reduced from 60 to 30
spawnPlatform();
platformSpawnTimer = 0;
}
// Only spawn cutters if we're scrolling
if (scrollSpeed != 0 && score > 0 && score % 20 === 0 && cutterSpawnTimer > 60) {
spawnCutter();
cutterSpawnTimer = 0;
}
// Only guitar pick collection will increase score now
if (LK.ticks % 60 === 0) {
// Just update the global score without incrementing it
LK.setScore(score);
}
};
// Initial platform setup - platforms along the bottom portion of the screen
for (var i = 0; i < 8; i++) {
var startingPlatform = new Platform();
startingPlatform.x = Math.random() * (2048 - 300) + 150;
startingPlatform.y = 2732 - 300 - i * 250; // Reduced spacing from 400 to 250
platforms.push(startingPlatform);
game.addChild(startingPlatform);
// Add a pick to some of the initial platforms
if (Math.random() < 0.5) {
var initialPick = new GuitarPick();
initialPick.x = startingPlatform.x;
initialPick.y = startingPlatform.y - 50;
picks.push(initialPick);
game.addChild(initialPick);
}
}
// Starting platform for player at the bottom of the map
var homePlatform = new Platform();
homePlatform.x = 2048 / 2;
homePlatform.y = 2732 - 100; // Near bottom of the screen
platforms.push(homePlatform);
game.addChild(homePlatform);
// Place guitar on starting platform
guitar.x = homePlatform.x;
guitar.y = homePlatform.y - 150;
// Start the game music with a fade-in effect
LK.playMusic('rockTrack', {
fade: {
start: 0,
end: 1,
duration: 1000
}
}); ===================================================================
--- original.js
+++ change.js
@@ -424,9 +424,10 @@
// Spawn objects
platformSpawnTimer++;
cutterSpawnTimer++;
// Only spawn platforms if we're scrolling
- if (scrollSpeed != 0 && platformSpawnTimer > 60) {
+ if (scrollSpeed != 0 && platformSpawnTimer > 30) {
+ // Reduced from 60 to 30
spawnPlatform();
platformSpawnTimer = 0;
}
// Only spawn cutters if we're scrolling
@@ -440,12 +441,12 @@
LK.setScore(score);
}
};
// Initial platform setup - platforms along the bottom portion of the screen
-for (var i = 0; i < 5; i++) {
+for (var i = 0; i < 8; i++) {
var startingPlatform = new Platform();
startingPlatform.x = Math.random() * (2048 - 300) + 150;
- startingPlatform.y = 2732 - 300 - i * 400; // Start from bottom and go up
+ startingPlatform.y = 2732 - 300 - i * 250; // Reduced spacing from 400 to 250
platforms.push(startingPlatform);
game.addChild(startingPlatform);
// Add a pick to some of the initial platforms
if (Math.random() < 0.5) {
Blue Electric guitar flying v. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Electric guitar Amplifier. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Guitar pick. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Whammy bar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
String cutters. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows