Code edit (1 edits merged)
Please save this source code
User prompt
DJ Dance Master
Initial prompt
bir dj masası var ekranın orta altında masanın sağında birden beşe kadar rakamlar yazılı butonlar var ortada yeşil bir ekran var. sounda ise mavi kırmızı ve yeşil renginde üç buton var. Bunlar dışında masada göstermelik düğmeler, tuşlar notalar var. Masa siyah etrafı beyaz şeritli eğlenceli bir masa kenarda kulaklık var. masanın karşısında dans eden yedi insan var. Masadaki ekranda sırasıyla rakam veya renk çıkıyor.Çıkan renge veya rakama uygun tuşa veya düğmeye basınca insanlar dans etmeye devam ediyor. Eğer hatalı basarsa insanlar dans etmeyi bırakıp kızıyor
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var DJButton = Container.expand(function (buttonType, value) {
var self = Container.call(this);
var buttonGraphics;
if (buttonType === 'number') {
buttonGraphics = self.attachAsset('numberButton', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (buttonType === 'blue') {
buttonGraphics = self.attachAsset('blueButton', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (buttonType === 'red') {
buttonGraphics = self.attachAsset('redButton', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (buttonType === 'green') {
buttonGraphics = self.attachAsset('greenButton', {
anchorX: 0.5,
anchorY: 0.5
});
}
var buttonText = new Text2(value.toString(), {
size: 40,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.buttonType = buttonType;
self.value = value;
self.isPressed = false;
self.press = function () {
if (!self.isPressed) {
self.isPressed = true;
tween(buttonGraphics, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
onFinish: function onFinish() {
tween(buttonGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
onFinish: function onFinish() {
self.isPressed = false;
}
});
}
});
}
};
self.down = function (x, y, obj) {
self.press();
game.handleButtonPress(self.buttonType, self.value);
};
return self;
});
var Dancer = Container.expand(function () {
var self = Container.call(this);
var dancerGraphics = self.attachAsset('dancer', {
anchorX: 0.5,
anchorY: 1
});
self.state = 'neutral'; // neutral, happy, angry
self.isAnimating = false;
self.setHappy = function () {
if (self.state !== 'happy') {
self.state = 'happy';
dancerGraphics.tint = 0xffaa00;
self.startDanceAnimation();
}
};
self.setAngry = function () {
if (self.state !== 'angry') {
self.state = 'angry';
dancerGraphics.tint = 0x990000;
self.stopDanceAnimation();
}
};
self.setNeutral = function () {
self.state = 'neutral';
dancerGraphics.tint = 0xff6600;
self.stopDanceAnimation();
};
self.startDanceAnimation = function () {
if (!self.isAnimating) {
self.isAnimating = true;
self.danceLoop();
}
};
self.stopDanceAnimation = function () {
self.isAnimating = false;
tween.stop(self, {
scaleX: true,
scaleY: true,
rotation: true
});
self.scaleX = 1;
self.scaleY = 1;
self.rotation = 0;
};
self.danceLoop = function () {
if (!self.isAnimating) return;
tween(self, {
scaleX: 1.1,
scaleY: 0.9,
rotation: 0.1
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (!self.isAnimating) return;
tween(self, {
scaleX: 0.9,
scaleY: 1.1,
rotation: -0.1
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (!self.isAnimating) return;
tween(self, {
scaleX: 1,
scaleY: 1,
rotation: 0
}, {
duration: 200,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.danceLoop();
}
});
}
});
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x220044
});
/****
* Game Code
****/
// Sounds
// Musical note decoration
// Dancers
// Buttons
// DJ Console and decorative elements
// Game variables
var dancers = [];
var djButtons = [];
var currentPrompt = null;
var promptSequence = [];
var gameSpeed = 2000; // ms between prompts
var consecutiveCorrect = 0;
var maxMistakes = 5;
var currentMistakes = 0;
var isGameActive = true;
// UI elements
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var mistakesText = new Text2('Mistakes: 0/5', {
size: 40,
fill: 0xFF4444
});
mistakesText.anchor.set(1, 0);
mistakesText.x = LK.gui.topRight.x - 20;
mistakesText.y = 20;
LK.gui.topRight.addChild(mistakesText);
// Create DJ table
var djTable = game.addChild(LK.getAsset('djTable', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: 2732
}));
// Add white stripes to DJ table
for (var i = 0; i < 3; i++) {
var stripe = djTable.addChild(LK.getAsset('whiteStripe', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -300 + i * 100
}));
}
// Create green screen
var greenScreen = djTable.addChild(LK.getAsset('greenScreen', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -200
}));
var promptText = new Text2('', {
size: 80,
fill: 0x000000
});
promptText.anchor.set(0.5, 0.5);
greenScreen.addChild(promptText);
// Add decorative knobs
for (var i = 0; i < 6; i++) {
var knob = djTable.addChild(LK.getAsset('knob', {
anchorX: 0.5,
anchorY: 0.5,
x: -600 + i * 120,
y: -300
}));
}
// Add piano keys
for (var i = 0; i < 12; i++) {
var key = djTable.addChild(LK.getAsset('key', {
anchorX: 0.5,
anchorY: 0.5,
x: -300 + i * 35,
y: -100
}));
}
// Add headphones
var headphones = djTable.addChild(LK.getAsset('headphones', {
anchorX: 0.5,
anchorY: 0.5,
x: -750,
y: -200
}));
// Add musical notes decoration
for (var i = 0; i < 8; i++) {
var note = djTable.addChild(LK.getAsset('musicalNote', {
anchorX: 0.5,
anchorY: 0.5,
x: -800 + i * 80,
y: -50
}));
}
// Create numbered buttons (1-5)
for (var i = 1; i <= 5; i++) {
var numberButton = new DJButton('number', i);
numberButton.x = djTable.x + 400 + (i - 1) * 100;
numberButton.y = djTable.y - 150;
game.addChild(numberButton);
djButtons.push(numberButton);
}
// Create colored buttons
var colorButtons = [{
type: 'blue',
color: 'B'
}, {
type: 'red',
color: 'R'
}, {
type: 'green',
color: 'G'
}];
for (var i = 0; i < colorButtons.length; i++) {
var colorButton = new DJButton(colorButtons[i].type, colorButtons[i].color);
colorButton.x = djTable.x - 400 + i * 100;
colorButton.y = djTable.y - 150;
game.addChild(colorButton);
djButtons.push(colorButton);
}
// Create dancers
for (var i = 0; i < 7; i++) {
var dancer = new Dancer();
dancer.x = 200 + i * 240;
dancer.y = 800;
game.addChild(dancer);
dancers.push(dancer);
}
// Generate random prompt
function generatePrompt() {
var prompts = ['1', '2', '3', '4', '5', 'B', 'R', 'G'];
return prompts[Math.floor(Math.random() * prompts.length)];
}
// Show new prompt
function showPrompt() {
if (!isGameActive) return;
currentPrompt = generatePrompt();
promptText.setText(currentPrompt);
// Flash screen effect
tween(greenScreen, {
tint: 0xffffff
}, {
duration: 100,
onFinish: function onFinish() {
tween(greenScreen, {
tint: 0xffffff
}, {
duration: 100,
onFinish: function onFinish() {
greenScreen.tint = 0xffffff;
}
});
}
});
}
// Handle button press
game.handleButtonPress = function (buttonType, value) {
if (!isGameActive || !currentPrompt) return;
var isCorrect = false;
if (buttonType === 'number' && currentPrompt === value.toString()) {
isCorrect = true;
} else if (buttonType === 'blue' && currentPrompt === 'B') {
isCorrect = true;
} else if (buttonType === 'red' && currentPrompt === 'R') {
isCorrect = true;
} else if (buttonType === 'green' && currentPrompt === 'G') {
isCorrect = true;
}
if (isCorrect) {
LK.getSound('correctSound').play();
LK.setScore(LK.getScore() + 10);
consecutiveCorrect++;
// Make dancers happy
for (var i = 0; i < dancers.length; i++) {
dancers[i].setHappy();
}
// Increase speed every 5 correct answers
if (consecutiveCorrect % 5 === 0) {
gameSpeed = Math.max(800, gameSpeed - 200);
}
} else {
LK.getSound('wrongSound').play();
currentMistakes++;
consecutiveCorrect = 0;
// Make dancers angry
for (var i = 0; i < dancers.length; i++) {
dancers[i].setAngry();
}
// Check game over
if (currentMistakes >= maxMistakes) {
isGameActive = false;
LK.showGameOver();
return;
}
}
// Update UI
scoreText.setText('Score: ' + LK.getScore());
mistakesText.setText('Mistakes: ' + currentMistakes + '/' + maxMistakes);
// Clear current prompt
currentPrompt = null;
promptText.setText('');
// Reset dancers to neutral after a delay
LK.setTimeout(function () {
if (isGameActive) {
for (var i = 0; i < dancers.length; i++) {
dancers[i].setNeutral();
}
}
}, 1000);
};
// Game timer for prompts
var promptTimer = LK.setInterval(function () {
showPrompt();
}, gameSpeed);
// Update game speed
var speedTimer = LK.setInterval(function () {
if (isGameActive && gameSpeed > 800) {
LK.clearInterval(promptTimer);
promptTimer = LK.setInterval(function () {
showPrompt();
}, gameSpeed);
}
}, 1000);
// Start the game
LK.playMusic('gameMusic');
LK.setTimeout(function () {
showPrompt();
}, 1000);
game.update = function () {
// Game logic handled by timers and events
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,392 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var DJButton = Container.expand(function (buttonType, value) {
+ var self = Container.call(this);
+ var buttonGraphics;
+ if (buttonType === 'number') {
+ buttonGraphics = self.attachAsset('numberButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ } else if (buttonType === 'blue') {
+ buttonGraphics = self.attachAsset('blueButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ } else if (buttonType === 'red') {
+ buttonGraphics = self.attachAsset('redButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ } else if (buttonType === 'green') {
+ buttonGraphics = self.attachAsset('greenButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ }
+ var buttonText = new Text2(value.toString(), {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.buttonType = buttonType;
+ self.value = value;
+ self.isPressed = false;
+ self.press = function () {
+ if (!self.isPressed) {
+ self.isPressed = true;
+ tween(buttonGraphics, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(buttonGraphics, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ self.isPressed = false;
+ }
+ });
+ }
+ });
+ }
+ };
+ self.down = function (x, y, obj) {
+ self.press();
+ game.handleButtonPress(self.buttonType, self.value);
+ };
+ return self;
+});
+var Dancer = Container.expand(function () {
+ var self = Container.call(this);
+ var dancerGraphics = self.attachAsset('dancer', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.state = 'neutral'; // neutral, happy, angry
+ self.isAnimating = false;
+ self.setHappy = function () {
+ if (self.state !== 'happy') {
+ self.state = 'happy';
+ dancerGraphics.tint = 0xffaa00;
+ self.startDanceAnimation();
+ }
+ };
+ self.setAngry = function () {
+ if (self.state !== 'angry') {
+ self.state = 'angry';
+ dancerGraphics.tint = 0x990000;
+ self.stopDanceAnimation();
+ }
+ };
+ self.setNeutral = function () {
+ self.state = 'neutral';
+ dancerGraphics.tint = 0xff6600;
+ self.stopDanceAnimation();
+ };
+ self.startDanceAnimation = function () {
+ if (!self.isAnimating) {
+ self.isAnimating = true;
+ self.danceLoop();
+ }
+ };
+ self.stopDanceAnimation = function () {
+ self.isAnimating = false;
+ tween.stop(self, {
+ scaleX: true,
+ scaleY: true,
+ rotation: true
+ });
+ self.scaleX = 1;
+ self.scaleY = 1;
+ self.rotation = 0;
+ };
+ self.danceLoop = function () {
+ if (!self.isAnimating) return;
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 0.9,
+ rotation: 0.1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ if (!self.isAnimating) return;
+ tween(self, {
+ scaleX: 0.9,
+ scaleY: 1.1,
+ rotation: -0.1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ if (!self.isAnimating) return;
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1,
+ rotation: 0
+ }, {
+ duration: 200,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ self.danceLoop();
+ }
+ });
+ }
+ });
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x220044
+});
+
+/****
+* Game Code
+****/
+// Sounds
+// Musical note decoration
+// Dancers
+// Buttons
+// DJ Console and decorative elements
+// Game variables
+var dancers = [];
+var djButtons = [];
+var currentPrompt = null;
+var promptSequence = [];
+var gameSpeed = 2000; // ms between prompts
+var consecutiveCorrect = 0;
+var maxMistakes = 5;
+var currentMistakes = 0;
+var isGameActive = true;
+// UI elements
+var scoreText = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreText);
+var mistakesText = new Text2('Mistakes: 0/5', {
+ size: 40,
+ fill: 0xFF4444
+});
+mistakesText.anchor.set(1, 0);
+mistakesText.x = LK.gui.topRight.x - 20;
+mistakesText.y = 20;
+LK.gui.topRight.addChild(mistakesText);
+// Create DJ table
+var djTable = game.addChild(LK.getAsset('djTable', {
+ anchorX: 0.5,
+ anchorY: 1,
+ x: 1024,
+ y: 2732
+}));
+// Add white stripes to DJ table
+for (var i = 0; i < 3; i++) {
+ var stripe = djTable.addChild(LK.getAsset('whiteStripe', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: -300 + i * 100
+ }));
+}
+// Create green screen
+var greenScreen = djTable.addChild(LK.getAsset('greenScreen', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: -200
+}));
+var promptText = new Text2('', {
+ size: 80,
+ fill: 0x000000
+});
+promptText.anchor.set(0.5, 0.5);
+greenScreen.addChild(promptText);
+// Add decorative knobs
+for (var i = 0; i < 6; i++) {
+ var knob = djTable.addChild(LK.getAsset('knob', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -600 + i * 120,
+ y: -300
+ }));
+}
+// Add piano keys
+for (var i = 0; i < 12; i++) {
+ var key = djTable.addChild(LK.getAsset('key', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -300 + i * 35,
+ y: -100
+ }));
+}
+// Add headphones
+var headphones = djTable.addChild(LK.getAsset('headphones', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -750,
+ y: -200
+}));
+// Add musical notes decoration
+for (var i = 0; i < 8; i++) {
+ var note = djTable.addChild(LK.getAsset('musicalNote', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -800 + i * 80,
+ y: -50
+ }));
+}
+// Create numbered buttons (1-5)
+for (var i = 1; i <= 5; i++) {
+ var numberButton = new DJButton('number', i);
+ numberButton.x = djTable.x + 400 + (i - 1) * 100;
+ numberButton.y = djTable.y - 150;
+ game.addChild(numberButton);
+ djButtons.push(numberButton);
+}
+// Create colored buttons
+var colorButtons = [{
+ type: 'blue',
+ color: 'B'
+}, {
+ type: 'red',
+ color: 'R'
+}, {
+ type: 'green',
+ color: 'G'
+}];
+for (var i = 0; i < colorButtons.length; i++) {
+ var colorButton = new DJButton(colorButtons[i].type, colorButtons[i].color);
+ colorButton.x = djTable.x - 400 + i * 100;
+ colorButton.y = djTable.y - 150;
+ game.addChild(colorButton);
+ djButtons.push(colorButton);
+}
+// Create dancers
+for (var i = 0; i < 7; i++) {
+ var dancer = new Dancer();
+ dancer.x = 200 + i * 240;
+ dancer.y = 800;
+ game.addChild(dancer);
+ dancers.push(dancer);
+}
+// Generate random prompt
+function generatePrompt() {
+ var prompts = ['1', '2', '3', '4', '5', 'B', 'R', 'G'];
+ return prompts[Math.floor(Math.random() * prompts.length)];
+}
+// Show new prompt
+function showPrompt() {
+ if (!isGameActive) return;
+ currentPrompt = generatePrompt();
+ promptText.setText(currentPrompt);
+ // Flash screen effect
+ tween(greenScreen, {
+ tint: 0xffffff
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(greenScreen, {
+ tint: 0xffffff
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ greenScreen.tint = 0xffffff;
+ }
+ });
+ }
+ });
+}
+// Handle button press
+game.handleButtonPress = function (buttonType, value) {
+ if (!isGameActive || !currentPrompt) return;
+ var isCorrect = false;
+ if (buttonType === 'number' && currentPrompt === value.toString()) {
+ isCorrect = true;
+ } else if (buttonType === 'blue' && currentPrompt === 'B') {
+ isCorrect = true;
+ } else if (buttonType === 'red' && currentPrompt === 'R') {
+ isCorrect = true;
+ } else if (buttonType === 'green' && currentPrompt === 'G') {
+ isCorrect = true;
+ }
+ if (isCorrect) {
+ LK.getSound('correctSound').play();
+ LK.setScore(LK.getScore() + 10);
+ consecutiveCorrect++;
+ // Make dancers happy
+ for (var i = 0; i < dancers.length; i++) {
+ dancers[i].setHappy();
+ }
+ // Increase speed every 5 correct answers
+ if (consecutiveCorrect % 5 === 0) {
+ gameSpeed = Math.max(800, gameSpeed - 200);
+ }
+ } else {
+ LK.getSound('wrongSound').play();
+ currentMistakes++;
+ consecutiveCorrect = 0;
+ // Make dancers angry
+ for (var i = 0; i < dancers.length; i++) {
+ dancers[i].setAngry();
+ }
+ // Check game over
+ if (currentMistakes >= maxMistakes) {
+ isGameActive = false;
+ LK.showGameOver();
+ return;
+ }
+ }
+ // Update UI
+ scoreText.setText('Score: ' + LK.getScore());
+ mistakesText.setText('Mistakes: ' + currentMistakes + '/' + maxMistakes);
+ // Clear current prompt
+ currentPrompt = null;
+ promptText.setText('');
+ // Reset dancers to neutral after a delay
+ LK.setTimeout(function () {
+ if (isGameActive) {
+ for (var i = 0; i < dancers.length; i++) {
+ dancers[i].setNeutral();
+ }
+ }
+ }, 1000);
+};
+// Game timer for prompts
+var promptTimer = LK.setInterval(function () {
+ showPrompt();
+}, gameSpeed);
+// Update game speed
+var speedTimer = LK.setInterval(function () {
+ if (isGameActive && gameSpeed > 800) {
+ LK.clearInterval(promptTimer);
+ promptTimer = LK.setInterval(function () {
+ showPrompt();
+ }, gameSpeed);
+ }
+}, 1000);
+// Start the game
+LK.playMusic('gameMusic');
+LK.setTimeout(function () {
+ showPrompt();
+}, 1000);
+game.update = function () {
+ // Game logic handled by timers and events
+};
\ No newline at end of file
gri mor bir masa üzerinde tuşlar var dj stilinde. In-Game asset. 2d. High contrast. No shadows
etrafı sarı işleme çerçeveli beyaz. In-Game asset. 2d. High contrast. No shadows
dansöz kıyafetli ayakta duran elleri havada dans eden bir kedi. In-Game asset. 2d. High contrast. No shadows
bomb. In-Game asset. 2d. High contrast. No shadows