User prompt
Add reset button, give them visors
User prompt
Remove mix complete, mixes loop every 9 secs
Code edit (1 edits merged)
Please save this source code
User prompt
Among Us Music Mix
User prompt
No, make music mix Game where you choose 2 colors of among us character out of the 6 (red, blue, yellow, green, pink, black)
Initial prompt
Game where you choose 2 colors of among us character out of the 6 (red, blue, yellow, green, pink, black)
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AmongUsCharacter = Container.expand(function (color) {
var self = Container.call(this);
self.color = color;
self.isSelected = false;
self.soundName = color + (color === 'red' ? 'Beat' : color === 'blue' ? 'Melody' : color === 'yellow' ? 'Bass' : color === 'green' ? 'Synth' : color === 'pink' ? 'Vocals' : 'Drums');
var highlight = self.addChild(LK.getAsset('selectionHighlight', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
}));
var characterBody = self.attachAsset(color + 'Character', {
anchorX: 0.5,
anchorY: 0.5
});
self.select = function () {
self.isSelected = true;
tween(highlight, {
alpha: 1
}, {
duration: 200,
easing: tween.easeOut
});
tween(characterBody, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200,
easing: tween.easeOut
});
};
self.deselect = function () {
self.isSelected = false;
tween(highlight, {
alpha: 0
}, {
duration: 200,
easing: tween.easeOut
});
tween(characterBody, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeOut
});
};
self.down = function (x, y, obj) {
if (gameState === 'selecting') {
selectCharacter(self);
}
};
return self;
});
var MixingStation = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('mixingArea', {
anchorX: 0.5,
anchorY: 0.5
});
self.character1 = null;
self.character2 = null;
self.isPlaying = false;
self.addCharacter = function (character) {
if (!self.character1) {
self.character1 = character;
character.x = -200;
character.y = 0;
} else if (!self.character2) {
self.character2 = character;
character.x = 200;
character.y = 0;
}
self.addChild(character);
};
self.playMix = function () {
if (self.character1 && self.character2 && !self.isPlaying) {
self.isPlaying = true;
LK.getSound(self.character1.soundName).play();
LK.setTimeout(function () {
LK.getSound(self.character2.soundName).play();
}, 500);
LK.setTimeout(function () {
LK.getSound('mixComplete').play();
self.completeMix();
}, 3000);
}
};
self.completeMix = function () {
self.isPlaying = false;
LK.setScore(LK.getScore() + 100);
scoreTxt.setText('Score: ' + LK.getScore());
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
LK.setTimeout(function () {
resetGame();
}, 2000);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
var gameState = 'selecting';
var selectedCount = 0;
var characters = [];
var characterColors = ['red', 'blue', 'yellow', 'green', 'pink', 'black'];
// UI Elements
var titleTxt = new Text2('Among Us Music Mix', {
size: 120,
fill: 0xFFFFFF
});
titleTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(titleTxt);
var instructionTxt = new Text2('Select two characters to create a mix!', {
size: 80,
fill: 0xCCCCCC
});
instructionTxt.anchor.set(0.5, 0);
instructionTxt.y = 150;
LK.gui.top.addChild(instructionTxt);
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
// Create mixing station
var mixingStation = game.addChild(new MixingStation());
mixingStation.x = 1024;
mixingStation.y = 1800;
// Create character selection grid
var startY = 800;
var spacing = 340;
for (var i = 0; i < characterColors.length; i++) {
var character = new AmongUsCharacter(characterColors[i]);
var row = Math.floor(i / 3);
var col = i % 3;
character.x = 400 + col * spacing;
character.y = startY + row * 400;
characters.push(character);
game.addChild(character);
}
function selectCharacter(character) {
if (character.isSelected) return;
character.select();
selectedCount++;
var characterCopy = new AmongUsCharacter(character.color);
mixingStation.addCharacter(characterCopy);
if (selectedCount === 2) {
gameState = 'mixing';
instructionTxt.setText('Creating your musical mix...');
LK.setTimeout(function () {
mixingStation.playMix();
}, 1000);
} else {
instructionTxt.setText('Select one more character!');
}
}
function resetGame() {
gameState = 'selecting';
selectedCount = 0;
instructionTxt.setText('Select two characters to create a mix!');
// Reset character selections
for (var i = 0; i < characters.length; i++) {
characters[i].deselect();
}
// Clear mixing station
if (mixingStation.character1) {
mixingStation.character1.destroy();
mixingStation.character1 = null;
}
if (mixingStation.character2) {
mixingStation.character2.destroy();
mixingStation.character2 = null;
}
}
game.update = function () {
// Visual feedback for mixing station when ready
if (mixingStation.character1 && mixingStation.character2 && !mixingStation.isPlaying) {
if (LK.ticks % 60 < 30) {
mixingStation.alpha = 0.8;
} else {
mixingStation.alpha = 1.0;
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,215 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var AmongUsCharacter = Container.expand(function (color) {
+ var self = Container.call(this);
+ self.color = color;
+ self.isSelected = false;
+ self.soundName = color + (color === 'red' ? 'Beat' : color === 'blue' ? 'Melody' : color === 'yellow' ? 'Bass' : color === 'green' ? 'Synth' : color === 'pink' ? 'Vocals' : 'Drums');
+ var highlight = self.addChild(LK.getAsset('selectionHighlight', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0
+ }));
+ var characterBody = self.attachAsset(color + 'Character', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.select = function () {
+ self.isSelected = true;
+ tween(highlight, {
+ alpha: 1
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ tween(characterBody, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ };
+ self.deselect = function () {
+ self.isSelected = false;
+ tween(highlight, {
+ alpha: 0
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ tween(characterBody, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ };
+ self.down = function (x, y, obj) {
+ if (gameState === 'selecting') {
+ selectCharacter(self);
+ }
+ };
+ return self;
+});
+var MixingStation = Container.expand(function () {
+ var self = Container.call(this);
+ var background = self.attachAsset('mixingArea', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.character1 = null;
+ self.character2 = null;
+ self.isPlaying = false;
+ self.addCharacter = function (character) {
+ if (!self.character1) {
+ self.character1 = character;
+ character.x = -200;
+ character.y = 0;
+ } else if (!self.character2) {
+ self.character2 = character;
+ character.x = 200;
+ character.y = 0;
+ }
+ self.addChild(character);
+ };
+ self.playMix = function () {
+ if (self.character1 && self.character2 && !self.isPlaying) {
+ self.isPlaying = true;
+ LK.getSound(self.character1.soundName).play();
+ LK.setTimeout(function () {
+ LK.getSound(self.character2.soundName).play();
+ }, 500);
+ LK.setTimeout(function () {
+ LK.getSound('mixComplete').play();
+ self.completeMix();
+ }, 3000);
+ }
+ };
+ self.completeMix = function () {
+ self.isPlaying = false;
+ LK.setScore(LK.getScore() + 100);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200
+ });
+ }
+ });
+ LK.setTimeout(function () {
+ resetGame();
+ }, 2000);
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a2e
+});
+
+/****
+* Game Code
+****/
+var gameState = 'selecting';
+var selectedCount = 0;
+var characters = [];
+var characterColors = ['red', 'blue', 'yellow', 'green', 'pink', 'black'];
+// UI Elements
+var titleTxt = new Text2('Among Us Music Mix', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+titleTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(titleTxt);
+var instructionTxt = new Text2('Select two characters to create a mix!', {
+ size: 80,
+ fill: 0xCCCCCC
+});
+instructionTxt.anchor.set(0.5, 0);
+instructionTxt.y = 150;
+LK.gui.top.addChild(instructionTxt);
+var scoreTxt = new Text2('Score: 0', {
+ size: 100,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(1, 0);
+LK.gui.topRight.addChild(scoreTxt);
+// Create mixing station
+var mixingStation = game.addChild(new MixingStation());
+mixingStation.x = 1024;
+mixingStation.y = 1800;
+// Create character selection grid
+var startY = 800;
+var spacing = 340;
+for (var i = 0; i < characterColors.length; i++) {
+ var character = new AmongUsCharacter(characterColors[i]);
+ var row = Math.floor(i / 3);
+ var col = i % 3;
+ character.x = 400 + col * spacing;
+ character.y = startY + row * 400;
+ characters.push(character);
+ game.addChild(character);
+}
+function selectCharacter(character) {
+ if (character.isSelected) return;
+ character.select();
+ selectedCount++;
+ var characterCopy = new AmongUsCharacter(character.color);
+ mixingStation.addCharacter(characterCopy);
+ if (selectedCount === 2) {
+ gameState = 'mixing';
+ instructionTxt.setText('Creating your musical mix...');
+ LK.setTimeout(function () {
+ mixingStation.playMix();
+ }, 1000);
+ } else {
+ instructionTxt.setText('Select one more character!');
+ }
+}
+function resetGame() {
+ gameState = 'selecting';
+ selectedCount = 0;
+ instructionTxt.setText('Select two characters to create a mix!');
+ // Reset character selections
+ for (var i = 0; i < characters.length; i++) {
+ characters[i].deselect();
+ }
+ // Clear mixing station
+ if (mixingStation.character1) {
+ mixingStation.character1.destroy();
+ mixingStation.character1 = null;
+ }
+ if (mixingStation.character2) {
+ mixingStation.character2.destroy();
+ mixingStation.character2 = null;
+ }
+}
+game.update = function () {
+ // Visual feedback for mixing station when ready
+ if (mixingStation.character1 && mixingStation.character2 && !mixingStation.isPlaying) {
+ if (LK.ticks % 60 < 30) {
+ mixingStation.alpha = 0.8;
+ } else {
+ mixingStation.alpha = 1.0;
+ }
+ }
+};
\ No newline at end of file