commit 06dcdb9e4cfea74312bc5caa66fdb0c5897dc242 Author: Richard Osborne Date: Sat Jan 18 14:27:39 2025 +0000 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7103c32 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Godot 4+ specific ignores +.godot/ + +.import/ +export.cfg +export_presets.cfg + +*.translation + +.mono/ +data_*/ +mono_crash.*.json + +/android/ diff --git a/ball.gd b/ball.gd new file mode 100644 index 0000000..1750f70 --- /dev/null +++ b/ball.gd @@ -0,0 +1,34 @@ +extends RigidBody2D + +var speed = 300 +var velocity + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + velocity = Vector2(1, -1).normalized() * speed + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _physics_process(delta: float) -> void: + var collision = move_and_collide(velocity * delta) + if collision: + var obj = collision.get_collider() + if obj.get_parent().is_in_group('Blocks'): + print('block') + obj.on_bonk() + velocity = velocity.bounce(collision.get_normal()) + pass + + +func _on_visible_on_screen_notifier_2d_screen_exited() -> void: + print('ball gone') + queue_free() + + +func _on_body_entered(body: Node) -> void: + return + # print('bonk') + # if body.get_parent().is_in_group('Blocks'): + # print('its a block') + # body.on_bonk() diff --git a/ball.tscn b/ball.tscn new file mode 100644 index 0000000..52a19ec --- /dev/null +++ b/ball.tscn @@ -0,0 +1,26 @@ +[gd_scene load_steps=4 format=3 uid="uid://bbxc20gvkbtg4"] + +[ext_resource type="Script" path="res://ball.gd" id="1_lxc0r"] + +[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_4pkmb"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_7kx4t"] + +[node name="Ball" type="RigidBody2D"] +gravity_scale = 0.0 +contact_monitor = true +max_contacts_reported = 50 +script = ExtResource("1_lxc0r") + +[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."] + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(30, 30) +texture = SubResource("PlaceholderTexture2D_4pkmb") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +scale = Vector2(2, 2) +shape = SubResource("CircleShape2D_7kx4t") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] +[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] diff --git a/block.gd b/block.gd new file mode 100644 index 0000000..17ee056 --- /dev/null +++ b/block.gd @@ -0,0 +1,11 @@ +extends StaticBody2D + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +func on_bonk() -> void: + print('goodbye') + queue_free() diff --git a/block.tscn b/block.tscn new file mode 100644 index 0000000..a9093b2 --- /dev/null +++ b/block.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=3 uid="uid://bxmatfh6hpb25"] + +[ext_resource type="Script" path="res://block.gd" id="1_mhtgf"] + +[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_xujbx"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_116d2"] +size = Vector2(213, 70) + +[node name="Block" type="StaticBody2D"] +script = ExtResource("1_mhtgf") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(209.188, 68.75) +texture = SubResource("PlaceholderTexture2D_xujbx") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_116d2") diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..9d8b7fa --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..75f1d24 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://de3dikrdfse7d" +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 diff --git a/level.gd b/level.gd new file mode 100644 index 0000000..d778c52 --- /dev/null +++ b/level.gd @@ -0,0 +1,28 @@ +extends Node2D + +@export var ball_scene: PackedScene +var ball + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + ball = ball_scene.instantiate() + + ball.position = $BallStartPos.position + + var direction = randf_range(-PI/2, PI/2) + ball.rotation = direction + + ball.linear_velocity = Vector2(randf_range(150.0, 250.0), 0.0).rotated(direction) + + add_child(ball) + + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_block_removal(node: Node) -> void: + pass # Replace with function body. diff --git a/level.tscn b/level.tscn new file mode 100644 index 0000000..d3f29d1 --- /dev/null +++ b/level.tscn @@ -0,0 +1,73 @@ +[gd_scene load_steps=6 format=3 uid="uid://133k2vqcsdfg"] + +[ext_resource type="PackedScene" uid="uid://bxmatfh6hpb25" path="res://block.tscn" id="1_6kkux"] +[ext_resource type="PackedScene" uid="uid://bbxc20gvkbtg4" path="res://ball.tscn" id="1_dwwgw"] +[ext_resource type="Script" path="res://level.gd" id="1_gs11x"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_lbv4x"] +size = Vector2(120.5, 772) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_1i5ye"] +size = Vector2(555.125, 88.5) + +[node name="Game" type="Node2D" groups=["Blocks"]] +script = ExtResource("1_gs11x") +ball_scene = ExtResource("1_dwwgw") + +[node name="Background" type="ColorRect" parent="."] +offset_left = -11.0 +offset_top = -27.0 +offset_right = 504.0 +offset_bottom = 753.0 +color = Color(0.754947, 1, 0.998037, 1) + +[node name="Blocks" type="Node" parent="." groups=["Blocks"]] + +[node name="Block4" parent="Blocks" instance=ExtResource("1_6kkux")] +position = Vector2(107, 47) +scale = Vector2(0.5, 0.5) + +[node name="Block3" parent="Blocks" instance=ExtResource("1_6kkux")] +position = Vector2(161, 325) +scale = Vector2(0.5, 0.5) + +[node name="Block6" parent="Blocks" instance=ExtResource("1_6kkux")] +position = Vector2(138, 481) +scale = Vector2(0.5, 0.5) + +[node name="Block5" parent="Blocks" instance=ExtResource("1_6kkux")] +position = Vector2(371, 545) +scale = Vector2(0.5, 0.5) + +[node name="Block2" parent="Blocks" instance=ExtResource("1_6kkux")] +position = Vector2(241, 30) +scale = Vector2(0.5, 0.5) + +[node name="Block" parent="Blocks" instance=ExtResource("1_6kkux")] +position = Vector2(294, 196) +scale = Vector2(0.5, 0.5) + +[node name="BallStartPos" type="Node2D" parent="."] +position = Vector2(246, 609) + +[node name="Boundary" type="Node2D" parent="."] + +[node name="StaticBody2D" type="StaticBody2D" parent="Boundary"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Boundary/StaticBody2D"] +position = Vector2(539, 375) +shape = SubResource("RectangleShape2D_lbv4x") + +[node name="CollisionShape2D2" type="CollisionShape2D" parent="Boundary/StaticBody2D"] +position = Vector2(-62, 377) +shape = SubResource("RectangleShape2D_lbv4x") + +[node name="CollisionShape2D3" type="CollisionShape2D" parent="Boundary/StaticBody2D"] +position = Vector2(254.438, -46.25) +shape = SubResource("RectangleShape2D_1i5ye") + +[node name="CollisionShape2D4" type="CollisionShape2D" parent="Boundary/StaticBody2D"] +position = Vector2(249, 763) +shape = SubResource("RectangleShape2D_1i5ye") + +[connection signal="child_exiting_tree" from="." to="." method="_on_block_removal"] diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..d3e7ec3 --- /dev/null +++ b/project.godot @@ -0,0 +1,22 @@ +; 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="2025-breakout" +run/main_scene="res://level.tscn" +config/features=PackedStringArray("4.3", "Forward Plus") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=480 +window/size/viewport_height=720 +window/stretch/mode="canvas_items"