Skip to content

Conversation

@Ymanawat
Copy link

This pull request adds a new demo project, showcasing dynamic level generation and endless arcade gameplay. The project is designed to demonstrate the use of procedural-level generation.

Demo made for v4.x

Pull request includes

  • Created a new directory procedural_platform_level_generator under the "2d" directory.
  • Added all project files, including scripts, assets, and scenes, required for the demo.
  • Implemented dynamic level generation using a grid-based (TileMap) approach.
  • Generated random lines and obstacles to create diverse and unpredictable levels.
  • Included dynamic tile management for optimal performance and memory usage.
  • Implemented collision detection for player and obstacle interactions.

Testing

  • Thoroughly tested the demo project to ensure smooth gameplay and level generation.
  • Verified that collision detection and obstacle placement are accurate.
  • Checked for any potential bugs or issues and fixed them as needed.

Screenshots / GIFs

Collision (1)
Dynamic_tile_generation

@Ymanawat Ymanawat force-pushed the platform_level_generation_godot_4 branch from 0409c3d to af6437b Compare July 22, 2023 17:20
@Calinou
Copy link
Member

Calinou commented Aug 23, 2023

This is a good start 🙂

I've made a branch based on your fork with further improvements to better match the existing visual style and code style: https://github.com/Calinou/godot-demo-projects/tree/platform_level_generation_godot_4
I still need to make some tweaks to it before it can be merged.

image

@Ymanawat
Copy link
Author

These visual improvements are much more intuitive. Can I help with any enhancements?

@Calinou
Copy link
Member

Calinou commented Aug 24, 2023

These visual improvements are much more intuitive. Can I help with any enhancements?

I can take it from here, but I won't be able to submit a PR soon as I'm busy with other tasks.

Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ymanawat @Calinou Is there interest to keep this PR going?

At a glance I'm not sure what the value is of this PR, since it doesn't really showcase a Godot feature, and so I'm leaning towards rejecting this PR. But maybe I'm just missing something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so many fonts? Ideally, we shouldn't use any fonts, and just use the default font from the engine.

Comment on lines +4 to +7
var camera_speed = 2 # the speed of the camera movement
var player
var target_pos
func _ready():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the GDScript style guide.

Please use static typing in the demos.

Please use snake_case for all file and folder names.

extends Camera2D


var camera_speed = 2 # the speed of the camera movement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var camera_speed = 2 # the speed of the camera movement
var camera_speed = 2 # The speed of the camera movement.

Per the comment style.

target_pos = Vector2(player.position.x+400, 200)

func _physics_process(delta):
# get the target position of the camera based on the player position and the offset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# get the target position of the camera based on the player position and the offset
# Get the target position of the camera based on the player position and the offset.

# get the target position of the camera based on the player position and the offset
if player!=null:
target_pos = Vector2(player.position.x+400, 200)
# lerp the current position of the camera to the target position with a smoothing factor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# lerp the current position of the camera to the target position with a smoothing factor
# Lerp the current position of the camera to the target position with a smoothing factor.

var camera_speed = 2 # the speed of the camera movement
var player
var target_pos
func _ready():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func _ready():
func _ready():

extends TextureRect

var player
# Called when the node enters the scene tree for the first time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Called when the node enters the scene tree for the first time.
# Called when the node enters the scene tree for the first time.

Two spaces before methods, as per the style guide


func generate_tiles():
while next_tile_position.x < (playerPosition.x + screenWidth):
var value = randi_range(1,5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var value = randi_range(1,5)
var value = randi_range(1, 5)

for i in range(value):
set_cell(0, local_to_map(next_tile_position), LineTileIndex, Vector2i(0,0))
next_tile_position.x += tile_size.x
set_cell(0, local_to_map(next_tile_position), PlateTileIndex, Vector2i(0,0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_cell(0, local_to_map(next_tile_position), PlateTileIndex, Vector2i(0,0))
set_cell(0, local_to_map(next_tile_position), PlateTileIndex, Vector2i(0, 0))

while next_tile_position.x < (playerPosition.x + screenWidth):
var value = randi_range(1,5)
for i in range(value):
set_cell(0, local_to_map(next_tile_position), LineTileIndex, Vector2i(0,0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_cell(0, local_to_map(next_tile_position), LineTileIndex, Vector2i(0,0))
set_cell(0, local_to_map(next_tile_position), LineTileIndex, Vector2i(0, 0))

# Obstacle indexed 1 tile
$"../Hit_sound".play()
set_cell(0, playerCellPos, -1)
emit_signal("score")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
emit_signal("score")
score.emit()

# Line indexed 0 tile
if not game_over_signal:
game_over_signal = true
emit_signal("game_over")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
emit_signal("game_over")
game_over.emit()

@aaronfranke aaronfranke marked this pull request as draft October 3, 2025 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants