Code edit (2 edits merged)
Please save this source code
User prompt
givethe driver x & y coordinates so I can edit it position
User prompt
create a new asset called Driver and place it the the bottom left side of the screen
User prompt
Fix Bug: 'ReferenceError: mainContainer is not defined' in this line: 'self.notificationText.y = self.y + mainContainer.y + 200;' Line Number: 63
User prompt
Fix Bug: 'ReferenceError: mainContainer is not defined' in this line: 'self.notificationText.x = self.x + mainContainer.x;' Line Number: 62
User prompt
the notifications still dont follow the car. I cant see them over the car :(
User prompt
Fix Bug: 'ReferenceError: mainContainer is not defined' in this line: 'self.notificationText.y = self.y + mainContainer.y + 200;' Line Number: 63
User prompt
Fix Bug: 'ReferenceError: mainContainer is not defined' in this line: 'self.notificationText.x = self.x + mainContainer.x;' Line Number: 62
User prompt
I still cant see the text for the notification. at the start of the game I see maybe a bit of it at the right side of the screen than cant see it anymore, somethign ir wrong with its position
User prompt
the notification text is not visible, move it to the very center of the car, it should appear at the same point as the car
User prompt
I still cant see the notification
Code edit (2 edits merged)
Please save this source code
User prompt
I cant see the notifications, maybe you are displaying them too far away from the car, move them closer to the car's asset
User prompt
Fix Bug: 'ReferenceError: notificationText is not defined' in this line: 'notificationText.x = car.x + mainContainer.x;' Line Number: 195
User prompt
Fix Bug: 'ReferenceError: notificationText is not defined' in this line: 'notificationText.setText(notificationTexts[Math.floor(Math.random() * notificationTexts.length)]);' Line Number: 193
User prompt
Fix Bug: 'Uncaught ReferenceError: notificationTexts is not defined' in this line: 'self.notificationText = new Text2(notificationTexts[Math.floor(Math.random() * notificationTexts.length)], {' Line Number: 24
User prompt
the notifications still dont follow the car, they need to appear above the car and remain there as the car moves
User prompt
the notifications are currently remaining in the place they were generated, they need to follow the car
User prompt
the notification should follow the car, not remain behind it
User prompt
instead of having the notifications stuck to the screen, make them come out of the car. they should appear above the car
Code edit (1 edits merged)
Please save this source code
User prompt
make the notification text outline stronger
User prompt
the undernotification asset is a property of the notification text, thus is should always appear under the text. it's part of the UI. right now it remains stuck to the ground
User prompt
I cant see the asset under the notification text. ensure it is under the text but above the road
User prompt
add an asset under the notification text layer
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.createAsset('particle', 'Car Trail Particle', 0.5, 0.5);
particleGraphics.rotation = Math.PI / 4;
self.lifetime = 100;
self.tick = function () {
if (--self.lifetime <= 0) self.destroy();
};
});
var Car = Container.expand(function () {
var self = Container.call(this);
self.projectMovement = function (vector) {
var angle = -Math.PI / 4;
var cosAngle = Math.cos(angle);
var sinAngle = Math.sin(angle);
return {
x: vector.x * cosAngle - vector.y * sinAngle,
y: vector.x * sinAngle + vector.y * cosAngle
};
};
var carGraphics = self.createAsset('car', 'Drifting Car', .5, .5);
self.ORIGINAL_SPEED = 2;
self.speed = self.ORIGINAL_SPEED;
self.direction = 0;
self.momentum = {
x: 0,
y: 0
};
self.move = function () {
var momentumModifier = 0.1;
self.speed *= 1.01;
if (self.direction === 0) {
self.momentum.x += self.speed * momentumModifier;
} else {
self.momentum.y -= self.speed * momentumModifier;
}
var projectedMovement = self.projectMovement(self.momentum);
self.x += projectedMovement.x;
self.y += projectedMovement.y;
var nonTravelMomentum;
if (self.direction === 0) {
self.momentum.x *= 0.98;
self.momentum.y *= 0.95;
nonTravelMomentum = self.momentum.y;
} else {
self.momentum.x *= 0.95;
self.momentum.y *= 0.98;
nonTravelMomentum = self.momentum.x;
}
self.nonTravelMomentum = nonTravelMomentum;
};
self.changeDirection = function () {
self.direction = self.direction === 0 ? 1 : 0;
self.speed = self.ORIGINAL_SPEED;
carGraphics.scale.x *= -1;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.calculateDistanceToPoint = function (point, segmentStart, segmentEnd) {
var A = point.x - segmentStart.x;
var B = point.y - segmentStart.y;
var C = segmentEnd.x - segmentStart.x;
var D = segmentEnd.y - segmentStart.y;
var dot = A * C + B * D;
var len_sq = C * C + D * D;
var param = -1;
if (len_sq != 0) {
param = dot / len_sq;
}
var xx, yy;
if (param < 0) {
xx = segmentStart.x;
yy = segmentStart.y;
} else if (param > 1) {
xx = segmentEnd.x;
yy = segmentEnd.y;
} else {
xx = segmentStart.x + param * C;
yy = segmentStart.y + param * D;
}
var dx = point.x - xx;
var dy = point.y - yy;
return Math.sqrt(dx * dx + dy * dy);
};
self.addRoadSegment = function () {
var lastSegment = roadSegments[roadSegments.length - 1];
zigzag = !zigzag;
var segment = roadContainer.createAsset('roadSegment', 'Road Segment', 0.5, 0);
segment.width = segmentWidth;
segmentWidth = Math.max(350, segmentWidth - 15);
segment.height = i === 1 ? 3000 : Math.floor(Math.random() * (4000 - 1200 + 1)) + 1200;
segment.rotation = zigzag ? -Math.PI - Math.PI / 4 : -Math.PI + Math.PI / 4;
segment.y = currentY;
segment.x = currentX;
var adjustedHeight = segment.height - segmentWidth / 2;
currentY += adjustedHeight * Math.cos(segment.rotation);
currentX -= adjustedHeight * Math.sin(segment.rotation);
segment.shadow = roadContainer.createAsset('roadSegmentShadow', 'Road Segment Shadow', 0.5, 0);
segment.shadow.width = segment.width;
segment.shadow.height = segment.height;
segment.shadow.rotation = segment.rotation;
segment.shadow.x = segment.x;
segment.shadow.y = segment.y + 50;
segment.shadow.alpha = 1;
segment.used = false;
roadSegments.push(segment);
roadContainer.addChildAt(segment.shadow, 0);
roadContainer.addChild(segment);
};
LK.stageContainer.setBackgroundColor(0xc39977);
var particles = [];
var mainContainer = self.addChild(new Container());
var roadContainer = mainContainer.addChild(new Container());
var roadSegments = [];
var segmentLength = Math.floor(Math.random() * (1000 - 200 + 1)) + 200;
var segmentWidth = 1200;
var currentX = 2048 / 2;
var currentY = 2732 / 2;
var zigzag = true;
for (var i = 1; i <= 15; i++) {
self.addRoadSegment();
}
var scoreText = new Text2('0', {
size: 150,
fill: "#ffffff",
weight: '800',
dropShadow: true,
dropShadowColor: '#373330',
dropShadowBlur: 4,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6
});
scoreText.anchor.set(0.5, 0);
LK.gui.topCenter.addChild(scoreText);
var notificationTexts = ['Longing for her warm embrace', 'My love intensifies with each curve', 'Time slips away like smoke', 'Her voice echoes in my mind', 'Desperation sharpens every turn', 'Curves lead to her embrace', 'My passion grows with every turn', 'Time slips, but love persists', 'Desperation sharpens my every move', 'Reunion, the ultimate driving force', 'Is she waiting for me?', 'Where could she be?', 'Can I reach her in time?', 'Will she smile when I arrive?', 'Does she know I am coming?', 'Her embrace is my reward', 'Does she still remember me?', 'Will I see love in her eyes?', 'Does she feel my urgency?', 'Will our love grow stronger?', 'Her voice my guiding star', 'Do I still hold her heart?', 'Can I reach her in time?', 'Does she still believe in us?', 'Will our love conquer all?', 'How fast can I go?', 'Can I push my limits?', 'Will speed get me there?', 'Is haste my driving force?', 'Can I outpace the clock?', 'Is this a race against time?', 'Will acceleration save us?', 'Am I in the fast lane?', 'Can I set a new record?', 'Do I thrive on speed?', 'Will I leave time behind?', 'Am I the fastest driver?', 'Can I reach her swiftly?', 'Loves urgency fuels my speed'];
var notificationText = new Text2(notificationTexts[Math.floor(Math.random() * notificationTexts.length)], {
size: 60,
fill: "#ffffff",
weight: '400',
align: 'center',
stroke: '#000000',
strokeThickness: 4
});
var underNotificationAsset = LK.getAsset('underNotification', 'Asset under notification text', 0.5, 0.5);
underNotificationAsset.x = 2048 / 2;
underNotificationAsset.y = 2732 / 2;
LK.gui.bottom.addChild(underNotificationAsset);
notificationText.anchor.set(0.5, 1.85);
LK.gui.bottom.addChild(notificationText);
var car = mainContainer.addChild(new Car());
car.x = 2048 / 2;
car.y = 2732 / 2;
var isGameOver = false;
var score = 0;
var closestSegment = null;
stage.on('down', function (obj) {
car.changeDirection();
});
LK.on('tick', function () {
car.move();
var carIsOnRoad = false;
var carPosition = {
x: car.x,
y: car.y
};
var currentClosestSegment = null;
var currentClosestDistance = Infinity;
roadSegments.forEach(function (segment) {
var segmentStart = {
x: segment.x + Math.sin(segment.rotation) * 100,
y: segment.y - Math.cos(segment.rotation) * 100
};
var segmentEnd = {
x: segment.x - Math.sin(segment.rotation) * (segment.height - segment.width / 2),
y: segment.y + Math.cos(segment.rotation) * (segment.height - segment.width / 2)
};
var distance = self.calculateDistanceToPoint(carPosition, segmentStart, segmentEnd);
if (distance < currentClosestDistance) {
currentClosestDistance = distance;
currentClosestSegment = segment;
}
if (distance < segment.width / 2 - 50) {
carIsOnRoad = true;
}
});
if (closestSegment !== currentClosestSegment && !currentClosestSegment.used) {
closestSegment = currentClosestSegment;
closestSegment.used = true;
score++;
car.ORIGINAL_SPEED += 0.1;
scoreText.setText(score.toString());
if (score % 2 === 0) {
notificationText.setText(notificationTexts[Math.floor(Math.random() * notificationTexts.length)]);
}
}
if (!carIsOnRoad) {
LK.showGameOver();
} else {}
var particleOffsets = [{
x: 20,
y: 140
}, {
x: 20 + 100,
y: 140 - 100
}, {
x: 20 - 150,
y: 140 - 150
}, {
x: 20 - 150 + 100,
y: 140 - 150 - 100
}];
for (var i = 0; i < particleOffsets.length; i++) {
var alphaValue = Math.max(0, Math.min(1, Math.abs(car.nonTravelMomentum) / 5 - 0.5));
if (alphaValue > 0) {
var particle = new Particle();
particle.alpha = alphaValue;
var noiseX = (Math.random() - 0.5) * 10;
var noiseY = (Math.random() - 0.5) * 10;
particle.x = car.x + (car.direction === 0 ? -1 : 1) * particleOffsets[i].x + noiseX;
particle.y = car.y + particleOffsets[i].y + noiseY;
mainContainer.addChildAt(particle, 1);
particles.push(particle);
}
}
particles.forEach(function (particle, index) {
particle.tick();
if (particle.lifetime <= 0) {
particles.splice(index, 1);
}
});
var carLocalPosition = self.toLocal(car.position, car.parent);
var offsetX = (2048 / 2 - carLocalPosition.x) / 20;
var offsetY = (2732 - 450 - carLocalPosition.y) / 20;
mainContainer.x += offsetX;
mainContainer.y += offsetY;
for (var i = roadSegments.length - 1; i >= 0; i--) {
var segmentGlobalPosition = self.toLocal(roadSegments[i].position, roadSegments[i].parent);
if (segmentGlobalPosition.y - roadSegments[i].height > 2732 * 2) {
roadSegments[i].shadow.destroy();
roadSegments[i].destroy();
roadSegments.splice(i, 1);
self.addRoadSegment();
}
}
});
});
DeLorean car, seen from behind Top-down, gta2, Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.isometric
cool looking driver holding a car wheel as if he's driving. 30 years old. vintage retro 1980 style. 3/4 view. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.