initial commit

This commit is contained in:
2024-12-02 13:45:17 +01:00
commit 92aaadc783
33 changed files with 1392 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
/android/

BIN
assets/Bombe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

34
assets/Bombe.png.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ckdx8o2mm5ynf"
path="res://.godot/imported/Bombe.png-e2d1d6803d65265e9bb8e587ab92142a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/Bombe.png"
dest_files=["res://.godot/imported/Bombe.png-e2d1d6803d65265e9bb8e587ab92142a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/GrassHills.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dn60hfc3u10tv"
path="res://.godot/imported/GrassHills.png-44828e2864775c26e62cff2c789bc0e8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/GrassHills.png"
dest_files=["res://.godot/imported/GrassHills.png-44828e2864775c26e62cff2c789bc0e8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cd78of2wvcfyc"
path="res://.godot/imported/dungeon_tilesheet.png-25f61e428a1ee16565a9c7244a480ae6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/dungeon_tilesheet.png"
dest_files=["res://.godot/imported/dungeon_tilesheet.png-25f61e428a1ee16565a9c7244a480ae6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
assets/explosion.wav Normal file

Binary file not shown.

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bjukkr1crbdn5"
path="res://.godot/imported/explosion.wav-de00f2d0ef23a85998326fdf0ffd33ab.sample"
[deps]
source_file="res://assets/explosion.wav"
dest_files=["res://.godot/imported/explosion.wav-de00f2d0ef23a85998326fdf0ffd33ab.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ct3rmsru1s17x"
path="res://.godot/imported/untitled_0001.png-278bb31666ec1350d3e0373e121e64d2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/player1/untitled_0001.png"
dest_files=["res://.godot/imported/untitled_0001.png-278bb31666ec1350d3e0373e121e64d2.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://eqyoffrsod4i"
path="res://.godot/imported/untitled_0002.png-331492033f1ea5643a06ba9cc90f0d32.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/player1/untitled_0002.png"
dest_files=["res://.godot/imported/untitled_0002.png-331492033f1ea5643a06ba9cc90f0d32.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://lapvfkp8cf4r"
path="res://.godot/imported/untitled_0003.png-c67cd4819e061f7112c6eec872453b24.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/player1/untitled_0003.png"
dest_files=["res://.godot/imported/untitled_0003.png-c67cd4819e061f7112c6eec872453b24.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cktd41a7ky8p1"
path="res://.godot/imported/untitled_0004.png-c3fe4a789c37b37b5e014d45020fba8f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/player1/untitled_0004.png"
dest_files=["res://.godot/imported/untitled_0004.png-c3fe4a789c37b37b5e014d45020fba8f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cqmuysiqs2apc"
path="res://.godot/imported/untitled_0005.png-fc8b1323ecde8ef7c7fda0f1c8bd168f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/player1/untitled_0005.png"
dest_files=["res://.godot/imported/untitled_0005.png-fc8b1323ecde8ef7c7fda0f1c8bd168f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b4bn085jvlf4a"
path="res://.godot/imported/tilesheet_complete.png-5f14f2929ff3d9b1c136ce3cca4823a1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/tilesheet_complete.png"
dest_files=["res://.godot/imported/tilesheet_complete.png-5f14f2929ff3d9b1c136ce3cca4823a1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

144
bomb.gd Normal file
View File

@@ -0,0 +1,144 @@
extends RigidBody2D
@export var speed = 400
@export var explosion_damage = 2000
var velocity = Vector2.ZERO
var is_in_flight = false
var has_exploded = false # Flag to track if the bomb has exploded
@onready var sprite = $Sprite2D
@onready var collision = $CollisionShape2D
@onready var particles = $Explosion
@onready var explosion_sound = $AudioStreamPlayer2D
@onready var explosion_area = $ExplosionArea
@onready var timer = $Timer
@onready var camera = get_parent().get_parent().get_node("MultiTargetCamera")
@onready var tile_map_layer = get_parent().get_parent().get_node("TileMapLayer")
@export var off_screen_margin = 2000
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
camera.add_target(self)
global_position = position
z_index = -1
# Disable the particles and audio on start
particles.emitting = false
explosion_sound.playing = false
# Connect the timer's timeout signal to the cleanup function
timer.connect("timeout", _on_timeout)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if is_in_flight:
# Explode if the bomb goes off-screen
if is_off_screen() and not has_exploded:
trigger_explosion()
# Check for spacebar press to explode, only if the bomb hasn't exploded
if Input.is_action_just_pressed("throw_bomb") and not has_exploded:
trigger_explosion()
# This function is used to set the velocity of the bomb when its thrown
func set_velocity(new_velocity: Vector2) -> void:
# Apply an impulse based on the new velocity
apply_central_impulse(new_velocity)
is_in_flight = true
# Function to trigger the explosion
func trigger_explosion():
if has_exploded:
return # Prevent multiple explosions
# Set the flag to true, indicating that the bomb has exploded
has_exploded = true
camera.remove_target(self)
# Play the explosion sound
explosion_sound.play()
# Enable and emit the particles
particles.emitting = true
# Push away players within the explosion radius
push_away_players()
# Destroy tiles in the explosion radius
destroy_tiles_in_explosion_area()
# Start the timer to cleanup the explosion
timer.start()
sprite.hide()
func push_away_players():
if not explosion_area:
print("ExplosionArea2D is missing!")
return
var overlapping_bodies = explosion_area.get_overlapping_bodies()
print("Overlapping bodies:", overlapping_bodies)
for body in overlapping_bodies:
if body is RigidBody2D:
print("Pushing body:", body.name)
var direction = (body.global_position - global_position).normalized()
var impulse = direction * explosion_damage
body.apply_central_impulse(impulse)
func destroy_tiles_in_explosion_area():
var center = global_position # This is the center of the explosion in global coordinates
var radius = 30 # The radius of the explosion
# Convert center to map coordinates, taking scale into account
var map_center = tile_map_layer.local_to_map(center)
print("Center: ", map_center)
# Get the scale factor of the TileMapLayer
var scale = tile_map_layer.scale.x # Assuming uniform scale for both x and y
var tile_width = 16
var tile_height = 16
# Get the bounding box for the explosion area in map coordinates
var min_x = int((map_center.x - radius * tile_width) / tile_width)
var max_x = int((map_center.x + radius * tile_width) / tile_width)
var min_y = int((map_center.y - radius * tile_height) / tile_height)
var max_y = int((map_center.y + radius * tile_height) / tile_height)
# Loop through all cells in the bounding box
for x in range(min_x, max_x + 1):
for y in range(min_y, max_y + 1):
# Calculate distance from the center of the explosion (map coordinates)
var dist = map_center.distance_to(Vector2(x, y))
# Check if the tile is within the explosion radius (using the distance check)
if dist <= radius:
# Print out some debug information
print("Checking tile:", Vector2i(x, y), "Distance:", dist)
# Check if the tile is within the bounds of the map and not empty
if tile_map_layer.get_cell_source_id(Vector2i(x, y)) != -1:
# Erase the tile at coordinates (x, y) in map coordinates
tile_map_layer.erase_cell(Vector2i(x, y))
# Function to check if the bomb is off-screen
func is_off_screen() -> bool:
var screen_rect = Rect2(camera.position - camera.zoom * camera.get_viewport_rect().size / 2,
camera.zoom * camera.get_viewport_rect().size)
screen_rect = screen_rect.grow(off_screen_margin) # Expand the screen rectangle by the margin
return not screen_rect.has_point(global_position)
# Cleanup function called when the timer times out
func _on_timeout():
# Once the timer finishes, queue the particles for cleanup (optional)
particles.emitting = false
explosion_sound.stop() # Stop the sound if it's still playing
queue_free()

89
bomb.tscn Normal file
View File

@@ -0,0 +1,89 @@
[gd_scene load_steps=14 format=3 uid="uid://bbagt6u0i07qx"]
[ext_resource type="Script" path="res://bomb.gd" id="1_hkjew"]
[ext_resource type="Texture2D" uid="uid://ckdx8o2mm5ynf" path="res://assets/Bombe.png" id="2_e237x"]
[ext_resource type="AudioStream" uid="uid://bjukkr1crbdn5" path="res://assets/explosion.wav" id="3_oy301"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_tlmti"]
bounce = 0.8
[sub_resource type="CircleShape2D" id="CircleShape2D_mjow3"]
[sub_resource type="Curve" id="Curve_pwtqa"]
min_value = -360.0
max_value = 360.0
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.283, 180), 0.0, 0.0, 0, 0, Vector2(0.986, 250), 0.0, 1008.0, 0, 0]
point_count = 3
[sub_resource type="CurveTexture" id="CurveTexture_whpl5"]
curve = SubResource("Curve_pwtqa")
[sub_resource type="Gradient" id="Gradient_mjxym"]
offsets = PackedFloat32Array(0, 0.780488, 1)
colors = PackedColorArray(1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_uev6e"]
gradient = SubResource("Gradient_mjxym")
[sub_resource type="Curve" id="Curve_fapsh"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -1.28901, 1.4, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_6ssa4"]
curve = SubResource("Curve_fapsh")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_3c5ho"]
particle_flag_disable_z = true
emission_shape = 1
emission_sphere_radius = 5.0
angle_min = 1.07288e-05
angle_max = 45.0
angle_curve = SubResource("CurveTexture_whpl5")
spread = 180.0
initial_velocity_min = 75.0
initial_velocity_max = 125.0
gravity = Vector3(0, 0, 0)
scale_min = 4.0
scale_max = 5.0
scale_curve = SubResource("CurveTexture_6ssa4")
color_ramp = SubResource("GradientTexture1D_uev6e")
turbulence_noise_strength = 14.86
turbulence_noise_scale = 6.399
turbulence_noise_speed_random = 1.48
turbulence_influence_min = 0.056
turbulence_influence_max = 0.056
[sub_resource type="CircleShape2D" id="CircleShape2D_y1ra5"]
radius = 100.0
[node name="Bomb" type="RigidBody2D"]
collision_layer = 0
physics_material_override = SubResource("PhysicsMaterial_tlmti")
angular_damp = 2.0
script = ExtResource("1_hkjew")
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(0, -2)
scale = Vector2(1.5, 1.5)
texture = ExtResource("2_e237x")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_mjow3")
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource("3_oy301")
[node name="Timer" type="Timer" parent="."]
[node name="Explosion" type="GPUParticles2D" parent="."]
emitting = false
amount = 32
process_material = SubResource("ParticleProcessMaterial_3c5ho")
explosiveness = 1.0
[node name="ExplosionArea" type="Area2D" parent="."]
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="ExplosionArea"]
shape = SubResource("CircleShape2D_y1ra5")

53
bomb2.tscn Normal file
View File

@@ -0,0 +1,53 @@
[gd_scene load_steps=9 format=3 uid="uid://bbdf5ntt282cq"]
[ext_resource type="Script" path="res://bomb.gd" id="1_jqcjo"]
[ext_resource type="Texture2D" uid="uid://ckdx8o2mm5ynf" path="res://assets/Bombe.png" id="2_alkef"]
[sub_resource type="CircleShape2D" id="CircleShape2D_vf2ry"]
radius = 2.0
[sub_resource type="Gradient" id="Gradient_1i0c6"]
offsets = PackedFloat32Array(0, 0.52439, 0.707317, 1)
colors = PackedColorArray(0.632226, 6.37732e-07, 2.40654e-07, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.772549, 0.8, 0, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_r0qu4"]
gradient = SubResource("Gradient_1i0c6")
[sub_resource type="Curve" id="Curve_fqbuq"]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_u1w5g"]
curve = SubResource("Curve_fqbuq")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_hq1ch"]
particle_flag_disable_z = true
emission_shape = 1
emission_sphere_radius = 10.0
spread = 180.0
initial_velocity_min = 50.0
initial_velocity_max = 100.0
gravity = Vector3(0, 0, 0)
scale_over_velocity_max = 80.0
scale_over_velocity_curve = SubResource("CurveTexture_u1w5g")
color_ramp = SubResource("GradientTexture1D_r0qu4")
[node name="Bomb" type="Area2D"]
position = Vector2(257, 118)
script = ExtResource("1_jqcjo")
[node name="CollisionShape2D2" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_vf2ry")
[node name="Sprite2D2" type="Sprite2D" parent="."]
scale = Vector2(2, 2)
texture = ExtResource("2_alkef")
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
[node name="Timer" type="Timer" parent="."]
[node name="GPUParticles2D" type="GPUParticles2D" parent="."]
amount = 30
process_material = SubResource("ParticleProcessMaterial_hq1ch")
explosiveness = 1.0

1
icon.svg Normal file
View File

@@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 949 B

37
icon.svg.import Normal file
View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://csulww3vhv5m3"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

11
main.gd Normal file
View File

@@ -0,0 +1,11 @@
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$MultiTargetCamera.add_target($Player)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

481
main.tscn Normal file

File diff suppressed because one or more lines are too long

47
multitargetcamera.gd Normal file
View File

@@ -0,0 +1,47 @@
extends Camera2D
@export var move_speed = 3 # camera position lerp speed
@export var zoom_speed = 3 # camera zoom lerp speed for zooming in
@export var min_zoom = 5 # camera won't zoom closer than this
@export var max_zoom = 1 # camera won't zoom farther than this
@export var margin = Vector2(400, 200) # include some buffer area around targets
var targets = []
@onready var screen_size = get_viewport_rect().size
func _process(delta):
if !targets:
return
# Keep the camera centered among all targets
var p = Vector2.ZERO
for target in targets:
p += target.position
p /= targets.size()
position = lerp(position, p, move_speed * delta)
# Find the zoom that will contain all targets
var r = Rect2(position, Vector2.ONE)
for target in targets:
r = r.expand(target.position)
r = r.grow_individual(margin.x, margin.y, margin.x, margin.y)
var z
if r.size.x > r.size.y * screen_size.aspect():
z = 1 / clamp(r.size.x / screen_size.x, max_zoom, min_zoom)
else:
z = 1 / clamp(r.size.y / screen_size.y, max_zoom, min_zoom)
# Apply zoom instantly if zooming out, or lerp if zooming in
#if z < zoom.x: # Zooming in (smaller zoom level)
zoom = lerp(zoom, Vector2.ONE * z, zoom_speed * delta)
#else: # Zooming out (larger zoom level)
#zoom = Vector2.ONE * z
func add_target(t):
if not t in targets:
targets.append(t)
func remove_target(t):
if t in targets:
targets.erase(t)

81
player.gd Normal file
View File

@@ -0,0 +1,81 @@
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 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)
@export var jump_force = -400.0 # Upward force applied during a jump
@export var max_fall_speed = 1000.0 # Limit for how fast the player can fall
@export var friction = 5
@export var max_speed = 500.0
var charging = false
var current_power = 0.0
var direction = Vector2(2, -2) # Default direction, can be modified for aiming
var bomb = null # Global bomb reference
@onready var velocity_label = $Label
@onready var line_indicator = $Line2D # Reference to the Line2D node
func _ready() -> void:
# Set the initial points for the Line2D to indicate the starting vector
line_indicator.clear_points()
line_indicator.add_point(Vector2.ZERO) # Starting point at the player
line_indicator.add_point(Vector2.ZERO) # Ending point, will update dynamically
func _process(delta: float) -> void:
if position.y > 2000:
get_tree().reload_current_scene()
# Start charging when "throw_bomb" is pressed
if Input.is_action_pressed("throw_bomb") and (!bomb or !is_instance_valid(bomb)):
charging = true
current_power += charge_rate * delta
current_power = min(current_power, max_power) # Cap power at max_power
# Update velocity on the label
velocity_label.text = "Power: " + str(current_power)
# Calculate the direction based on the input (for example, using the mouse position or joystick)
var aim_direction = (get_global_mouse_position() - global_position).normalized()
# Set the start position of the line a bit away from the player
var start_position = aim_direction * line_start_offset
# Update the Line2D to visualize the throw direction and power
var end_point = start_position + (aim_direction * current_power / 10)
#line_indicator.set_point_position(1, end_point) # Set the ending point of the vector
line_indicator.set_point_position(0, start_position) # Set the starting point of the vector
line_indicator.set_point_position(1, end_point) # Set the ending point of the vector
elif Input.is_action_just_released("throw_bomb") and charging:
# Throw bomb when the action is released
throw_bomb(current_power)
charging = false
current_power = 0.0 # Reset power
# Reset Line2D to initial state after release
line_indicator.set_point_position(0, Vector2.ZERO)
line_indicator.set_point_position(1, Vector2.ZERO)
func throw_bomb(power: float):
# Check if there is no bomb or if the current bomb instance is invalid
if !bomb or !is_instance_valid(bomb):
# Instantiate the bomb
bomb = Bomb.instantiate() # Use global bomb reference
bomb.position = global_position
# Calculate the direction based on the mouse position
var aim_direction = (get_global_mouse_position() - global_position).normalized()
# Set the velocity for the bomb: direction * power
var launch_velocity = aim_direction * power * 2
bomb.set_velocity(launch_velocity)
# Add the bomb to the scene
add_child(bomb)
# Clear velocity display after throwing (optional)
velocity_label.text = "Power: 0"

85
player.tscn Normal file
View File

@@ -0,0 +1,85 @@
[gd_scene load_steps=10 format=3 uid="uid://clh8told15mah"]
[ext_resource type="Script" path="res://player.gd" id="1_jh72x"]
[ext_resource type="Texture2D" uid="uid://ct3rmsru1s17x" path="res://assets/player1/untitled_0001.png" id="1_uk6hx"]
[ext_resource type="Texture2D" uid="uid://cqmuysiqs2apc" path="res://assets/player1/untitled_0005.png" id="2_kkwhx"]
[ext_resource type="Texture2D" uid="uid://eqyoffrsod4i" path="res://assets/player1/untitled_0002.png" id="3_83v7l"]
[ext_resource type="Texture2D" uid="uid://lapvfkp8cf4r" path="res://assets/player1/untitled_0003.png" id="4_bfdm1"]
[ext_resource type="Texture2D" uid="uid://cktd41a7ky8p1" path="res://assets/player1/untitled_0004.png" id="5_4g1sb"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_wvdrw"]
bounce = 0.35
[sub_resource type="SpriteFrames" id="SpriteFrames_8lff6"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("1_uk6hx")
}],
"loop": true,
"name": &"air",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_kkwhx")
}],
"loop": true,
"name": &"dead",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_83v7l")
}, {
"duration": 1.0,
"texture": ExtResource("1_uk6hx")
}],
"loop": true,
"name": &"idle",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("4_bfdm1")
}, {
"duration": 1.0,
"texture": ExtResource("5_4g1sb")
}],
"loop": true,
"name": &"scared",
"speed": 5.0
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_ogije"]
radius = 20.0
height = 58.0
[node name="Player" type="RigidBody2D"]
collision_layer = 2
physics_material_override = SubResource("PhysicsMaterial_wvdrw")
lock_rotation = true
script = ExtResource("1_jh72x")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
scale = Vector2(2, 2)
sprite_frames = SubResource("SpriteFrames_8lff6")
animation = &"idle"
frame_progress = 0.708992
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 10)
scale = Vector2(2, 2)
shape = SubResource("CapsuleShape2D_ogije")
one_way_collision_margin = 32.1
[node name="Label" type="Label" parent="."]
offset_left = 38.0
offset_top = 7.0
offset_right = 78.0
offset_bottom = 30.0
[node name="Line2D" type="Line2D" parent="."]
scale = Vector2(2, 2)
points = PackedVector2Array(148, 120)
width = 5.0

28
project.godot Normal file
View File

@@ -0,0 +1,28 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="Bomber-Thorsten"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.3")
config/icon="res://icon.svg"
[input]
throw_bomb={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
]
}
[rendering]
textures/canvas_textures/default_texture_filter=0