I need some helpI

Hello!

you are trying to generate with a single expression, a generation with rules. that is impossible. procedural generation, 99% of times, require many steps (even if the rule seems simple).

quick explanation

to guarantee an offset, between the previous platform (assuming you also don’t want platforms spawning outside of screen), you must first establish how much space is to the left, and how much space is to the right. then → you need to choose between either section. and then ->now choosing a random number in the range of the chosen section (plus the offset):

step by step -----------

step 1) store ranges inside variables (i assume an offset of 400 here)

  • range B = max(0, (screen_width - (previous_plat_X + 400)))
  • range A = max(0, (previous_plat_X - 400))

step 2) choose between either ranges (ponderated)

  • randomIRange(0, (range_A + range_B))
  • if this result is greater than range A, choose range B

step 3) place at position

  • create platform at X position: randomIRange(0, chosen_range) + offset
    (note: offset is -400 for A, and 400 for B)

also, side note:

you are using collision between player and platform to spawn a platform?
doesn’t that create issues with many platforms being created at the same y? (imagine jumping on the same platform many times)

just thinkin’


also, another side note:

your full creation range is 900 (990 - 90), your offset is 600 in either directions, that means potentially 1200 px are unusable (which is greater than the range!!!). sometimes no platform could be created.

consider reducing the offset to 200

He has variables set up to prevent this btw

I was wondering, no offense, if you were a bot, your answer looks so perfectly formatted and structured. If you are not, I believe you, hope you werent offended!

haha!

is that a complinsult?

or should i say… insupliment?

:alien_monster: :alien: :eye_in_speech_bubble:

yeah I guess, well done for making neat and tidy structured answers, most people can’t be bothered!

Thanks for the help!

I tried implementing this system. It worked, but it produced somewhat repetitive patterns. While playing, you can notice that you’ve already done this part before, and it’s just a repeat of the same platform arrangement. So, I tried another approach. The method I used is also a bit monotonous, but it’s simpler.

Regarding your note: ‘you are using collision between player and platform to spawn a platform? doesn’t that create issues with many platforms being created at the same y? (imagine jumping on the same platform many times)’

I made the platforms have an instance variable. When a platform appears on the screen, its value is 1. If the player stands on it, it becomes 0.

Event 1
Conditions:
1 - Platform is in collision with Player.
2 - Player is on the platform.
3 - Platform instance variable value = 1.

Actions:
1 - Change the platform instance variable value to 0 (to avoid spawning more than one platform when jumping on the same platform multiple times).
2 - Generate a random number between 90 and 990 for the X-axis and store it in the variable newX (to determine the X position of the platform to be spawned).

nice. its a pleasure to help

if you love your method, keep your method.


interesting that you addressed the first side note but not the second.

you still have a range of 900 pixel. and the dead zone is 440 in each direction 440*2 = 880. i understand that most of the time, the platform isn’t at the center → meaning that the dead zone doesn’t completely take away from the possible range. still, you remove a large chunk of the randomness: this explains the repetitiveness.


but as i said, if youre happy, youre happy.