Hi, I have a problem because I want to create hills like the ones in Hill Climb Racing. Does anyone have a ready-made project featuring that kind of generation, or a screenshot of the code?
~Translated by Google Translator
Hi, I have a problem because I want to create hills like the ones in Hill Climb Racing. Does anyone have a ready-made project featuring that kind of generation, or a screenshot of the code?
~Translated by Google Translator
would marching squares help?
just a thought
this discussion might help.
IMO… its not the generation that is difficult, its the collision.
my mind tells me thst its either marching squares or just using quadratic curves. though for the curves, you gotta manage collision yourself
hills climb rancing has bezier curve ground. (the ground is smoothly curved)
To everyone who wanted to help: You didn’t quite understand what I meant. I wanted to create hills like the ones in Hill Climb Racing—just the hills themselves. The game I’m making doesn’t require collision detection; I’m just looking for smooth curves.
But IMO, collisions would be useful—for detection purposes.
And for those curious about the game I’m making: it’s about a train that’s moving and… something else, but I can’t say what ![]()
then you can simply use shape painter to draw the curves. Shape painter - GDevelop documentation
also… I made an extension that allows you to visually draw the curve inside the runtimescene (the preview). but my extension returns an SVG command to be used for the “curved path movement extension”
the easiest is to just plot draggable object inside the parameters of the action that draws the curve (of the shape painter). then… drag them to see the curve that you want.
I just tried doing it—thought it would be smoother in JS—but I don’t know JS. I used ChatGPT and it gave me some code; it works in theory, but it’s incredibly buggy.
const terrain = runtimeScene.getObjects("Terrain")[0];
const points = runtimeScene.getObjects("TerrainPoint");
const speed = 5;
const stepX = 2560;
// ===== 1. PRZESUW =====
for (const p of points) {
p.setX(p.getX() - speed);
}
// ===== 2. ZNAJDĹą NAJLEWY I NAJPRAWY =====
let leftMost = points[0];
let rightMost = points[0];
for (const p of points) {
if (p.getX() < leftMost.getX()) leftMost = p;
if (p.getX() > rightMost.getX()) rightMost = p;
}
// ===== 3. TELEPORT (ODPINANIE + PRZYPINANIE) =====
if (leftMost.getX() < -500) {
const newY = Math.max(120, Math.min(650,
rightMost.getY() + (Math.random() * 180 - 90)
));
leftMost.setX(rightMost.getX() + stepX);
leftMost.setY(newY);
}
// ===== 4. RYSOWANIE W DOBREJ KOLEJNOĹšCI =====
terrain.clear();
terrain.beginFillPath();
terrain.setOutlineColor("255;255;255");
terrain.setOutlineSize(6);
// zawsze sort tylko do rysowania
const sorted = [...points].sort((a, b) => a.getX() - b.getX());
terrain.drawPathMoveTo(sorted[0].getX(), sorted[0].getY());
for (let i = 1; i < sorted.length; i++) {
terrain.drawPathLineTo(sorted[i].getX(), sorted[i].getY());
}
terrain.endFillPath();
every TerraiPoint have Variable Point, They are numbered 1, 2, 3, and 4 respectively, and their positions are:
1 - 0, 360
2 - 2560, 360
3 - 5120, 360
4 - 7680, 360
Idk if that helps.<3
if that helps who? youre the one making the post
are you saying that you have solved your problem? i’m confused
have you tried it? does it work?