User prompt
her iki tarafada kaydırdığım zaman kırmızı oluyor ve kişinin hakkında bilgi vermiyor düzelt
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 99
User prompt
eğer ki birini sağ kaydırırsak kişi hakkında daha fazla bilgiye ulaşabilelim ve kişi sınırısını dahada artırt daha fazla kişi olsun
User prompt
yazılar okunmuyor biraz büyült ve fotoğraflar ekle
Code edit (1 edits merged)
Please save this source code
User prompt
Swipe Right Dating Game
Initial prompt
Tinder uygulamasına benzer bir uygulama yap ama bu oyunun amacı olsun tinderdan güzel bir kız bulmaya çalışalım
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Profile = Container.expand(function (attractiveness, name, age) {
var self = Container.call(this);
self.attractiveness = attractiveness; // 1=unattractive, 2=average, 3=attractive
self.name = name;
self.age = age;
self.swiped = false;
// Create card background
var cardBg = self.attachAsset('profileCard', {
anchorX: 0.5,
anchorY: 0.5
});
// Create photo based on attractiveness
var photo;
if (attractiveness === 3) {
photo = self.attachAsset('attractivePhoto', {
anchorX: 0.5,
anchorY: 0.5,
y: -100
});
} else if (attractiveness === 2) {
photo = self.attachAsset('averagePhoto', {
anchorX: 0.5,
anchorY: 0.5,
y: -100
});
} else {
photo = self.attachAsset('unattractive', {
anchorX: 0.5,
anchorY: 0.5,
y: -100
});
}
// Add name text
self.nameText = new Text2(name + ', ' + age, {
size: 40,
fill: 0x000000
});
self.nameText.anchor.set(0.5, 0.5);
self.nameText.x = 0;
self.nameText.y = 150;
self.addChild(self.nameText);
self.swipeRight = function () {
if (self.swiped) return;
self.swiped = true;
tween(self, {
x: 2048 + 400,
rotation: 0.3
}, {
duration: 300,
onFinish: function onFinish() {
if (self.attractiveness >= 2) {
// Good swipe
LK.setScore(LK.getScore() + self.attractiveness * 10);
LK.getSound('match').play();
LK.effects.flashScreen(0x00ff00, 200);
} else {
// Bad swipe
wrongSwipes++;
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 200);
}
updateScore();
spawnNewProfile();
self.destroy();
}
});
};
self.swipeLeft = function () {
if (self.swiped) return;
self.swiped = true;
tween(self, {
x: -400,
rotation: -0.3
}, {
duration: 300,
onFinish: function onFinish() {
if (self.attractiveness === 3) {
// Missed attractive person
wrongSwipes++;
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 200);
} else {
// Good rejection
LK.setScore(LK.getScore() + 5);
LK.getSound('reject').play();
}
updateScore();
spawnNewProfile();
self.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xf0f0f0
});
/****
* Game Code
****/
var currentProfile = null;
var wrongSwipes = 0;
var maxWrongSwipes = 5;
var profileNames = ['Emma', 'Sophia', 'Isabella', 'Mia', 'Charlotte', 'Amelia', 'Harper', 'Aria', 'Luna', 'Grace'];
var gameSpeed = 1;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0x333333
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var wrongSwipesTxt = new Text2('Wrong: 0/' + maxWrongSwipes, {
size: 40,
fill: 0xFF0000
});
wrongSwipesTxt.anchor.set(1, 0);
wrongSwipesTxt.x = -20;
wrongSwipesTxt.y = 20;
LK.gui.topRight.addChild(wrongSwipesTxt);
// Instructions
var instructionsTxt = new Text2('Swipe Right: Like | Swipe Left: Pass', {
size: 50,
fill: 0x666666
});
instructionsTxt.anchor.set(0.5, 1);
instructionsTxt.y = -50;
LK.gui.bottom.addChild(instructionsTxt);
// Heart and Cross icons
var heartIcon = game.addChild(LK.getAsset('heartIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 - 200,
y: 2732 / 2,
alpha: 0.3
}));
var crossIcon = game.addChild(LK.getAsset('crossIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 2732 / 2,
alpha: 0.3
}));
function updateScore() {
scoreTxt.setText('Score: ' + LK.getScore());
wrongSwipesTxt.setText('Wrong: ' + wrongSwipes + '/' + maxWrongSwipes);
if (wrongSwipes >= maxWrongSwipes) {
LK.showGameOver();
return;
}
// Increase game speed based on score
gameSpeed = 1 + Math.floor(LK.getScore() / 100) * 0.2;
// Win condition
if (LK.getScore() >= 500) {
LK.showYouWin();
}
}
function getRandomName() {
return profileNames[Math.floor(Math.random() * profileNames.length)];
}
function getRandomAge() {
return Math.floor(Math.random() * 15) + 20; // Age 20-34
}
function getRandomAttractiveness() {
var rand = Math.random();
if (rand < 0.3) return 1; // 30% unattractive
if (rand < 0.7) return 2; // 40% average
return 3; // 30% attractive
}
function spawnNewProfile() {
if (currentProfile) {
currentProfile.destroy();
}
var attractiveness = getRandomAttractiveness();
var name = getRandomName();
var age = getRandomAge();
currentProfile = new Profile(attractiveness, name, age);
currentProfile.x = 2048 / 2;
currentProfile.y = 2732 / 2;
currentProfile.scaleX = 0.8;
currentProfile.scaleY = 0.8;
game.addChild(currentProfile);
// Entrance animation
currentProfile.alpha = 0;
currentProfile.scaleX = 0.5;
currentProfile.scaleY = 0.5;
tween(currentProfile, {
alpha: 1,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 200,
easing: tween.easeOut
});
}
var dragStartX = 0;
var dragStartY = 0;
var isDragging = false;
var dragThreshold = 100;
game.down = function (x, y, obj) {
if (currentProfile && !currentProfile.swiped) {
dragStartX = x;
dragStartY = y;
isDragging = true;
}
};
game.move = function (x, y, obj) {
if (isDragging && currentProfile && !currentProfile.swiped) {
var deltaX = x - dragStartX;
var deltaY = y - dragStartY;
currentProfile.x = 2048 / 2 + deltaX * 0.5;
currentProfile.y = 2732 / 2 + deltaY * 0.2;
currentProfile.rotation = deltaX * 0.0005;
// Visual feedback
if (Math.abs(deltaX) > dragThreshold) {
if (deltaX > 0) {
heartIcon.alpha = Math.min(0.8, 0.3 + Math.abs(deltaX) / 300);
crossIcon.alpha = 0.3;
} else {
crossIcon.alpha = Math.min(0.8, 0.3 + Math.abs(deltaX) / 300);
heartIcon.alpha = 0.3;
}
} else {
heartIcon.alpha = 0.3;
crossIcon.alpha = 0.3;
}
}
};
game.up = function (x, y, obj) {
if (isDragging && currentProfile && !currentProfile.swiped) {
var deltaX = x - dragStartX;
if (Math.abs(deltaX) > dragThreshold) {
if (deltaX > 0) {
currentProfile.swipeRight();
} else {
currentProfile.swipeLeft();
}
} else {
// Snap back to center
tween(currentProfile, {
x: 2048 / 2,
y: 2732 / 2,
rotation: 0
}, {
duration: 200,
easing: tween.easeOut
});
}
isDragging = false;
heartIcon.alpha = 0.3;
crossIcon.alpha = 0.3;
}
};
// Initialize first profile
spawnNewProfile();
updateScore(); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,269 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Profile = Container.expand(function (attractiveness, name, age) {
+ var self = Container.call(this);
+ self.attractiveness = attractiveness; // 1=unattractive, 2=average, 3=attractive
+ self.name = name;
+ self.age = age;
+ self.swiped = false;
+ // Create card background
+ var cardBg = self.attachAsset('profileCard', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Create photo based on attractiveness
+ var photo;
+ if (attractiveness === 3) {
+ photo = self.attachAsset('attractivePhoto', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -100
+ });
+ } else if (attractiveness === 2) {
+ photo = self.attachAsset('averagePhoto', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -100
+ });
+ } else {
+ photo = self.attachAsset('unattractive', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -100
+ });
+ }
+ // Add name text
+ self.nameText = new Text2(name + ', ' + age, {
+ size: 40,
+ fill: 0x000000
+ });
+ self.nameText.anchor.set(0.5, 0.5);
+ self.nameText.x = 0;
+ self.nameText.y = 150;
+ self.addChild(self.nameText);
+ self.swipeRight = function () {
+ if (self.swiped) return;
+ self.swiped = true;
+ tween(self, {
+ x: 2048 + 400,
+ rotation: 0.3
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ if (self.attractiveness >= 2) {
+ // Good swipe
+ LK.setScore(LK.getScore() + self.attractiveness * 10);
+ LK.getSound('match').play();
+ LK.effects.flashScreen(0x00ff00, 200);
+ } else {
+ // Bad swipe
+ wrongSwipes++;
+ LK.getSound('wrong').play();
+ LK.effects.flashScreen(0xff0000, 200);
+ }
+ updateScore();
+ spawnNewProfile();
+ self.destroy();
+ }
+ });
+ };
+ self.swipeLeft = function () {
+ if (self.swiped) return;
+ self.swiped = true;
+ tween(self, {
+ x: -400,
+ rotation: -0.3
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ if (self.attractiveness === 3) {
+ // Missed attractive person
+ wrongSwipes++;
+ LK.getSound('wrong').play();
+ LK.effects.flashScreen(0xff0000, 200);
+ } else {
+ // Good rejection
+ LK.setScore(LK.getScore() + 5);
+ LK.getSound('reject').play();
+ }
+ updateScore();
+ spawnNewProfile();
+ self.destroy();
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xf0f0f0
+});
+
+/****
+* Game Code
+****/
+var currentProfile = null;
+var wrongSwipes = 0;
+var maxWrongSwipes = 5;
+var profileNames = ['Emma', 'Sophia', 'Isabella', 'Mia', 'Charlotte', 'Amelia', 'Harper', 'Aria', 'Luna', 'Grace'];
+var gameSpeed = 1;
+// UI Elements
+var scoreTxt = new Text2('Score: 0', {
+ size: 60,
+ fill: 0x333333
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+var wrongSwipesTxt = new Text2('Wrong: 0/' + maxWrongSwipes, {
+ size: 40,
+ fill: 0xFF0000
+});
+wrongSwipesTxt.anchor.set(1, 0);
+wrongSwipesTxt.x = -20;
+wrongSwipesTxt.y = 20;
+LK.gui.topRight.addChild(wrongSwipesTxt);
+// Instructions
+var instructionsTxt = new Text2('Swipe Right: Like | Swipe Left: Pass', {
+ size: 50,
+ fill: 0x666666
+});
+instructionsTxt.anchor.set(0.5, 1);
+instructionsTxt.y = -50;
+LK.gui.bottom.addChild(instructionsTxt);
+// Heart and Cross icons
+var heartIcon = game.addChild(LK.getAsset('heartIcon', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 - 200,
+ y: 2732 / 2,
+ alpha: 0.3
+}));
+var crossIcon = game.addChild(LK.getAsset('crossIcon', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 200,
+ y: 2732 / 2,
+ alpha: 0.3
+}));
+function updateScore() {
+ scoreTxt.setText('Score: ' + LK.getScore());
+ wrongSwipesTxt.setText('Wrong: ' + wrongSwipes + '/' + maxWrongSwipes);
+ if (wrongSwipes >= maxWrongSwipes) {
+ LK.showGameOver();
+ return;
+ }
+ // Increase game speed based on score
+ gameSpeed = 1 + Math.floor(LK.getScore() / 100) * 0.2;
+ // Win condition
+ if (LK.getScore() >= 500) {
+ LK.showYouWin();
+ }
+}
+function getRandomName() {
+ return profileNames[Math.floor(Math.random() * profileNames.length)];
+}
+function getRandomAge() {
+ return Math.floor(Math.random() * 15) + 20; // Age 20-34
+}
+function getRandomAttractiveness() {
+ var rand = Math.random();
+ if (rand < 0.3) return 1; // 30% unattractive
+ if (rand < 0.7) return 2; // 40% average
+ return 3; // 30% attractive
+}
+function spawnNewProfile() {
+ if (currentProfile) {
+ currentProfile.destroy();
+ }
+ var attractiveness = getRandomAttractiveness();
+ var name = getRandomName();
+ var age = getRandomAge();
+ currentProfile = new Profile(attractiveness, name, age);
+ currentProfile.x = 2048 / 2;
+ currentProfile.y = 2732 / 2;
+ currentProfile.scaleX = 0.8;
+ currentProfile.scaleY = 0.8;
+ game.addChild(currentProfile);
+ // Entrance animation
+ currentProfile.alpha = 0;
+ currentProfile.scaleX = 0.5;
+ currentProfile.scaleY = 0.5;
+ tween(currentProfile, {
+ alpha: 1,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+}
+var dragStartX = 0;
+var dragStartY = 0;
+var isDragging = false;
+var dragThreshold = 100;
+game.down = function (x, y, obj) {
+ if (currentProfile && !currentProfile.swiped) {
+ dragStartX = x;
+ dragStartY = y;
+ isDragging = true;
+ }
+};
+game.move = function (x, y, obj) {
+ if (isDragging && currentProfile && !currentProfile.swiped) {
+ var deltaX = x - dragStartX;
+ var deltaY = y - dragStartY;
+ currentProfile.x = 2048 / 2 + deltaX * 0.5;
+ currentProfile.y = 2732 / 2 + deltaY * 0.2;
+ currentProfile.rotation = deltaX * 0.0005;
+ // Visual feedback
+ if (Math.abs(deltaX) > dragThreshold) {
+ if (deltaX > 0) {
+ heartIcon.alpha = Math.min(0.8, 0.3 + Math.abs(deltaX) / 300);
+ crossIcon.alpha = 0.3;
+ } else {
+ crossIcon.alpha = Math.min(0.8, 0.3 + Math.abs(deltaX) / 300);
+ heartIcon.alpha = 0.3;
+ }
+ } else {
+ heartIcon.alpha = 0.3;
+ crossIcon.alpha = 0.3;
+ }
+ }
+};
+game.up = function (x, y, obj) {
+ if (isDragging && currentProfile && !currentProfile.swiped) {
+ var deltaX = x - dragStartX;
+ if (Math.abs(deltaX) > dragThreshold) {
+ if (deltaX > 0) {
+ currentProfile.swipeRight();
+ } else {
+ currentProfile.swipeLeft();
+ }
+ } else {
+ // Snap back to center
+ tween(currentProfile, {
+ x: 2048 / 2,
+ y: 2732 / 2,
+ rotation: 0
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ }
+ isDragging = false;
+ heartIcon.alpha = 0.3;
+ crossIcon.alpha = 0.3;
+ }
+};
+// Initialize first profile
+spawnNewProfile();
+updateScore();
\ No newline at end of file