diff --git a/2d/bullet_shower/README.md b/2d/bullet_shower/README.md index fe400867..df616b0a 100644 --- a/2d/bullet_shower/README.md +++ b/2d/bullet_shower/README.md @@ -9,7 +9,7 @@ in the documentation for more information. Language: GDScript -Renderer: GLES 2 +Renderer: Vulkan Mobile Check out this demo on the asset library: https://godotengine.org/asset-library/asset/887 diff --git a/2d/bullet_shower/bullet.png.import b/2d/bullet_shower/bullet.png.import index 22b343c9..8687cc2e 100644 --- a/2d/bullet_shower/bullet.png.import +++ b/2d/bullet_shower/bullet.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/bullet.png-ff1424653e10246c11e3724e402c519e.stex" +type="CompressedTexture2D" +uid="uid://bcoiuym4nw1ua" +path="res://.godot/imported/bullet.png-ff1424653e10246c11e3724e402c519e.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,23 @@ metadata={ [deps] source_file="res://bullet.png" -dest_files=["res://.godot/imported/bullet.png-ff1424653e10246c11e3724e402c519e.stex"] +dest_files=["res://.godot/imported/bullet.png-ff1424653e10246c11e3724e402c519e.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +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/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/2d/bullet_shower/bullets.gd b/2d/bullet_shower/bullets.gd index 852c69e4..74b8e21b 100644 --- a/2d/bullet_shower/bullets.gd +++ b/2d/bullet_shower/bullets.gd @@ -10,7 +10,7 @@ const SPEED_MAX = 80 const bullet_image = preload("res://bullet.png") -var bullets = [] +var bullets := [] var shape @@ -32,16 +32,14 @@ func _ready(): for _i in BULLET_COUNT: var bullet = Bullet.new() - # Give each bullet its own speed. + # Give each bullet its own random speed. bullet.speed = randf_range(SPEED_MIN, SPEED_MAX) bullet.body = PhysicsServer2D.body_create() PhysicsServer2D.body_set_space(bullet.body, get_world_2d().get_space()) PhysicsServer2D.body_add_shape(bullet.body, shape) # Don't make bullets check collision with other bullets to improve performance. - # Their collision mask is still configured to the default value, which allows - # bullets to detect collisions with the player. - PhysicsServer2D.body_set_collision_layer(bullet.body, 0) + PhysicsServer2D.body_set_collision_mask(bullet.body, 0) # Place bullets randomly on the viewport and move bullets outside the # play area so that they fade in nicely. @@ -68,11 +66,10 @@ func _physics_process(delta): bullet.position.x -= bullet.speed * delta if bullet.position.x < -16: - # The bullet has left the screen; move it back to the right. + # Move the bullet back to the right when it left the screen. bullet.position.x = offset transform2d.origin = bullet.position - PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d) diff --git a/2d/bullet_shower/face_happy.png.import b/2d/bullet_shower/face_happy.png.import index 20f8826a..b42c41ce 100644 --- a/2d/bullet_shower/face_happy.png.import +++ b/2d/bullet_shower/face_happy.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/face_happy.png-38d387d31ec13459f749c93ce3d75d80.stex" +type="CompressedTexture2D" +uid="uid://d3u7k0742d5ug" +path="res://.godot/imported/face_happy.png-38d387d31ec13459f749c93ce3d75d80.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,23 @@ metadata={ [deps] source_file="res://face_happy.png" -dest_files=["res://.godot/imported/face_happy.png-38d387d31ec13459f749c93ce3d75d80.stex"] +dest_files=["res://.godot/imported/face_happy.png-38d387d31ec13459f749c93ce3d75d80.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +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/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/2d/bullet_shower/face_sad.png.import b/2d/bullet_shower/face_sad.png.import index 6da209aa..45ae30a2 100644 --- a/2d/bullet_shower/face_sad.png.import +++ b/2d/bullet_shower/face_sad.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/face_sad.png-0ac7165eab24f595aba17a746a66c550.stex" +type="CompressedTexture2D" +uid="uid://8j32onnr4qo3" +path="res://.godot/imported/face_sad.png-0ac7165eab24f595aba17a746a66c550.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,23 @@ metadata={ [deps] source_file="res://face_sad.png" -dest_files=["res://.godot/imported/face_sad.png-0ac7165eab24f595aba17a746a66c550.stex"] +dest_files=["res://.godot/imported/face_sad.png-0ac7165eab24f595aba17a746a66c550.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +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/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/2d/bullet_shower/icon.png.import b/2d/bullet_shower/icon.png.import index 889af9df..e6915379 100644 --- a/2d/bullet_shower/icon.png.import +++ b/2d/bullet_shower/icon.png.import @@ -1,8 +1,9 @@ [remap] importer="texture" -type="StreamTexture2D" -path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +type="CompressedTexture2D" +uid="uid://c8w03v671qh3y" +path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex" metadata={ "vram_texture": false } @@ -10,26 +11,23 @@ metadata={ [deps] source_file="res://icon.png" -dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"] +dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"] [params] compress/mode=0 compress/lossy_quality=0.7 -compress/hdr_mode=0 +compress/hdr_compression=1 compress/bptc_ldr=0 compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 +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/HDR_as_SRGB=false -process/invert_color=false process/normal_map_invert_y=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 +process/hdr_as_srgb=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/2d/bullet_shower/player.gd b/2d/bullet_shower/player.gd index eeb63ce3..32b14c7e 100644 --- a/2d/bullet_shower/player.gd +++ b/2d/bullet_shower/player.gd @@ -17,11 +17,13 @@ func _ready(): func _input(event): + # Getting the movement of the mouse so the sprite can follow its position. if event is InputEventMouseMotion: position = event.position - Vector2(0, 16) func _on_body_shape_entered(_body_id, _body, _body_shape, _local_shape): + # Player got touched by a bullet so sprite changes to sad face. touching += 1 if touching >= 1: sprite.frame = 1 @@ -29,5 +31,7 @@ func _on_body_shape_entered(_body_id, _body, _body_shape, _local_shape): func _on_body_shape_exited(_body_id, _body, _body_shape, _local_shape): touching -= 1 + # When non of the bullets are touching the player, + # sprite changes to happy face. if touching == 0: sprite.frame = 0 diff --git a/2d/bullet_shower/project.godot b/2d/bullet_shower/project.godot index fc9f4d49..448355a8 100644 --- a/2d/bullet_shower/project.godot +++ b/2d/bullet_shower/project.godot @@ -6,11 +6,10 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 +config_version=5 _global_script_classes=[] -_global_script_class_icons={ -} +_global_script_class_icons={} [application] @@ -18,23 +17,21 @@ config/name="Bullet Shower" config/description="Demonstrates how to manage large amounts of objects efficiently using low-level Servers." run/main_scene="res://shower.tscn" config/icon="res://icon.png" +config/features=PackedStringArray("4.0") [display] -window/dpi/allow_hidpi=true -window/stretch/mode="2d" +window/stretch/mode="canvas_items" window/stretch/aspect="expand" +[layer_names] + +2d_physics/layer_1="Player" + [physics] -common/enable_pause_aware_picking=true 2d/cell_size=64 [rendering] -quality/driver/driver_name="GLES2" -quality/intended_usage/framebuffer_allocation=0 -quality/intended_usage/framebuffer_allocation.mobile=0 -vram_compression/import_etc=true -vram_compression/import_etc2=false -environment/default_clear_color=Color(0.133333, 0.133333, 0.2, 1) +vulkan/rendering/back_end=1 diff --git a/2d/bullet_shower/shower.tscn b/2d/bullet_shower/shower.tscn index 8150ee96..df11543b 100644 --- a/2d/bullet_shower/shower.tscn +++ b/2d/bullet_shower/shower.tscn @@ -1,34 +1,34 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=7 format=3 uid="uid://c78by7hc4fmwx"] -[ext_resource path="res://bullets.gd" type="Script" id=2] -[ext_resource path="res://face_happy.png" type="Texture2D" id=3] -[ext_resource path="res://face_sad.png" type="Texture2D" id=4] -[ext_resource path="res://player.gd" type="Script" id=5] +[ext_resource type="Script" path="res://bullets.gd" id="2"] +[ext_resource type="Texture2D" uid="uid://d3u7k0742d5ug" path="res://face_happy.png" id="3"] +[ext_resource type="Texture2D" uid="uid://8j32onnr4qo3" path="res://face_sad.png" id="4"] +[ext_resource type="Script" path="res://player.gd" id="5"] -[sub_resource type="SpriteFrames" id=1] +[sub_resource type="SpriteFrames" id="1"] animations = [{ -"frames": [ExtResource( 3 ), ExtResource( 4 )], +"frames": [ExtResource( "3" ), ExtResource( "4" )], "loop": true, -"name": "default", +"name": &"default", "speed": 5.0 }] -[sub_resource type="CircleShape2D" id=2] +[sub_resource type="CircleShape2D" id="2"] radius = 27.0 [node name="Shower" type="Node2D"] [node name="Bullets" type="Node2D" parent="."] -script = ExtResource( 2 ) +script = ExtResource( "2" ) [node name="Player" type="Area2D" parent="."] -script = ExtResource( 5 ) +script = ExtResource( "5" ) [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Player"] -frames = SubResource( 1 ) +frames = SubResource( "1" ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] -shape = SubResource( 2 ) +shape = SubResource( "2" ) [connection signal="body_shape_entered" from="Player" to="Player" method="_on_body_shape_entered"] [connection signal="body_shape_exited" from="Player" to="Player" method="_on_body_shape_exited"]