User prompt
spawn objgust only once until seagul is not diving anymore
User prompt
Spawn objGust behind center of seagull
User prompt
adjust obj gust spawn position depending on what way seagul is facing visually
Code edit (8 edits merged)
Please save this source code
User prompt
objGust should be on the layer behind seagul
User prompt
objgust must be instantiated before seagul can dive
User prompt
if seagul is diving, do not instantiate objgust again
Code edit (5 edits merged)
Please save this source code
User prompt
when left clicking also spawn behind seagul for 0.5 seconds objgust
Code edit (1 edits merged)
Please save this source code
User prompt
Move objimhungry to the right
User prompt
Instantiate objimhungry for two seconds over objhead when hunger bar is decreasing.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Move objhead to the right
User prompt
Replace objstomach with objhead
User prompt
Fix it
User prompt
If more than one is attached to contactpoint the hunger refill should stack
User prompt
compare objfries to objcrab, both should behave the exact same way when attached to contactpoint, if it isn't, then delete the redundant code
User prompt
when hungermeter is increasing, the bar should be light green
User prompt
objmusic notes should be rendered before objbackground11
User prompt
objmusicnotes should be behind objbackground11
User prompt
similar to objfries, when objcrab is snatched, it should increase hunger
User prompt
similar to objfries, when objcrab intersects with contactpoint, it should increase hunger
User prompt
when objcrab intersects with contactpoint, it should increase hunger
/**** * Classes ****/ var Background02 = Container.expand(function () { var self = Container.call(this); var background02Graphics = self.attachAsset('objBackground02', { anchorX: 0.5, anchorY: 0.5 }); // Add wind animation in the update method self.update = function () { // Simulate wind blowing by rotating the object slightly self.rotation = Math.sin(LK.ticks / 120) * 0.05; // Rotate more back and forth with increased effect }; }); var Background04 = Container.expand(function () { var self = Container.call(this); var background04Graphics = self.attachAsset('objBackground04', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += Math.sin(LK.ticks / 60) * 0.2; // Reduced floating effect }; }); var Background06 = Container.expand(function () { var self = Container.call(this); var background06Graphics = self.attachAsset('objBackground06', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += Math.sin(LK.ticks / 60) * 0.2; // Reduced floating effect }; }); var Background07 = Container.expand(function () { var self = Container.call(this); var background07Graphics = self.attachAsset('objBackground07', { anchorX: 0.5, anchorY: 0.5 }); // Add wind animation in the update method self.update = function () { // Simulate wind blowing by rotating the object slightly self.rotation = Math.sin(LK.ticks / 120) * 0.08; // Rotate a bit less back and forth }; }); var Background13 = Container.expand(function () { var self = Container.call(this); var background13Graphics = self.attachAsset('objBackground13', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose a direction self.update = function () { var background13Graphics = self.children[0]; // Access the attached asset self.x += self.speed * self.direction; // Flip the image depending on the direction background13Graphics.scale.x = self.direction * (0.75 + Math.random() * 0.25); // Check if background13 is out of bounds horizontally if (self.x > 2048 + background13Graphics.width / 2 || self.x < -background13Graphics.width / 2) { self.destroy(); // Destroy background13 when it goes out of bounds } }; }); var ObjCrab = Container.expand(function () { var self = Container.call(this); var crabGraphics = self.attachAsset('objCrab', { anchorX: 0.5, anchorY: 0.5 }); self.y = 2455; self.speed = 2; self.update = function () { self.x += self.speed; self.y += Math.sin(LK.ticks / 3) * 2; // Add vertical waddling effect self.rotation = Math.sin(LK.ticks / 20) * 0.1; // Add rotation for waddling effect if (self.intersects(background8)) { var objSandDust = game.addChild(new ObjSandDust()); objSandDust.x = background8.x; objSandDust.y = background8.y - 50; self.destroy(); } if (self.intersects(objContactPoint)) { self.attached = true; self.x = objContactPoint.x; self.y = objContactPoint.y; self.speed = 0; // Stop crab movement when snatched } else { self.attached = false; } // Check if objCrab leaves the playspace if (self.y > 2732 + self.height || self.y < -self.height || self.x > 2048 + self.width || self.x < -self.width) { self.attached = false; // Mark crab as detached when destroyed self.destroy(); } }; }); var ObjFish = Container.expand(function () { var self = Container.call(this); var fishGraphics = self.attachAsset('objFish', { anchorX: 0.5, anchorY: 0.5 }); var startX = 1000; // Centered X position var startY = 1875; // Centered Y position self.x = startX; self.y = startY; var scaleDirection = 1; self.update = function () { // Make the fish swim around its starting position var newX = startX + Math.sin(LK.ticks / 60) * 50; if (newX < self.x) { fishGraphics.scale.x = -1; // Flip horizontally } else { fishGraphics.scale.x = 1; // Default orientation } self.x = newX; self.y = startY + Math.cos(LK.ticks / 60) * 30; // Slowly scale the fish up and down if (self.scale.x >= 1.1) { scaleDirection = -1; } else if (self.scale.x <= 0.9) { scaleDirection = 1; } self.scale.x += scaleDirection * 0.001; self.scale.y += scaleDirection * 0.001; }; }); var ObjMusicNotes = Container.expand(function () { var self = Container.call(this); var musicNotesGraphics = self.attachAsset('ObjMusicNotes', { anchorX: 0.5, anchorY: 0.5 }); var scaleDirection = 1; self.update = function () { // Make the music notes dance by scaling up and down slightly if (self.scale.y >= 1.1) { scaleDirection = -1; } else if (self.scale.y <= 0.9) { scaleDirection = 1; } self.scale.y += scaleDirection * 0.002; }; }); var ObjSandDust = Container.expand(function () { var self = Container.call(this); var sandDustGraphics = self.attachAsset('objSandDust', { anchorX: 0.5, anchorY: 0.5 }); self.alpha = 1.0; self.update = function () { self.y -= 1; // Move upwards self.alpha -= 0.01; // Gradually disappear over 2 seconds (60 frames per second) if (self.alpha <= 0) { self.destroy(); // Destroy the object when fully transparent } }; }); var Seagull = Container.expand(function () { var self = Container.call(this); var seagullGraphics = self.attachAsset('objSeagull', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10 + Math.floor(LK.getScore() / 10); self.direction = 1; self.diving = false; self.diveTime = 0; self.diveDuration = 60; // Total duration of the dive in frames self.startX = 0; self.startY = 0; self.endX = 0; self.endY = 2732 - seagullGraphics.height / 2 - 200; // Target Y position for the dive self.returning = false; self.update = function () { if (self.diving) { self.diveTime++; var t = self.diveTime / self.diveDuration; // Normalized time (0 to 1) self.x = (1 - t) * self.startX + t * self.endX; // Linear horizontal movement self.y = (1 - t) * self.startY + t * self.endY - 300 * t * (1 - t); // Parabolic vertical movement if (self.diveTime >= self.diveDuration) { self.diveTime = 0; self.diving = false; self.returning = true; // Start returning to original position self.startX = self.x; // Update startX to the current X self.startY = self.y; // Update startY to the current Y (bottom of the dive) self.endY = 475; // Return to the original Y position self.endX = self.startX + self.speed * self.direction * self.diveDuration / 2; // Move further ahead } } else if (self.returning) { self.diveTime++; var t = self.diveTime / self.diveDuration; // Normalized time (0 to 1) self.x = (1 - t) * self.startX + t * self.endX; // Linear horizontal movement back self.y = (1 - t) * self.startY + t * self.endY - 300 * t * (1 - t); // Parabolic vertical movement back if (self.diveTime >= self.diveDuration) { self.diveTime = 0; self.returning = false; // End the return phase self.diving = false; // Reset diving state self.startX = self.x; // Reset startX for the next dive self.startY = self.y; // Reset startY for the next dive self.endY = 2732 - seagullGraphics.height / 2 - 200; // Reset endY for the next dive } } else { intersecting = false; self.x += self.speed * self.direction; self.y += Math.sin(LK.ticks / 10) * 5; // Add a hover effect // Check if seagull is out of bounds horizontally if (self.x > 2048 + seagullGraphics.width / 2 || self.x < -seagullGraphics.width / 2) { self.direction *= -1; // Flip direction self.x = Math.max(-seagullGraphics.width / 2, Math.min(2048 + seagullGraphics.width / 2, self.x)); // Keep seagull within bounds self.y = Math.random() * (2732 * 0.3) + 100; // Random Y position in the upper 30% of the playspace with a 100px boundary // Flip the seagull's graphics seagullGraphics.scale.x *= -1; } } // Increment score by 3 every second objCrab or objFries are intersecting with objContactPoint if (LK.ticks % 60 == 0) { if (typeof crab !== 'undefined' && objContactPoint.intersects(crab)) { score += 3; } if (objContactPoint.intersects(fries)) { score += 3; } } // Update the score display scoreText.setText('Score: ' + score); // Check if objContactPoint and fries are intersecting if (objContactPoint.intersects(fries)) { intersecting = true; // Attach fries to the center of objContactPoint fries.x = objContactPoint.x; fries.y = objContactPoint.y; // Stop decreasing hungerMeter's width and start replenishing it hungerMeter.width = Math.min(hungerMeter.width + 1, 2048); // Do not increment score when seagull snatches fries } else if (typeof crab !== 'undefined' && objContactPoint.intersects(crab)) { intersecting = true; // Snatch the crab crab.speed = 0; crab.x = objContactPoint.x; crab.y = objContactPoint.y; crab.rotation = 0; // Stop rotation when snatched crab.attached = true; // Mark crab as snatched // Increase hunger meter when objCrab intersects with objContactPoint hungerMeter.width = Math.min(hungerMeter.width + 5, 2048); } else if (typeof crab !== 'undefined' && crab.attached) { crab.x = objContactPoint.x; crab.y = objContactPoint.y; // Increase hunger meter when objCrab is attached hungerMeter.width = Math.min(hungerMeter.width + 5, 2048); } else { // Decrease hungerMeter's width over time if seagull is not snatching fries if (!intersecting && hungerMeter.width > 0) { hungerMeter.width -= 2; // Increase the rate of decrease if (LK.ticks % 60 == 0) { score += 1; } } } // Check if fries leave the playspace if (fries.y > 2732 + fries.height / 2 || fries.y < -fries.height / 2 || fries.x > 2048 + fries.width / 2 || fries.x < -fries.width / 2) { // Destroy fries fries.destroy(); } // Check if crab leaves the playspace if (typeof crab !== 'undefined' && (crab.y > 2732 + crab.height / 2 || crab.y < -crab.height / 2 || crab.x > 2048 + crab.width / 2 || crab.x < -crab.width / 2)) { crab.destroy(); crab.attached = false; // Mark crab as detached when destroyed } // Initialize objBackground13 every 6 to 15 seconds if (!game.background13Active && LK.ticks % (60 * (Math.floor(Math.random() * 10) + 6)) == 0) { var background13 = game.addChild(new Background13()); background13.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose a direction background13.x = background13.direction > 0 ? -background13.width / 2 : 2048 + background13.width / 2; // Start from the left or right edge of the playspace background13.y = Math.random() * (2732 * 0.2) + 50; // Random Y position in the upper 20% of the playspace with a 50px boundary game.background13Active = true; // Set the flag to indicate that objBackground13 is active background13.update = function () { var background13Graphics = this.children[0]; // Access the attached asset this.x += this.speed * this.direction; // Flip the image depending on the direction background13Graphics.scale.x = this.direction; // Check if background13 is out of bounds horizontally if (this.x > 2048 + background13Graphics.width / 2 || this.x < -background13Graphics.width / 2) { this.destroy(); // Destroy background13 when it goes out of bounds game.background13Active = false; // Reset the flag when objBackground13 is destroyed } }; } // Spawn objCrab every 6 to 10 seconds if (LK.ticks % (60 * (Math.floor(Math.random() * 5) + 6)) == 0) { crab = new ObjCrab(); crab.attached = false; // Initialize attached state crab.x = -crab.width / 2; // Start from the utmost left game.addChildAt(crab, game.getChildIndex(background9)); // Add crab behind objBackground09 } // Trigger game over when hungerMeter's width reaches 0 if (hungerMeter.width <= 0) { LK.setScore(score); LK.showGameOver(); } // Attach objContactPoint to the center of seagull objContactPoint.x = self.x; objContactPoint.y = self.y + 200; }; // Remove the down event from the seagull as we want to trigger it from anywhere in the playspace }); var Smoke = Container.expand(function () { var self = Container.call(this); var smokeGraphics = self.attachAsset('objSmoke', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += Math.sin(LK.ticks / 60) * 0.2; // Reduced floating effect }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var crab; // Declare crab in the global scope var intersecting = false; // Flag to track if seagull is interacting with fries or crab var background = game.addChild(LK.getAsset('ObjBackground01', { anchorX: 0.5, anchorY: 0.5 })); background.x = 1024; background.y = 1366; var objSmoke = game.addChild(new Smoke()); objSmoke.x = 975; objSmoke.y = 875; var objFish = game.addChild(new ObjFish()); objFish.x = 1024; objFish.y = 1366; // Position objFish at y 1366 objFish.visible = true; // Ensure objFish is visible var background11 = game.addChild(LK.getAsset('objBackground11', { anchorX: 0.5, anchorY: 0.5 })); background11.x = 25; background11.y = 1300; var objMusicNotes = game.addChild(new ObjMusicNotes()); objMusicNotes.x = 435; objMusicNotes.y = 1010; var background10 = game.addChild(LK.getAsset('objBackground10', { anchorX: 0.5, anchorY: 0.5 })); background10.x = 125; background10.y = 2500; var background9 = game.addChild(LK.getAsset('objBackground09', { anchorX: 0.5, anchorY: 0.5 })); background9.x = 450; background9.y = 2490; var background8 = game.addChild(LK.getAsset('objBackground08', { anchorX: 0.5, anchorY: 0.5 })); background8.x = 1525; background8.y = 2455; var background7 = game.addChild(new Background07()); background7.x = 150; background7.y = 2650; var background6 = game.addChild(new Background06()); background6.x = 1175; background6.y = 1035; var background4 = game.addChild(new Background04()); var background5 = game.addChild(LK.getAsset('objBackground05', { anchorX: 0.5, anchorY: 0.5 })); var background12 = game.addChild(LK.getAsset('objBackground12', { anchorX: 0.5, anchorY: 0.5 })); background12.x = 850; background12.y = 3335; background5.x = 165; background5.y = 1925; background4.x = 1024; background4.y = 990; var background3 = game.addChild(LK.getAsset('objBackground03', { anchorX: 0.5, anchorY: 0.5 })); background3.x = 1824; background3.y = 2166; var background2 = game.addChild(new Background02()); background2.x = 1790; background2.y = 1766; var seagull = game.addChild(new Seagull()); seagull.x = -seagull.width / 2; // Start from outside the left edge of the playspace seagull.y = 475; var fries = game.addChild(LK.getAsset('objFries', { anchorX: 0.5, anchorY: 0.5 })); fries.x = 1024; fries.y = 2166; var hungerMeter = game.addChild(LK.getAsset('objHungerMeter', { anchorX: 0.5, anchorY: 0.5, width: 2048 })); hungerMeter.x = 1024; hungerMeter.y = 2650; objContactPoint = game.addChild(LK.getAsset('objContactPoint', { anchorX: 0.5, anchorY: 0.5, alpha: 0 })); objContactPoint.x = 1024; objContactPoint.y = 1366; // Create a text object to display the score var scoreText = new Text2('Score: 0', { size: 80, fill: "#ffffff", font: "Impact" }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); var score = 0; game.background13Active = false; // Flag to track if objBackground13 is active // Instantiate objStomach where objHungerFrame is and remove objHungerFrame from the playspace var stomach = game.addChild(LK.getAsset('objStomach', { anchorX: 0.5, anchorY: 0.5 })); stomach.x = 995; stomach.y = 2635; ; game.down = function (x, y, obj) { if (!seagull.diving && !seagull.returning) { // Only start diving if not already diving or returning seagull.diving = true; seagull.diveTime = 0; seagull.startX = seagull.x; seagull.startY = seagull.y; // Calculate endX based on current speed and direction seagull.endX = seagull.startX + seagull.speed * seagull.direction * seagull.diveDuration / 2; } };
/****
* Classes
****/
var Background02 = Container.expand(function () {
var self = Container.call(this);
var background02Graphics = self.attachAsset('objBackground02', {
anchorX: 0.5,
anchorY: 0.5
});
// Add wind animation in the update method
self.update = function () {
// Simulate wind blowing by rotating the object slightly
self.rotation = Math.sin(LK.ticks / 120) * 0.05; // Rotate more back and forth with increased effect
};
});
var Background04 = Container.expand(function () {
var self = Container.call(this);
var background04Graphics = self.attachAsset('objBackground04', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += Math.sin(LK.ticks / 60) * 0.2; // Reduced floating effect
};
});
var Background06 = Container.expand(function () {
var self = Container.call(this);
var background06Graphics = self.attachAsset('objBackground06', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += Math.sin(LK.ticks / 60) * 0.2; // Reduced floating effect
};
});
var Background07 = Container.expand(function () {
var self = Container.call(this);
var background07Graphics = self.attachAsset('objBackground07', {
anchorX: 0.5,
anchorY: 0.5
});
// Add wind animation in the update method
self.update = function () {
// Simulate wind blowing by rotating the object slightly
self.rotation = Math.sin(LK.ticks / 120) * 0.08; // Rotate a bit less back and forth
};
});
var Background13 = Container.expand(function () {
var self = Container.call(this);
var background13Graphics = self.attachAsset('objBackground13', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose a direction
self.update = function () {
var background13Graphics = self.children[0]; // Access the attached asset
self.x += self.speed * self.direction;
// Flip the image depending on the direction
background13Graphics.scale.x = self.direction * (0.75 + Math.random() * 0.25);
// Check if background13 is out of bounds horizontally
if (self.x > 2048 + background13Graphics.width / 2 || self.x < -background13Graphics.width / 2) {
self.destroy(); // Destroy background13 when it goes out of bounds
}
};
});
var ObjCrab = Container.expand(function () {
var self = Container.call(this);
var crabGraphics = self.attachAsset('objCrab', {
anchorX: 0.5,
anchorY: 0.5
});
self.y = 2455;
self.speed = 2;
self.update = function () {
self.x += self.speed;
self.y += Math.sin(LK.ticks / 3) * 2; // Add vertical waddling effect
self.rotation = Math.sin(LK.ticks / 20) * 0.1; // Add rotation for waddling effect
if (self.intersects(background8)) {
var objSandDust = game.addChild(new ObjSandDust());
objSandDust.x = background8.x;
objSandDust.y = background8.y - 50;
self.destroy();
}
if (self.intersects(objContactPoint)) {
self.attached = true;
self.x = objContactPoint.x;
self.y = objContactPoint.y;
self.speed = 0; // Stop crab movement when snatched
} else {
self.attached = false;
}
// Check if objCrab leaves the playspace
if (self.y > 2732 + self.height || self.y < -self.height || self.x > 2048 + self.width || self.x < -self.width) {
self.attached = false; // Mark crab as detached when destroyed
self.destroy();
}
};
});
var ObjFish = Container.expand(function () {
var self = Container.call(this);
var fishGraphics = self.attachAsset('objFish', {
anchorX: 0.5,
anchorY: 0.5
});
var startX = 1000; // Centered X position
var startY = 1875; // Centered Y position
self.x = startX;
self.y = startY;
var scaleDirection = 1;
self.update = function () {
// Make the fish swim around its starting position
var newX = startX + Math.sin(LK.ticks / 60) * 50;
if (newX < self.x) {
fishGraphics.scale.x = -1; // Flip horizontally
} else {
fishGraphics.scale.x = 1; // Default orientation
}
self.x = newX;
self.y = startY + Math.cos(LK.ticks / 60) * 30;
// Slowly scale the fish up and down
if (self.scale.x >= 1.1) {
scaleDirection = -1;
} else if (self.scale.x <= 0.9) {
scaleDirection = 1;
}
self.scale.x += scaleDirection * 0.001;
self.scale.y += scaleDirection * 0.001;
};
});
var ObjMusicNotes = Container.expand(function () {
var self = Container.call(this);
var musicNotesGraphics = self.attachAsset('ObjMusicNotes', {
anchorX: 0.5,
anchorY: 0.5
});
var scaleDirection = 1;
self.update = function () {
// Make the music notes dance by scaling up and down slightly
if (self.scale.y >= 1.1) {
scaleDirection = -1;
} else if (self.scale.y <= 0.9) {
scaleDirection = 1;
}
self.scale.y += scaleDirection * 0.002;
};
});
var ObjSandDust = Container.expand(function () {
var self = Container.call(this);
var sandDustGraphics = self.attachAsset('objSandDust', {
anchorX: 0.5,
anchorY: 0.5
});
self.alpha = 1.0;
self.update = function () {
self.y -= 1; // Move upwards
self.alpha -= 0.01; // Gradually disappear over 2 seconds (60 frames per second)
if (self.alpha <= 0) {
self.destroy(); // Destroy the object when fully transparent
}
};
});
var Seagull = Container.expand(function () {
var self = Container.call(this);
var seagullGraphics = self.attachAsset('objSeagull', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10 + Math.floor(LK.getScore() / 10);
self.direction = 1;
self.diving = false;
self.diveTime = 0;
self.diveDuration = 60; // Total duration of the dive in frames
self.startX = 0;
self.startY = 0;
self.endX = 0;
self.endY = 2732 - seagullGraphics.height / 2 - 200; // Target Y position for the dive
self.returning = false;
self.update = function () {
if (self.diving) {
self.diveTime++;
var t = self.diveTime / self.diveDuration; // Normalized time (0 to 1)
self.x = (1 - t) * self.startX + t * self.endX; // Linear horizontal movement
self.y = (1 - t) * self.startY + t * self.endY - 300 * t * (1 - t); // Parabolic vertical movement
if (self.diveTime >= self.diveDuration) {
self.diveTime = 0;
self.diving = false;
self.returning = true; // Start returning to original position
self.startX = self.x; // Update startX to the current X
self.startY = self.y; // Update startY to the current Y (bottom of the dive)
self.endY = 475; // Return to the original Y position
self.endX = self.startX + self.speed * self.direction * self.diveDuration / 2; // Move further ahead
}
} else if (self.returning) {
self.diveTime++;
var t = self.diveTime / self.diveDuration; // Normalized time (0 to 1)
self.x = (1 - t) * self.startX + t * self.endX; // Linear horizontal movement back
self.y = (1 - t) * self.startY + t * self.endY - 300 * t * (1 - t); // Parabolic vertical movement back
if (self.diveTime >= self.diveDuration) {
self.diveTime = 0;
self.returning = false; // End the return phase
self.diving = false; // Reset diving state
self.startX = self.x; // Reset startX for the next dive
self.startY = self.y; // Reset startY for the next dive
self.endY = 2732 - seagullGraphics.height / 2 - 200; // Reset endY for the next dive
}
} else {
intersecting = false;
self.x += self.speed * self.direction;
self.y += Math.sin(LK.ticks / 10) * 5; // Add a hover effect
// Check if seagull is out of bounds horizontally
if (self.x > 2048 + seagullGraphics.width / 2 || self.x < -seagullGraphics.width / 2) {
self.direction *= -1; // Flip direction
self.x = Math.max(-seagullGraphics.width / 2, Math.min(2048 + seagullGraphics.width / 2, self.x)); // Keep seagull within bounds
self.y = Math.random() * (2732 * 0.3) + 100; // Random Y position in the upper 30% of the playspace with a 100px boundary
// Flip the seagull's graphics
seagullGraphics.scale.x *= -1;
}
}
// Increment score by 3 every second objCrab or objFries are intersecting with objContactPoint
if (LK.ticks % 60 == 0) {
if (typeof crab !== 'undefined' && objContactPoint.intersects(crab)) {
score += 3;
}
if (objContactPoint.intersects(fries)) {
score += 3;
}
}
// Update the score display
scoreText.setText('Score: ' + score);
// Check if objContactPoint and fries are intersecting
if (objContactPoint.intersects(fries)) {
intersecting = true;
// Attach fries to the center of objContactPoint
fries.x = objContactPoint.x;
fries.y = objContactPoint.y;
// Stop decreasing hungerMeter's width and start replenishing it
hungerMeter.width = Math.min(hungerMeter.width + 1, 2048);
// Do not increment score when seagull snatches fries
} else if (typeof crab !== 'undefined' && objContactPoint.intersects(crab)) {
intersecting = true;
// Snatch the crab
crab.speed = 0;
crab.x = objContactPoint.x;
crab.y = objContactPoint.y;
crab.rotation = 0; // Stop rotation when snatched
crab.attached = true; // Mark crab as snatched
// Increase hunger meter when objCrab intersects with objContactPoint
hungerMeter.width = Math.min(hungerMeter.width + 5, 2048);
} else if (typeof crab !== 'undefined' && crab.attached) {
crab.x = objContactPoint.x;
crab.y = objContactPoint.y;
// Increase hunger meter when objCrab is attached
hungerMeter.width = Math.min(hungerMeter.width + 5, 2048);
} else {
// Decrease hungerMeter's width over time if seagull is not snatching fries
if (!intersecting && hungerMeter.width > 0) {
hungerMeter.width -= 2; // Increase the rate of decrease
if (LK.ticks % 60 == 0) {
score += 1;
}
}
}
// Check if fries leave the playspace
if (fries.y > 2732 + fries.height / 2 || fries.y < -fries.height / 2 || fries.x > 2048 + fries.width / 2 || fries.x < -fries.width / 2) {
// Destroy fries
fries.destroy();
}
// Check if crab leaves the playspace
if (typeof crab !== 'undefined' && (crab.y > 2732 + crab.height / 2 || crab.y < -crab.height / 2 || crab.x > 2048 + crab.width / 2 || crab.x < -crab.width / 2)) {
crab.destroy();
crab.attached = false; // Mark crab as detached when destroyed
}
// Initialize objBackground13 every 6 to 15 seconds
if (!game.background13Active && LK.ticks % (60 * (Math.floor(Math.random() * 10) + 6)) == 0) {
var background13 = game.addChild(new Background13());
background13.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose a direction
background13.x = background13.direction > 0 ? -background13.width / 2 : 2048 + background13.width / 2; // Start from the left or right edge of the playspace
background13.y = Math.random() * (2732 * 0.2) + 50; // Random Y position in the upper 20% of the playspace with a 50px boundary
game.background13Active = true; // Set the flag to indicate that objBackground13 is active
background13.update = function () {
var background13Graphics = this.children[0]; // Access the attached asset
this.x += this.speed * this.direction;
// Flip the image depending on the direction
background13Graphics.scale.x = this.direction;
// Check if background13 is out of bounds horizontally
if (this.x > 2048 + background13Graphics.width / 2 || this.x < -background13Graphics.width / 2) {
this.destroy(); // Destroy background13 when it goes out of bounds
game.background13Active = false; // Reset the flag when objBackground13 is destroyed
}
};
}
// Spawn objCrab every 6 to 10 seconds
if (LK.ticks % (60 * (Math.floor(Math.random() * 5) + 6)) == 0) {
crab = new ObjCrab();
crab.attached = false; // Initialize attached state
crab.x = -crab.width / 2; // Start from the utmost left
game.addChildAt(crab, game.getChildIndex(background9)); // Add crab behind objBackground09
}
// Trigger game over when hungerMeter's width reaches 0
if (hungerMeter.width <= 0) {
LK.setScore(score);
LK.showGameOver();
}
// Attach objContactPoint to the center of seagull
objContactPoint.x = self.x;
objContactPoint.y = self.y + 200;
};
// Remove the down event from the seagull as we want to trigger it from anywhere in the playspace
});
var Smoke = Container.expand(function () {
var self = Container.call(this);
var smokeGraphics = self.attachAsset('objSmoke', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.y += Math.sin(LK.ticks / 60) * 0.2; // Reduced floating effect
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
var crab; // Declare crab in the global scope
var intersecting = false; // Flag to track if seagull is interacting with fries or crab
var background = game.addChild(LK.getAsset('ObjBackground01', {
anchorX: 0.5,
anchorY: 0.5
}));
background.x = 1024;
background.y = 1366;
var objSmoke = game.addChild(new Smoke());
objSmoke.x = 975;
objSmoke.y = 875;
var objFish = game.addChild(new ObjFish());
objFish.x = 1024;
objFish.y = 1366; // Position objFish at y 1366
objFish.visible = true; // Ensure objFish is visible
var background11 = game.addChild(LK.getAsset('objBackground11', {
anchorX: 0.5,
anchorY: 0.5
}));
background11.x = 25;
background11.y = 1300;
var objMusicNotes = game.addChild(new ObjMusicNotes());
objMusicNotes.x = 435;
objMusicNotes.y = 1010;
var background10 = game.addChild(LK.getAsset('objBackground10', {
anchorX: 0.5,
anchorY: 0.5
}));
background10.x = 125;
background10.y = 2500;
var background9 = game.addChild(LK.getAsset('objBackground09', {
anchorX: 0.5,
anchorY: 0.5
}));
background9.x = 450;
background9.y = 2490;
var background8 = game.addChild(LK.getAsset('objBackground08', {
anchorX: 0.5,
anchorY: 0.5
}));
background8.x = 1525;
background8.y = 2455;
var background7 = game.addChild(new Background07());
background7.x = 150;
background7.y = 2650;
var background6 = game.addChild(new Background06());
background6.x = 1175;
background6.y = 1035;
var background4 = game.addChild(new Background04());
var background5 = game.addChild(LK.getAsset('objBackground05', {
anchorX: 0.5,
anchorY: 0.5
}));
var background12 = game.addChild(LK.getAsset('objBackground12', {
anchorX: 0.5,
anchorY: 0.5
}));
background12.x = 850;
background12.y = 3335;
background5.x = 165;
background5.y = 1925;
background4.x = 1024;
background4.y = 990;
var background3 = game.addChild(LK.getAsset('objBackground03', {
anchorX: 0.5,
anchorY: 0.5
}));
background3.x = 1824;
background3.y = 2166;
var background2 = game.addChild(new Background02());
background2.x = 1790;
background2.y = 1766;
var seagull = game.addChild(new Seagull());
seagull.x = -seagull.width / 2; // Start from outside the left edge of the playspace
seagull.y = 475;
var fries = game.addChild(LK.getAsset('objFries', {
anchorX: 0.5,
anchorY: 0.5
}));
fries.x = 1024;
fries.y = 2166;
var hungerMeter = game.addChild(LK.getAsset('objHungerMeter', {
anchorX: 0.5,
anchorY: 0.5,
width: 2048
}));
hungerMeter.x = 1024;
hungerMeter.y = 2650;
objContactPoint = game.addChild(LK.getAsset('objContactPoint', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
}));
objContactPoint.x = 1024;
objContactPoint.y = 1366;
// Create a text object to display the score
var scoreText = new Text2('Score: 0', {
size: 80,
fill: "#ffffff",
font: "Impact"
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var score = 0;
game.background13Active = false; // Flag to track if objBackground13 is active
// Instantiate objStomach where objHungerFrame is and remove objHungerFrame from the playspace
var stomach = game.addChild(LK.getAsset('objStomach', {
anchorX: 0.5,
anchorY: 0.5
}));
stomach.x = 995;
stomach.y = 2635;
;
game.down = function (x, y, obj) {
if (!seagull.diving && !seagull.returning) {
// Only start diving if not already diving or returning
seagull.diving = true;
seagull.diveTime = 0;
seagull.startX = seagull.x;
seagull.startY = seagull.y;
// Calculate endX based on current speed and direction
seagull.endX = seagull.startX + seagull.speed * seagull.direction * seagull.diveDuration / 2;
}
};
Create a cartoon-style illustration of the ocean and an empty sandy beach from the perspective of a person standing on the beach. The goal is to capture a lively and playful location.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of fries in a brown bag. The goal is to capture a lively and playful object. Front perspective. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of white drop of paint. The goal is to capture a lively and playful paint.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of white splash of paint. The goal is to capture a lively and playful paint. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a stomach The goal is to capture a lively and playful stomach... Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of palm trees. The goal is to capture a lively and playful location. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of beach rocks. The goal is to capture a lively and playful location. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a wooden no feeding and no littering sign on a sandy stake.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a speech bubble that is written I'm Hungry!. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a giant squid menacingly staring... Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of palm trees leaves.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a dark silhouette of a seaplane, side profile. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of smoke.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a mix of colorful music notes. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a cartoon-style illustration of a crab from the back. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a cartoon-style illustration of a sand cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a cartoon-style illustration of an explosion of stars. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a cartoon-style illustration of an speech bubble with the word "Yum!". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
make it more colorful in the top portion of the bricks
Create a cartoon-style illustration of a mix of a beach radio. Front View. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a close-up cartoon-style illustration of an dizzy seagull with his tongue sticking out on an empty sandy beach. The goal is to capture a lively and playful game over screen. Make sure 'game over' is written.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a close-up cartoon-style illustration of the letters "sos" in black. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a smiling face of a seagul with black shades with the words "Time Bonus" at the bottom of it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a seagul's face chomping down on a slice of bread make it comical. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a cartoon-style illustration of an red girly angry emoji. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a cartoon-style illustration of a seagul's face chomping down on fries make it comical.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a cartoon-style illustration of a seagul's face chomping down on a fish make it comical.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
three words 'dive to eat' in a cartoonish style with an arrow pointing down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.