/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Profile = Container.expand(function (attractiveness, name, age, bio, interests) {
var self = Container.call(this);
self.attractiveness = attractiveness; // 1=unattractive, 2=average, 3=attractive
self.name = name;
self.age = age;
self.bio = bio || "No bio available";
self.interests = interests || [];
self.swiped = false;
self.profileId = Math.random().toString(36).substr(2, 9);
// 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: 80,
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 - it's a match!
LK.setScore(LK.getScore() + self.attractiveness * 10);
LK.getSound('match').play();
LK.effects.flashScreen(0x00ff00, 200);
// Store matched profile for detailed view
var profileData = {
name: self.name,
age: self.age,
bio: self.bio,
interests: self.interests,
attractiveness: self.attractiveness,
profileId: self.profileId
};
matchedProfiles.push(profileData);
showProfileDetails(profileData);
} else {
// Bad swipe - swiped right on unattractive person
wrongSwipes++;
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 200);
}
updateScore();
LK.setTimeout(function () {
spawnNewProfile();
}, 2000);
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 - this is wrong
wrongSwipes++;
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 200);
} else {
// Good rejection - correct swipe left
LK.setScore(LK.getScore() + 5);
LK.getSound('reject').play();
LK.effects.flashScreen(0x00ff00, 200);
}
updateScore();
LK.setTimeout(function () {
spawnNewProfile();
}, 1000);
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', 'Olivia', 'Ava', 'Chloe', 'Madison', 'Ella', 'Scarlett', 'Victoria', 'Aria', 'Zoe', 'Lily', 'Natalie', 'Leah', 'Hannah', 'Addison', 'Maya', 'Samantha', 'Audrey', 'Brooklyn', 'Claire', 'Bella'];
var gameSpeed = 1;
var viewedProfiles = 0;
var maxProfiles = 50;
var matchedProfiles = [];
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0x333333
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var wrongSwipesTxt = new Text2('Wrong: 0/' + maxWrongSwipes, {
size: 80,
fill: 0xFF0000
});
wrongSwipesTxt.anchor.set(1, 0);
wrongSwipesTxt.x = -20;
wrongSwipesTxt.y = 20;
LK.gui.topRight.addChild(wrongSwipesTxt);
var profileCountTxt = new Text2('Profiles: 0/' + maxProfiles, {
size: 80,
fill: 0x333333
});
profileCountTxt.anchor.set(0, 0);
profileCountTxt.x = 20;
profileCountTxt.y = 20;
LK.gui.topLeft.addChild(profileCountTxt);
var matchesTxt = new Text2('Matches: 0', {
size: 50,
fill: 0x00AA00
});
matchesTxt.anchor.set(1, 0);
matchesTxt.x = -20;
matchesTxt.y = 80;
LK.gui.topRight.addChild(matchesTxt);
// Instructions
var instructionsTxt = new Text2('Swipe Right: Like | Swipe Left: Pass', {
size: 70,
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);
profileCountTxt.setText('Profiles: ' + viewedProfiles + '/' + maxProfiles);
matchesTxt.setText('Matches: ' + matchedProfiles.length);
if (wrongSwipes >= maxWrongSwipes) {
LK.showGameOver();
return;
}
if (viewedProfiles >= maxProfiles) {
LK.showYouWin();
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 getRandomBio() {
var bios = ["Love traveling and trying new foods 🌍", "Fitness enthusiast and dog lover 🐕", "Artist by day, Netflix binger by night 🎨", "Adventurous spirit seeking new experiences ⛰️", "Coffee addict and bookworm 📚☕", "Yoga instructor and nature lover 🧘♀️", "Photographer capturing life's moments 📸", "Foodie exploring the city's best restaurants 🍴", "Music lover and concert goer 🎵", "Beach lover and sunset chaser 🌅"];
return bios[Math.floor(Math.random() * bios.length)];
}
function getRandomInterests() {
var allInterests = ["Travel", "Fitness", "Art", "Music", "Food", "Photography", "Reading", "Yoga", "Dancing", "Gaming", "Movies", "Nature", "Cooking", "Sports"];
var interests = [];
var numInterests = Math.floor(Math.random() * 4) + 2; // 2-5 interests
for (var i = 0; i < numInterests; i++) {
var randomInterest = allInterests[Math.floor(Math.random() * allInterests.length)];
if (interests.indexOf(randomInterest) === -1) {
interests.push(randomInterest);
}
}
return interests;
}
function showProfileDetails(profile) {
// Create detailed info display
var detailsContainer = new Container();
detailsContainer.x = 2048 / 2;
detailsContainer.y = 2732 / 2;
game.addChild(detailsContainer);
var detailsBg = detailsContainer.attachAsset('profileCard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
});
var detailsText = new Text2("It's a Match! 💕\n\n" + profile.name + ", " + profile.age + "\n\n" + profile.bio + "\n\nInterests: " + profile.interests.join(", "), {
size: 80,
fill: 0x000000,
align: 'center',
wordWrap: true,
wordWrapWidth: 400
});
detailsText.anchor.set(0.5, 0.5);
detailsContainer.addChild(detailsText);
// Auto-hide after 2 seconds
LK.setTimeout(function () {
detailsContainer.destroy();
}, 2000);
}
function spawnNewProfile() {
if (currentProfile) {
currentProfile.destroy();
}
if (viewedProfiles >= maxProfiles) {
return;
}
var attractiveness = getRandomAttractiveness();
var name = getRandomName();
var age = getRandomAge();
var bio = getRandomBio();
var interests = getRandomInterests();
currentProfile = new Profile(attractiveness, name, age, bio, interests);
currentProfile.x = 2048 / 2;
currentProfile.y = 2732 / 2;
currentProfile.scaleX = 0.8;
currentProfile.scaleY = 0.8;
game.addChild(currentProfile);
viewedProfiles++;
updateScore();
// 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(); /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Profile = Container.expand(function (attractiveness, name, age, bio, interests) {
var self = Container.call(this);
self.attractiveness = attractiveness; // 1=unattractive, 2=average, 3=attractive
self.name = name;
self.age = age;
self.bio = bio || "No bio available";
self.interests = interests || [];
self.swiped = false;
self.profileId = Math.random().toString(36).substr(2, 9);
// 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: 80,
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 - it's a match!
LK.setScore(LK.getScore() + self.attractiveness * 10);
LK.getSound('match').play();
LK.effects.flashScreen(0x00ff00, 200);
// Store matched profile for detailed view
var profileData = {
name: self.name,
age: self.age,
bio: self.bio,
interests: self.interests,
attractiveness: self.attractiveness,
profileId: self.profileId
};
matchedProfiles.push(profileData);
showProfileDetails(profileData);
} else {
// Bad swipe - swiped right on unattractive person
wrongSwipes++;
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 200);
}
updateScore();
LK.setTimeout(function () {
spawnNewProfile();
}, 2000);
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 - this is wrong
wrongSwipes++;
LK.getSound('wrong').play();
LK.effects.flashScreen(0xff0000, 200);
} else {
// Good rejection - correct swipe left
LK.setScore(LK.getScore() + 5);
LK.getSound('reject').play();
LK.effects.flashScreen(0x00ff00, 200);
}
updateScore();
LK.setTimeout(function () {
spawnNewProfile();
}, 1000);
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', 'Olivia', 'Ava', 'Chloe', 'Madison', 'Ella', 'Scarlett', 'Victoria', 'Aria', 'Zoe', 'Lily', 'Natalie', 'Leah', 'Hannah', 'Addison', 'Maya', 'Samantha', 'Audrey', 'Brooklyn', 'Claire', 'Bella'];
var gameSpeed = 1;
var viewedProfiles = 0;
var maxProfiles = 50;
var matchedProfiles = [];
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0x333333
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var wrongSwipesTxt = new Text2('Wrong: 0/' + maxWrongSwipes, {
size: 80,
fill: 0xFF0000
});
wrongSwipesTxt.anchor.set(1, 0);
wrongSwipesTxt.x = -20;
wrongSwipesTxt.y = 20;
LK.gui.topRight.addChild(wrongSwipesTxt);
var profileCountTxt = new Text2('Profiles: 0/' + maxProfiles, {
size: 80,
fill: 0x333333
});
profileCountTxt.anchor.set(0, 0);
profileCountTxt.x = 20;
profileCountTxt.y = 20;
LK.gui.topLeft.addChild(profileCountTxt);
var matchesTxt = new Text2('Matches: 0', {
size: 50,
fill: 0x00AA00
});
matchesTxt.anchor.set(1, 0);
matchesTxt.x = -20;
matchesTxt.y = 80;
LK.gui.topRight.addChild(matchesTxt);
// Instructions
var instructionsTxt = new Text2('Swipe Right: Like | Swipe Left: Pass', {
size: 70,
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);
profileCountTxt.setText('Profiles: ' + viewedProfiles + '/' + maxProfiles);
matchesTxt.setText('Matches: ' + matchedProfiles.length);
if (wrongSwipes >= maxWrongSwipes) {
LK.showGameOver();
return;
}
if (viewedProfiles >= maxProfiles) {
LK.showYouWin();
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 getRandomBio() {
var bios = ["Love traveling and trying new foods 🌍", "Fitness enthusiast and dog lover 🐕", "Artist by day, Netflix binger by night 🎨", "Adventurous spirit seeking new experiences ⛰️", "Coffee addict and bookworm 📚☕", "Yoga instructor and nature lover 🧘♀️", "Photographer capturing life's moments 📸", "Foodie exploring the city's best restaurants 🍴", "Music lover and concert goer 🎵", "Beach lover and sunset chaser 🌅"];
return bios[Math.floor(Math.random() * bios.length)];
}
function getRandomInterests() {
var allInterests = ["Travel", "Fitness", "Art", "Music", "Food", "Photography", "Reading", "Yoga", "Dancing", "Gaming", "Movies", "Nature", "Cooking", "Sports"];
var interests = [];
var numInterests = Math.floor(Math.random() * 4) + 2; // 2-5 interests
for (var i = 0; i < numInterests; i++) {
var randomInterest = allInterests[Math.floor(Math.random() * allInterests.length)];
if (interests.indexOf(randomInterest) === -1) {
interests.push(randomInterest);
}
}
return interests;
}
function showProfileDetails(profile) {
// Create detailed info display
var detailsContainer = new Container();
detailsContainer.x = 2048 / 2;
detailsContainer.y = 2732 / 2;
game.addChild(detailsContainer);
var detailsBg = detailsContainer.attachAsset('profileCard', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 1.2
});
var detailsText = new Text2("It's a Match! 💕\n\n" + profile.name + ", " + profile.age + "\n\n" + profile.bio + "\n\nInterests: " + profile.interests.join(", "), {
size: 80,
fill: 0x000000,
align: 'center',
wordWrap: true,
wordWrapWidth: 400
});
detailsText.anchor.set(0.5, 0.5);
detailsContainer.addChild(detailsText);
// Auto-hide after 2 seconds
LK.setTimeout(function () {
detailsContainer.destroy();
}, 2000);
}
function spawnNewProfile() {
if (currentProfile) {
currentProfile.destroy();
}
if (viewedProfiles >= maxProfiles) {
return;
}
var attractiveness = getRandomAttractiveness();
var name = getRandomName();
var age = getRandomAge();
var bio = getRandomBio();
var interests = getRandomInterests();
currentProfile = new Profile(attractiveness, name, age, bio, interests);
currentProfile.x = 2048 / 2;
currentProfile.y = 2732 / 2;
currentProfile.scaleX = 0.8;
currentProfile.scaleY = 0.8;
game.addChild(currentProfile);
viewedProfiles++;
updateScore();
// 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();