Code edit (12 edits merged)
Please save this source code
User prompt
pease write a function that can be called to determine if two objects are colliding more than the value of a parameter passed to the function.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: groundLevel is not defined' in or related to this line: 't.y = groundLevel + 20;' Line Number: 739
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (11 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in or related to this line: 'barricade.x = 2048 + spikeTrap.width;' Line Number: 454
Code edit (1 edits merged)
Please save this source code
User prompt
give all text a black outline
User prompt
the +10 signs should fly off to the left side of the screen and be destroyed after a few seconds
User prompt
show a +10 sign and play a sound effect when player picks up a collectible
User prompt
Increase score by 10 when player picks up a collectible
User prompt
add a scorelabel top center of the scree
Code edit (12 edits merged)
Please save this source code
User prompt
make a class for the dustparticle and use its update method instead of running the spread and alpha in an interval
User prompt
the dust particles should spread and go transparent before they disappear
User prompt
use a separate dustparticle asset for the dustparticles
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'destroy')' in or related to this line: 'particle.destroy();' Line Number: 169
===================================================================
--- original.js
+++ change.js
@@ -2,16 +2,13 @@
* Classes
****/
/***
TODO:
- - Maybe show a warning for oncoming enemies (high middle or low) before they appear on screen.
- This would require an array of oncoming attacks, or that they spawn farther off-screen than now.
- - The pausing to introduce challenges often creates awkward situations and death.
- Maybe just give instructions on start screen instead. Or just show arrow pointing in the direction.
+ - Relaxed collision detection.
- Music
- Sound effects. Or skip this - too hard to make a coherent soundscape. maybe just music instead.
- Title, description, hashtags, icon and banner image.
- */
+ */
var ArrowVolley = Container.expand(function () {
var self = Container.call(this);
//var assetTypes = ['snacks', 'snacks2', 'snacks3', 'snacks4', 'snacks5', 'snacks6', 'snacks7'];
//var randomAsset = assetTypes[Math.floor(Math.random() * assetTypes.length)];
@@ -305,29 +302,50 @@
};
});
var PointerArrow = Container.expand(function () {
var self = Container.call(this);
- var collectibleGraphics = self.attachAsset('arrowUp', {
+ var t2 = self.attachAsset('arrowUp', {
anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.2,
+ scaleY: 1.1,
+ tint: '#000000'
+ });
+ var t = self.attachAsset('arrowUp', {
+ anchorX: 0.5,
anchorY: 0.5
});
self.alpha = 0;
+ self.moveX = 0;
+ self.moveY = 0;
self.x = 2048 / 2;
self.y = 2732 / 2;
self.update = function () {};
self.showPointer = function (direction) {
if (direction == 'up') {
self.rotation = 0;
+ self.moveY = -10;
} else if (direction == 'right') {
self.rotation = Math.PI / 2;
+ self.moveX = 10;
} else if (direction == 'down') {
self.rotation = Math.PI;
+ self.moveY = 10;
}
self.alpha = 1;
LK.setTimeout(function () {
//do something here
- }, 1000);
+ self.moveX = 0;
+ self.moveY = 0;
+ self.alpha = 0;
+ self.x = 2048 / 2;
+ self.y = 2732 / 2;
+ }, 500);
};
+ self.update = function () {
+ self.x += self.moveX;
+ self.y += self.moveY;
+ };
});
var ScoreSign = Container.expand(function (scoreAmount) {
var self = Container.call(this);
var scoreSignGraphics = new Text2('+' + scoreAmount, {
@@ -422,8 +440,22 @@
/****
* Game Code
****/
+/**
+* Function to determine if two objects are colliding more than a specified value.
+* @param {Object} obj1 - The first object.
+* @param {Object} obj2 - The second object.
+* @param {number} threshold - The minimum collision overlap value.
+* @returns {boolean} - True if the objects are colliding more than the threshold, false otherwise.
+*/
+function isCollidingMoreThan(obj1, obj2, threshold) {
+ // Calculate the overlap in the x and y directions
+ var overlapX = Math.max(0, Math.min(obj1.x + obj1.width, obj2.x + obj2.width) - Math.max(obj1.x, obj2.x));
+ var overlapY = Math.max(0, Math.min(obj1.y + obj1.height, obj2.y + obj2.height) - Math.max(obj1.y, obj2.y));
+ // Check if the overlap is greater than the threshold
+ return overlapX > threshold && overlapY > threshold;
+}
// Create and add score label to the top center of the screen
var scoreLabel = new Text2('0', {
size: 120,
fill: "#ffffff",
@@ -635,9 +667,9 @@
if (child.x <= -child.width) {
//child.x = 2048 + child.width;
child.destroy();
}
- if (child.intersects(player)) {
+ if (isCollidingMoreThan(child, player, 10)) {
LK.setScore(LK.getScore() + child.scoreVal);
scoreLabel.setText('' + LK.getScore());
// Show +10 sign
var scoreSign = new ScoreSign(child.scoreVal);
@@ -654,9 +686,9 @@
for (var i = obstacles.length - 1; i >= 0; i--) {
var child = obstacles[i];
child.x -= gameSpeed + gameSpeedBoost + child.speed;
//obstacles[i].update();
- if (child.intersects(player)) {
+ if (isCollidingMoreThan(child, player, 10)) {
if (child instanceof TallBarricade && player.dashing) {
if (!child.dead) {
child.breakApart();
LK.setScore(LK.getScore() + 50);
@@ -701,9 +733,10 @@
// Spawn new obstacles
if (unpausedClicks % 300 == 0) {
// 5 seconds at 60 FPS
var ran = Math.random();
- if (ran < 0.33 || !SPIKETRAP_SEEN) {
+ //if (ran < 0.33 || !SPIKETRAP_SEEN) {
+ if (ran < 0.33) {
var spikeTrap = new SpikeTrap();
spikeTrap.x = 2048 + spikeTrap.width;
spikeTrap.y = groundY;
game.addChild(spikeTrap);
@@ -711,11 +744,12 @@
if (!SPIKETRAP_SEEN) {
// plan delay to show swipe movement
//pauseAndShowInstructions(1);
pointerArrow.showPointer('up');
- SPIKETRAP_SEEN = true;
+ //SPIKETRAP_SEEN = true;
}
- } else if (ran < 0.66 || !PALLISADES_SEEN) {
+ //} else if (ran < 0.66 || !PALLISADES_SEEN) {
+ } else if (ran < 0.66) {
var barricade = new TallBarricade();
barricade.x = 2048 + barricade.width;
barricade.y = groundY - barricade.height / 2 + 450;
game.addChild(barricade);
@@ -723,9 +757,9 @@
if (!PALLISADES_SEEN) {
// plan delay to show swipe movement
//pauseAndShowInstructions(2);
pointerArrow.showPointer('right');
- PALLISADES_SEEN = true;
+ //PALLISADES_SEEN = true;
}
} else {
var volley = new ArrowVolley();
volley.x = 2048 + volley.width;
@@ -735,9 +769,9 @@
if (!ARROWS_SEEN) {
// plan delay to show swipe movement
//pauseAndShowInstructions(3);
pointerArrow.showPointer('down');
- ARROWS_SEEN = true;
+ //ARROWS_SEEN = true;
}
}
}
// Spawn new collectible every 30 ticks
A background illstration for a game, rich in style, medieval fantasy themed, of a landscape seen from a great distance, like froma mountain ridge with mountains and forests and lakes and lots of features.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A spritesheet with various poses for a heavily armored little dwarven warrior with an axe in various poses for use in an endless runner game. Te poses should include walking, eating, jumping, ducking low, and chargingforward. Sprites should be laid out in a rectangular grid wih blank space between them. Style should be medieval fantasy.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A game logo for a game called 'Endless Viking Run' using norse font on a background of a viking shield and crossed axes. Muted colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.