Compare commits

..

2 Commits

Author SHA1 Message Date
a3ef6f5328 floating tile detection 2024-12-04 16:17:31 +01:00
32ccd05d9d kleine änderungen 2024-12-04 12:17:13 +01:00
8 changed files with 1680 additions and 17 deletions

View File

@@ -66,6 +66,8 @@ func trigger_explosion():
# Destroy tiles in the explosion radius
destroy_tiles_in_explosion_area()
tile_map_layer.detect_and_make_tiles_fall()
# Start the timer to cleanup the explosion
timer.start()

41
export_presets.cfg Normal file
View File

@@ -0,0 +1,41 @@
[preset.0]
name="Web"
platform="Web"
runnable=true
advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="../export/Bomber-Thorsten.html"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
[preset.0.options]
custom_template/debug=""
custom_template/release=""
variant/extensions_support=false
variant/thread_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
progressive_web_app/enabled=false
progressive_web_app/ensure_cross_origin_isolation_headers=true
progressive_web_app/offline_page=""
progressive_web_app/display=1
progressive_web_app/orientation=0
progressive_web_app/icon_144x144=""
progressive_web_app/icon_180x180=""
progressive_web_app/icon_512x512=""
progressive_web_app/background_color=Color(0, 0, 0, 1)

View File

@@ -11,23 +11,31 @@ script = ExtResource("1_p5ww4")
[node name="PlayerList" type="VBoxContainer" parent="."]
layout_mode = 0
offset_left = 33.0
offset_top = 54.0
offset_right = 73.0
offset_bottom = 94.0
offset_left = 531.0
offset_top = 168.0
offset_right = 648.0
offset_bottom = 382.0
[node name="StartButton" type="Button" parent="."]
layout_mode = 2
offset_left = 370.0
offset_top = 165.0
offset_right = 416.0
offset_bottom = 196.0
offset_left = 516.0
offset_top = 464.0
offset_right = 666.0
offset_bottom = 511.0
text = "Start"
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_left = 155.0
offset_top = 31.0
offset_right = 292.0
offset_bottom = 54.0
offset_left = 514.0
offset_top = 88.0
offset_right = 651.0
offset_bottom = 111.0
text = "Bomber-Thorsten"
[node name="Label2" type="Label" parent="."]
layout_mode = 0
offset_left = 530.0
offset_top = 614.0
offset_right = 660.0
offset_bottom = 637.0
text = "www.it-thaler.de"

758
mai5410.tmp Normal file

File diff suppressed because one or more lines are too long

758
mai9FEE.tmp Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@ extends RigidBody2D
@export var speed = 400
@export var Bomb = load("res://bomb.tscn")
@export var max_power = 1000 # Maximum throw power
@export var charge_rate = 500 # Power increase per second
@export var charge_rate = 900 # Power increase per second
@export var line_start_offset = 30 # Distance from the player where the line starts (in pixels)
@export var gravity = 800.0 # Gravity force (pixels per second squared)

94
tile_map_layer.gd Normal file
View File

@@ -0,0 +1,94 @@
extends TileMapLayer
# Detect and make tiles fall
func detect_and_make_tiles_fall():
var all_tiles = get_used_cells()
var grounded_tiles = get_grounded_tiles()
print("Grounded tiles:", grounded_tiles)
var floating_tiles = []
for tile in all_tiles:
if tile not in grounded_tiles:
floating_tiles.append(tile)
print("Floating tiles:", floating_tiles)
for tile_pos in floating_tiles:
make_tile_fall(tile_pos)
# Returns all the grounded tiles (tiles connected to the bottom-most tiles)
func get_grounded_tiles() -> Array:
var grounded_tiles = []
var bottom_y = get_bottom_y() # Identify the bottom-most y coordinate
print("Bottom y:", bottom_y)
# Get all tiles at the bottom-most y-coordinate
var bottom_tiles = []
for tile in get_used_cells():
if tile.y == bottom_y:
bottom_tiles.append(tile)
print("Bottom tiles:", bottom_tiles)
# Traverse all tiles connected to the bottom-most tiles (iteratively)
var visited = {} # Dictionary to track visited tiles
var queue = bottom_tiles.duplicate() # Initialize the queue with bottom-most tiles
while queue.size() > 0:
var current = queue.pop_front() # Get the next tile to process
# Skip if already visited
if visited.has(current):
continue
visited[current] = true # Mark as visited
grounded_tiles.append(current) # Add to grounded tiles
# Check neighboring tiles (up, down, left, right)
var neighbors = [
current + Vector2i(1, 0), # Right
current + Vector2i(-1, 0), # Left
current + Vector2i(0, 1), # Down (already checked for bottom-most)
current + Vector2i(0, -1) # Up
]
for neighbor in neighbors:
if has_tile(neighbor) and not visited.has(neighbor):
queue.append(neighbor) # Add unvisited neighboring tile to the queue
return grounded_tiles
# Function to get the lowest y-coordinate of tiles in the map
func get_bottom_y() -> int:
var bottom_y = -1
for tile in get_used_cells():
if tile.y > bottom_y:
bottom_y = tile.y # Keep track of the largest y value (lowest tile)
return bottom_y
# Check if a specific tile exists at the given coordinates
func has_tile(coords: Vector2i) -> bool:
return get_cell_source_id(coords) != -1
# Make a tile fall by erasing it and placing it below
func make_tile_fall(coords: Vector2i) -> void:
var source_id = get_cell_source_id(coords) # Get the source ID of the tile
var atlas_coords = get_cell_atlas_coords(coords) # Get the atlas coordinates
var below_coords = coords + Vector2i(0, 1) # Position where the tile will fall
# Erase the current tile
erase_cell(coords)
# Place the tile one step below
#set_cell(below_coords, source_id, atlas_coords)
func _ready():
# Automatically call the function to test it when the scene runs
detect_and_make_tiles_fall()