User prompt
// In WaterParticle class, modify init: self.init = function (type) { if (type === 'trail') { speed = Math.random() * 8 + 6; // Increased from 6 + 4 angle = Math.PI + (Math.random() * 0.4 - 0.2); // Slightly wider spread scale = 0.7; } else { // splash speed = Math.random() * 12 + 8; // Increased from 8 + 6 angle = -Math.PI/2 + (Math.random() * 1.4 - 0.7); // Wider arc spread scale = 1.2; } self.type = type; };
User prompt
// In Surfer class, modify createSplash function: function createSplash() { for (var i = 0; i < 50; i++) { // Increased from 30 to 50 particles game.particles.addWaterParticle(FIXED_X, self.y + 40, 'splash'); } }
User prompt
Update with: // In Surfer class, modify where we check for landing if (self.y > targetY && velocityY > 0) { let fallVelocity = velocityY; // Capture velocity before reset self.y = targetY; velocityY = 0; if (aboveWave && fallVelocity > 15) { // Only splash on significant falls createSplash(); } }
Code edit (1 edits merged)
Please save this source code
User prompt
Update with: self.update = function () { // Faster fade for splash particles scale -= (self.type === 'splash' ? 0.04 : 0.02); // Double fade speed for splash self.scaleX = scale; self.scaleY = scale; if (scale <= 0) { self.destroy(); } self.x += Math.cos(angle) * speed; self.y += Math.sin(angle) * speed; };
User prompt
Update with: // In WaterParticle class, modify init function: self.init = function (type) { if (type === 'trail') { // Trail particles stay the same speed = Math.random() * 6 + 4; angle = Math.PI + (Math.random() * 0.3 - 0.15); scale = 0.7; } else { // Splash particles - faster speed and higher arc speed = Math.random() * 8 + 6; // Increased base speed angle = -Math.PI/2 + (Math.random() * 1 - 0.5); // More upward angle scale = 1.2; // Slightly larger } };
User prompt
Update with: // In Surfer class, modify createSplash: function createSplash() { for (var i = 0; i < 30; i++) { // Move splash up by 40 to match trail Y position game.particles.addWaterParticle(FIXED_X, self.y + 40, 'splash'); } }
User prompt
Update with: function createSplash() { // Remove velocity check since we only call this when we want a splash for (var i = 0; i < 30; i++) { game.particles.addWaterParticle(FIXED_X, self.y, 'splash'); } }
User prompt
Update surfer with: // In Surfer's update function: var aboveWave = self.y < targetY; if (self.y > targetY && velocityY > 0) { self.y = targetY; velocityY = 0; if (aboveWave) { // Only create splash if we were above the wave createSplash(); } }
User prompt
Update as needed with: if (self.y > targetY && velocityY > 0) { self.y = targetY; velocityY = 0; // Reduce threshold if needed if (Math.abs(velocityY) > 5) { // Lower threshold createSplash(); } }
User prompt
Update as needed with: // In WaterParticle class, adjust trail behavior: self.init = function(type) { if (type === 'trail') { // Increase speed and adjust angle for longer trail speed = Math.random() * 6 + 4; // Faster base speed angle = Math.PI + (Math.random() * 0.3 - 0.15); // Tighter angle spread scale = 0.7; } else { speed = Math.random() * 3; angle = -Math.random() * Math.PI; scale = 1; } };
User prompt
Update as needed with: // In WaterParticle class, adjust trail behavior: self.init = function(type) { if (type === 'trail') { // Increase speed and adjust angle for longer trail speed = Math.random() * 6 + 4; // Faster base speed angle = Math.PI + (Math.random() * 0.3 - 0.15); // Tighter angle spread scale = 0.7; } else { speed = Math.random() * 3; angle = -Math.random() * Math.PI; scale = 1; } };
Code edit (1 edits merged)
Please save this source code
User prompt
Update with: self.addWaterParticle = function(x, y, type) { var particle = new WaterParticle(); if (type === 'trail') { // Move spawn point up and behind surfer particle.x = x + 100; // Spawn behind (to the right of) surfer particle.y = y + 40; // Raised up from previous +90 } else { // Keep original splash positioning particle.x = x + Math.random() * 130 - 40; particle.y = y + 90; } particle.init(type); self.addChild(particle); };
User prompt
Update with: // In Surfer's update function: self.update = function() { // ... existing physics code ... if (self.y > targetY && velocityY > 0) { self.y = targetY; velocityY = 0; createSplash(); // Only splash on landing } // Create trail particles when in contact with water if (self.y >= targetY && facekit.volume > 0.15) { createTrail(); } // ... rest of update code ... };
User prompt
Update surfer with: function createSplash() { if (Math.abs(velocityY) > 10) { for (var i = 0; i < 30; i++) { game.particles.addWaterParticle(FIXED_X, self.y, 'splash'); } } } function createTrail() { // Create fewer particles but more frequently for trail for (var i = 0; i < 3; i++) { game.particles.addWaterParticle(FIXED_X, self.y, 'trail'); } }
User prompt
Update with: var ParticleSystem = Container.expand(function() { var self = Container.call(this); self.addWaterParticle = function(x, y, type) { var particle = new WaterParticle(); particle.x = x + Math.random() * 130 - 40; particle.y = y + 90; particle.init(type); self.addChild(particle); }; self.update = function() { self.children.forEach(function(particle) { if (particle.update) { particle.update(); } }); }; return self; });
User prompt
Update with: var WaterParticle = Container.expand(function() { var self = Container.call(this); var particleGraphics = self.attachAsset('wave_point', { anchorX: 0.5, anchorY: 0.5 }); var speed = Math.random() * 3; var angle = -Math.random() * Math.PI; var scale = 1; // Add a type parameter to determine behavior self.init = function(type) { if (type === 'trail') { // Trail particles move left and slightly down speed = Math.random() * 4 + 2; angle = Math.PI + (Math.random() * 0.5 - 0.25); // Slightly varied left direction scale = 0.7; // Start smaller } else { // Splash particles go up and spread speed = Math.random() * 3; angle = -Math.random() * Math.PI; scale = 1; } }; self.update = function() { scale -= 0.02; self.scaleX = scale; self.scaleY = scale; if (scale <= 0) { self.destroy(); } self.x += Math.cos(angle) * speed; self.y += Math.sin(angle) * speed; }; return self; });
Code edit (1 edits merged)
Please save this source code
User prompt
Update as needed with: var ParticleSystem = Container.expand(function() { var self = Container.call(this); self.addWaterParticle = function(x, y) { var particle = new WaterParticle(); particle.x = x + Math.random() * 130 - 40; particle.y = y + 90; // Match Bawk Bawk's offset self.addChild(particle); }; self.update = function() { self.children.forEach(function(particle) { if (particle.update) { particle.update(); } }); }; return self; }); // In Surfer class createSplash: function createSplash() { if (Math.abs(velocityY) > 10) { for (var i = 0; i < 30; i++) { // Call with the exact surfer position from the game world game.particles.addWaterParticle(FIXED_X, self.y); } } }
User prompt
Update with: // In ParticleSystem class, remove any auto-movement: var ParticleSystem = Container.expand(function() { var self = Container.call(this); self.addWaterParticle = function(x, y) { var particle = new WaterParticle(); // Use exact coordinates from surfer particle.x = x + Math.random() * 60 - 30; // Smaller spread around surfer particle.y = y; self.addChild(particle); }; self.update = function() { self.children.forEach(function(particle) { if (particle.update) { particle.update(); } }); }; return self; }); // In Surfer class, adjust where we create the splash: function createSplash() { if (Math.abs(velocityY) > 10) { for (var i = 0; i < 30; i++) { // Use surfer's exact position particles.addWaterParticle(self.x, self.y); } } }
User prompt
Update as needed with: // In ParticleSystem: self.addWaterParticle = function(x, y) { var particle = new WaterParticle(); // Match Bawk Bawk's positioning more closely particle.x = x - 50 + Math.random() * 100; // More spread particle.y = y + Math.random() * 20; // Slight vertical variation self.addChild(particle); }; // In Surfer's createSplash: function createSplash() { if (Math.abs(velocityY) > 10) { for (var i = 0; i < 30; i++) { // Increased to 30 like Bawk Bawk particles.addWaterParticle(self.x, self.y + 50); } } }
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: particles' in or related to this line: 'particles.update();' Line Number: 307
User prompt
Update surfer class with: function createSplash() { if (Math.abs(velocityY) > 10) { for (var i = 0; i < 10; i++) { particles.addWaterParticle(self.x, self.y + 90); } } }
User prompt
Add this: var ParticleSystem = Container.expand(function() { var self = Container.call(this); self.addWaterParticle = function(x, y) { var particle = new WaterParticle(); particle.x = x + Math.random() * 130 - 40; particle.y = y; self.addChild(particle); }; self.update = function() { self.children.forEach(function(particle) { if (particle.update) { particle.update(); } }); }; return self; });
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var facekit = LK.import("@upit/facekit.v1");
/****
* Classes
****/
var ParticleSystem = Container.expand(function () {
var self = Container.call(this);
self.addWaterParticle = function (x, y, type) {
var particle = new WaterParticle();
if (type === 'trail') {
// Move spawn point up and behind surfer
particle.x = x - 100; // Spawn behind (to the right of) surfer
particle.y = y + 40; // Raised up from previous +90
} else {
// Keep original splash positioning
particle.x = x + Math.random() * 130 - 40;
particle.y = y - 20;
}
particle.init(type);
self.addChild(particle);
};
self.update = function () {
self.children.forEach(function (particle) {
if (particle.update) {
particle.update();
}
});
};
return self;
});
var Surfer = Container.expand(function () {
var self = Container.call(this);
var BASE_GRAVITY = 1.5; // Reduced for smoother acceleration
var MAX_SPEED = 40; // Increased for longer falls
var DAMPENING = 0.98; // Less dampening for smoother motion
var WAVE_OFFSET = -30;
var FIXED_X = 2048 * 0.35;
var MAX_AIR_VELOCITY = -25; // Only applies when surfer is above wave
var velocityY = 0;
var velocityRot = 0;
var lastWaveY = 2732 * 0.85; // Match WaveSystem's baseY
var initialized = false;
var surferGraphics = self.attachAsset('surfer', {
anchorX: 0.5,
anchorY: 0.8
});
self.x = FIXED_X;
self.y = lastWaveY + WAVE_OFFSET; // Start at base wave height
self.setWaveSystem = function (ws) {
waveSystem = ws;
if (!waveSystem.points) {
waveSystem.points = [];
}
initialized = true;
};
self.update = function () {
if (!waveSystem) {
return;
}
var normalizedX = self.x / 2048;
var pointIndex = Math.floor(normalizedX * (waveSystem.points.length - 1));
var nextPointIndex = Math.min(pointIndex + 1, waveSystem.points.length - 1);
var progress = normalizedX * (waveSystem.points.length - 1) - pointIndex;
var currentPoint = waveSystem.points[pointIndex];
var nextPoint = waveSystem.points[nextPointIndex];
var targetY = currentPoint.y + (nextPoint.y - currentPoint.y) * progress + WAVE_OFFSET;
var waveRising = targetY < lastWaveY;
var aboveWave = self.y < targetY;
if (waveRising && !aboveWave) {
// Natural wave following - no limits when on the wave
velocityY = (targetY - self.y) * 0.2;
self.y += velocityY;
} else {
// In air or falling
velocityY += BASE_GRAVITY;
velocityY *= DAMPENING;
// Only cap velocity when above the wave
if (aboveWave && velocityY < MAX_AIR_VELOCITY) {
velocityY = MAX_AIR_VELOCITY;
}
self.y += velocityY;
if (self.y > targetY && velocityY > 0) {
var fallVelocity = velocityY; // Capture velocity before reset
self.y = targetY;
velocityY = 0;
if (aboveWave && fallVelocity > 15) {
// Only splash on significant falls
createSplash();
}
}
}
lastWaveY = targetY;
// Create trail particles when in contact with water
if (self.y >= targetY && facekit.volume > 0.15) {
createTrail();
}
var targetAngle = Math.atan2(nextPoint.y - currentPoint.y, nextPoint.x - currentPoint.x);
// ... rest of the rotation code ...
particles.children.forEach(function (particle) {
if (particle.update) {
particle.update();
}
});
};
self.getScore = function () {
return Math.floor(score);
};
// Then in the Surfer class, replace the particle system with:
var particles = self.addChild(new ParticleSystem());
function createSplash() {
for (var i = 0; i < 50; i++) {
// Move splash up by 40 to match trail Y position
game.particles.addWaterParticle(FIXED_X, self.y + 40, 'splash');
}
}
function createTrail() {
// Create fewer particles but more frequently for trail
for (var i = 0; i < 3; i++) {
game.particles.addWaterParticle(FIXED_X, self.y, 'trail');
}
}
return self;
});
var WaterParticle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('wave_point', {
anchorX: 0.5,
anchorY: 0.5
});
var speed = Math.random() * 3;
var angle = -Math.random() * Math.PI;
var scale = 1;
// Add a type parameter to determine behavior
self.init = function (type) {
if (type === 'trail') {
speed = Math.random() * 8 + 6; // Increased from 6 + 4
angle = Math.PI + (Math.random() * 0.4 - 0.2); // Slightly wider spread
scale = 0.7;
} else {
//{N} // splash
speed = Math.random() * 12 + 8; // Increased from 8 + 6
angle = -Math.PI / 2 + (Math.random() * 1.4 - 0.7); // Wider arc spread
scale = 1.2;
}
};
self.update = function () {
scale -= self.type === 'splash' ? 0.04 : 0.02; // Double fade speed for splash
self.scaleX = scale;
self.scaleY = scale;
if (scale <= 0) {
self.destroy();
}
self.x += Math.cos(angle) * speed;
self.y += Math.sin(angle) * speed;
};
return self;
});
var WaveSystem = Container.expand(function () {
var self = Container.call(this);
var NUM_POINTS = 40;
var SCREEN_WIDTH = 2048;
var points = [];
var baseY = 2732 * 0.85;
var MIN_PITCH = 50;
var MAX_PITCH = 300;
var WAVE_HEIGHT = 2300;
var lastPitch = 0;
// Enhanced smoothing system
var heightBuffer = Array(15).fill(0);
var bufferIndex = 0;
var lastSmoothedHeight = 0;
// Water fill rectangles
var waterRects = [];
var NUM_WATER_SECTIONS = 80; // Significantly more sections
for (var i = 0; i < NUM_WATER_SECTIONS; i++) {
var rect = self.attachAsset('wave_line', {
anchorX: 0.5,
// Center anchor
anchorY: 0,
// Top anchor
height: 2732,
width: SCREEN_WIDTH / NUM_WATER_SECTIONS + 1,
// Tiny overlap to prevent pixel gaps
tint: 0x0066cc,
alpha: 0.3
});
waterRects.push(rect);
}
// Create wave line segments
var lines = [];
for (var i = 0; i < NUM_POINTS - 1; i++) {
var line = self.attachAsset('wave_line', {
anchorX: 0,
anchorY: 0.5,
height: 4
});
lines.push(line);
}
function gaussianCurve(x) {
return Math.exp(-(x * x) / 0.8);
}
function getSmoothedHeight(newHeight) {
heightBuffer[bufferIndex] = newHeight;
bufferIndex = (bufferIndex + 1) % heightBuffer.length;
var total = 0;
var weightTotal = 0;
for (var i = 0; i < heightBuffer.length; i++) {
var age = (bufferIndex - i + heightBuffer.length) % heightBuffer.length;
var weight = (heightBuffer.length - age) / heightBuffer.length;
total += heightBuffer[i] * weight;
weightTotal += weight;
}
var averageHeight = total / weightTotal;
var smoothedHeight = lastSmoothedHeight * 0.7 + averageHeight * 0.3;
lastSmoothedHeight = smoothedHeight;
return smoothedHeight;
}
self.update = function () {
var targetPitch = 0;
if (facekit.volume > 0.15) {
var normalizedPitch = (facekit.pitch - MIN_PITCH) / (MAX_PITCH - MIN_PITCH);
normalizedPitch = Math.max(0, Math.min(1, normalizedPitch));
targetPitch = normalizedPitch * 0.8 + lastPitch * 0.2;
}
lastPitch += (targetPitch - lastPitch) * 0.2;
var smoothedHeight = getSmoothedHeight(lastPitch * WAVE_HEIGHT);
if (facekit.volume > 0.15) {
score += smoothedHeight / WAVE_HEIGHT * multiplier;
multiplier += 0.001;
} else {
multiplier = Math.max(1, multiplier - 0.01);
}
points = [];
for (var i = 0; i < NUM_POINTS; i++) {
var x = i / (NUM_POINTS - 1) * SCREEN_WIDTH;
var distanceFromCenter = (x - SCREEN_WIDTH * 0.35) / (SCREEN_WIDTH * 0.45);
var heightFactor = gaussianCurve(distanceFromCenter);
var y = baseY - smoothedHeight * heightFactor;
points.push({
x: x,
y: y
});
}
// Update water rectangles
for (var i = 0; i < NUM_WATER_SECTIONS; i++) {
var rect = waterRects[i];
var xPosition = i / NUM_WATER_SECTIONS * SCREEN_WIDTH;
// Match x positions exactly with wave points
var exactPointPosition = xPosition / SCREEN_WIDTH * (NUM_POINTS - 1);
var pointIndex = Math.floor(exactPointPosition);
var nextPointIndex = Math.min(pointIndex + 1, NUM_POINTS - 1);
// Precise interpolation
var progress = exactPointPosition - pointIndex;
var y1 = points[pointIndex].y;
var y2 = points[nextPointIndex].y;
var y = y1 + (y2 - y1) * progress;
// Align exactly with wave position
rect.x = xPosition;
rect.y = y;
rect.height = 2732 - y;
// Very subtle alpha variation
rect.alpha = 0.3 + Math.sin(LK.ticks * 0.02 + i * 0.2) * 0.02;
}
self.points = points;
// Update wave line segments
for (var i = 0; i < lines.length; i++) {
var start = points[i];
var end = points[i + 1];
var dx = end.x - start.x;
var dy = end.y - start.y;
var length = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx);
lines[i].x += (start.x - lines[i].x) * 0.3;
lines[i].y += (start.y - lines[i].y) * 0.3;
lines[i].width += (length - lines[i].width) * 0.3;
var angleDiff = angle - lines[i].rotation;
if (angleDiff > Math.PI) {
angleDiff -= Math.PI * 2;
}
if (angleDiff < -Math.PI) {
angleDiff += Math.PI * 2;
}
lines[i].rotation += angleDiff * 0.3;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var score = 0; // Initialize score variable
var multiplier = 1;
var lastWaveHeight = 0;
var waveSystem = game.addChild(new WaveSystem());
var particles = new ParticleSystem();
game.particles = game.addChild(new ParticleSystem());
var surfer = game.addChild(new Surfer());
surfer.setWaveSystem(waveSystem);
var scoreText = new Text2("", {
size: 70,
fill: 0xFFFFFF
});
scoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreText);
var multiplierText = new Text2("", {
size: 40,
fill: 0xFFFFFF,
alpha: 0.8
});
multiplierText.anchor.set(1, 1);
LK.gui.bottomRight.addChild(multiplierText);
// Game update function
game.update = function () {
waveSystem.update();
surfer.update(); // Add this line
particles.update();
scoreText.setText(Math.floor(score).toLocaleString());
multiplierText.setText("x" + multiplier.toFixed(1));
}; ===================================================================
--- original.js
+++ change.js
@@ -136,17 +136,16 @@
var scale = 1;
// Add a type parameter to determine behavior
self.init = function (type) {
if (type === 'trail') {
- // Trail particles stay the same
- speed = Math.random() * 6 + 4;
- angle = Math.PI + (Math.random() * 0.3 - 0.15);
+ speed = Math.random() * 8 + 6; // Increased from 6 + 4
+ angle = Math.PI + (Math.random() * 0.4 - 0.2); // Slightly wider spread
scale = 0.7;
} else {
- // Splash particles - faster speed and higher arc
- speed = Math.random() * 8 + 6; // Increased base speed
- angle = -Math.PI / 2 + (Math.random() * 1 - 0.5); // More upward angle
- scale = 1.2; // Slightly larger
+ //{N} // splash
+ speed = Math.random() * 12 + 8; // Increased from 8 + 6
+ angle = -Math.PI / 2 + (Math.random() * 1.4 - 0.7); // Wider arc spread
+ scale = 1.2;
}
};
self.update = function () {
scale -= self.type === 'splash' ? 0.04 : 0.02; // Double fade speed for splash
A surfer standing and riding on a surfboard. Side profile. Cartoon. Full body. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A peaked blue rock. Cartoon style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Poseidon’s face. Cartoon style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
An opened pair of lips as if singing . Light Skin color. Cell shading vector art style. Facing forward. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A tropical fish. Cartoon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows