update character_body_2d example

This commit is contained in:
Hana - Piralein
2023-08-28 21:41:12 +02:00
parent 67e1ec4055
commit c209a33b0d
29 changed files with 372 additions and 756 deletions

View File

@@ -1,24 +0,0 @@
extends KinematicBody2D
var speed = 250
var velocity = Vector2()
var use_slide = true
func get_input():
velocity = Vector2()
if Input.is_action_pressed('ui_right'):
velocity.x += 1
if Input.is_action_pressed('ui_left'):
velocity.x -= 1
if Input.is_action_pressed('ui_down'):
velocity.y += 1
if Input.is_action_pressed('ui_up'):
velocity.y -= 1
velocity = velocity.normalized() * speed
func _physics_process(delta):
get_input()
if use_slide:
move_and_slide(velocity)
else:
move_and_collide(velocity * delta)

View File

@@ -1,176 +0,0 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://BasicMovement.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[sub_resource type="RectangleShape2D" id=1]
custom_solver_bias = 0.0
extents = Vector2( 30.8363, 31.4991 )
[sub_resource type="RectangleShape2D" id=2]
custom_solver_bias = 0.0
extents = Vector2( 138.37, 10 )
[node name="BasicMovement" type="Node"]
[node name="KinematicBody2D" type="KinematicBody2D" parent="." index="0"]
position = Vector2( 534.268, 286.215 )
input_pickable = false
collision_layer = 1
collision_mask = 1
collision/safe_margin = 0.08
script = ExtResource( 1 )
__meta__ = {
"_edit_group_": true
}
[node name="Sprite" type="Sprite" parent="KinematicBody2D" index="0"]
texture = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D" index="1"]
shape = SubResource( 1 )
[node name="Walls" type="Node" parent="." index="1"]
[node name="Wall" type="StaticBody2D" parent="Walls" index="0"]
position = Vector2( 790, 100 )
input_pickable = false
collision_layer = 1
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
__meta__ = {
"_edit_group_": true
}
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall" index="0"]
polygon = PoolVector2Array( -139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625 )
uv = PoolVector2Array( )
color = Color( 1, 1, 1, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall" index="1"]
shape = SubResource( 2 )
[node name="Wall2" type="StaticBody2D" parent="Walls" index="1"]
position = Vector2( 250, 510 )
input_pickable = false
collision_layer = 1
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
__meta__ = {
"_edit_group_": true
}
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall2" index="0"]
polygon = PoolVector2Array( -139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625 )
uv = PoolVector2Array( )
color = Color( 1, 1, 1, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall2" index="1"]
shape = SubResource( 2 )
[node name="Wall3" type="StaticBody2D" parent="Walls" index="2"]
position = Vector2( 240, 210 )
rotation = 1.5708
input_pickable = false
collision_layer = 1
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Transform" ]
__meta__ = {
"_edit_group_": true
}
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall3" index="0"]
polygon = PoolVector2Array( -139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625 )
uv = PoolVector2Array( )
color = Color( 1, 1, 1, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall3" index="1"]
shape = SubResource( 2 )
[node name="Wall4" type="StaticBody2D" parent="Walls" index="3"]
position = Vector2( 844.578, 387.906 )
rotation = -0.785398
input_pickable = false
collision_layer = 1
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
_sections_unfolded = [ "Transform" ]
__meta__ = {
"_edit_group_": true
}
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall4" index="0"]
polygon = PoolVector2Array( -139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625 )
uv = PoolVector2Array( )
color = Color( 1, 1, 1, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall4" index="1"]
shape = SubResource( 2 )

View File

@@ -1,80 +0,0 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Player.gd" type="Script" id=1]
[ext_resource path="res://assets/soldier1_gun.png" type="Texture" id=2]
[ext_resource path="res://Wall.tscn" type="PackedScene" id=3]
[sub_resource type="CircleShape2D" id=1]
custom_solver_bias = 0.0
radius = 22.0227
[node name="BounceandCollide" type="Node"]
[node name="Player" type="KinematicBody2D" parent="." index="0"]
position = Vector2( 350, 139 )
input_pickable = false
collision_layer = 1
collision_mask = 1
collision/safe_margin = 0.08
script = ExtResource( 1 )
__meta__ = {
"_edit_group_": true
}
[node name="Sprite" type="Sprite" parent="Player" index="0"]
texture = ExtResource( 2 )
_sections_unfolded = [ "Transform" ]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player" index="1"]
position = Vector2( -5, 0 )
shape = SubResource( 1 )
_sections_unfolded = [ "Transform" ]
[node name="Muzzle" type="Position2D" parent="Player" index="2"]
position = Vector2( 28, 8 )
_sections_unfolded = [ "Transform", "Visibility", "Z Index" ]
[node name="Label" type="Label" parent="Player" index="3"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 40.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Walls" type="Node" parent="." index="1"]
[node name="Wall" parent="Walls" index="0" instance=ExtResource( 3 )]
[node name="Wall2" parent="Walls" index="1" instance=ExtResource( 3 )]
position = Vector2( 668, 85 )
[node name="Wall3" parent="Walls" index="2" instance=ExtResource( 3 )]
position = Vector2( 827.828, 263.748 )
rotation = 1.5708
_sections_unfolded = [ "Transform" ]
[node name="Wall4" parent="Walls" index="3" instance=ExtResource( 3 )]
position = Vector2( 231.425, 302.296 )
rotation = 1.5708
_sections_unfolded = [ "Transform" ]

View File

@@ -1,19 +0,0 @@
extends KinematicBody2D
var speed = 750
var velocity = Vector2()
func start(pos, dir):
rotation = dir
position = pos
velocity = Vector2(speed, 0).rotated(rotation)
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision:
velocity = velocity.bounce(collision.normal)
if collision.collider.has_method("hit"):
collision.collider.hit()
func _on_VisibilityNotifier2D_screen_exited():
queue_free()

View File

@@ -1,12 +0,0 @@
extends KinematicBody2D
var velocity = Vector2(100, 100)
var use_slide = true
func _physics_process(delta):
if use_slide:
velocity = move_and_slide(velocity)
else:
var collision = move_and_collide(velocity * delta)
if collision:
velocity = velocity.slide(collision.normal)

View File

@@ -1,29 +0,0 @@
extends KinematicBody2D
export (int) var run_speed = 100
export (int) var jump_speed = -400
export (int) var gravity = 1200
var velocity = Vector2()
var jumping = false
func get_input():
velocity.x = 0
var right = Input.is_action_pressed('ui_right')
var left = Input.is_action_pressed('ui_left')
var jump = Input.is_action_just_pressed('ui_select')
if jump and is_on_floor():
jumping = true
velocity.y = jump_speed
if right:
velocity.x += run_speed
if left:
velocity.x -= run_speed
func _physics_process(delta):
get_input()
velocity.y += gravity * delta
if jumping and is_on_floor():
jumping = false
velocity = move_and_slide(velocity, Vector2(0, -1))

View File

@@ -1,70 +0,0 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://PlatformPlayer.gd" type="Script" id=1]
[sub_resource type="RectangleShape2D" id=1]
custom_solver_bias = 0.0
extents = Vector2( 8, 12 )
[node name="PlatformPlayer" type="KinematicBody2D"]
input_pickable = false
collision_layer = 2
collision_mask = 13
collision/safe_margin = 0.08
script = ExtResource( 1 )
_sections_unfolded = [ "Collision", "Transform", "collision" ]
run_speed = 100
jump_speed = -400
gravity = 1200
[node name="Polygon2D" type="Polygon2D" parent="." index="0"]
polygon = PoolVector2Array( -8, -12, 8, -12, 8, 12, -8, 12 )
uv = PoolVector2Array( )
color = Color( 1, 1, 1, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
_sections_unfolded = [ "Visibility" ]
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
shape = SubResource( 1 )
_sections_unfolded = [ "Transform" ]
[node name="Camera2D" type="Camera2D" parent="." index="2"]
position = Vector2( 0, 5 )
anchor_mode = 1
rotating = false
current = true
zoom = Vector2( 0.3, 0.3 )
limit_left = -75
limit_top = 50
limit_right = 725
limit_bottom = 550
limit_smoothed = false
drag_margin_h_enabled = true
drag_margin_v_enabled = true
smoothing_enabled = false
smoothing_speed = 5.0
offset_v = 0.0
offset_h = 0.0
drag_margin_left = 0.1
drag_margin_top = 0.1
drag_margin_right = 0.1
drag_margin_bottom = 0.1
editor_draw_screen = true
editor_draw_limits = false
editor_draw_drag_margin = false
_sections_unfolded = [ "Drag Margin", "Limit" ]

View File

@@ -1,81 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://PlatformPlayer.tscn" type="PackedScene" id=1]
[node name="PlatformGame" type="Node" index="0"]
[node name="Walls" type="Node" parent="." index="0"]
[node name="StaticBody2D" type="StaticBody2D" parent="Walls" index="0"]
position = Vector2( 485.296, 379.731 )
input_pickable = false
collision_layer = 1
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
__meta__ = {
"_edit_group_": true
}
[node name="Polygon2D" type="Polygon2D" parent="Walls/StaticBody2D" index="0"]
polygon = PoolVector2Array( -435.83, 105.853, -388.346, 74.7186, -86.0178, 74.7186, -32.3343, 50.5918, 9.76965, 11.9966, 68.5397, 12.8737, 72.0483, 64.6264, 26.4358, 104.976 )
uv = PoolVector2Array( )
color = Color( 0.341461, 0.523438, 0.34857, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Walls/StaticBody2D" index="1"]
build_mode = 0
polygon = PoolVector2Array( -434.052, 106.741, -387.516, 75.3428, -85.3116, 75.3428, -33.1687, 51.2337, 10.564, 12.5471, 66.6316, 14.2292, 73.3597, 63.5686, 24.5809, 106.18 )
[node name="StaticBody2D2" type="StaticBody2D" parent="Walls" index="1"]
position = Vector2( 491.464, 318.057 )
input_pickable = false
collision_layer = 1
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
__meta__ = {
"_edit_group_": true
}
[node name="Polygon2D" type="Polygon2D" parent="Walls/StaticBody2D2" index="0"]
polygon = PoolVector2Array( -330.327, 94.9664, -340.98, 82.6316, -113.906, 86.5563, -127.923, 96.6485 )
uv = PoolVector2Array( )
color = Color( 0.341461, 0.523438, 0.34857, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Walls/StaticBody2D2" index="1"]
build_mode = 0
polygon = PoolVector2Array( -328.645, 96.0878, -341.217, 83.0776, -114.513, 86.9529, -126.802, 97.2092 )
[node name="PlatformPlayer" parent="." index="1" instance=ExtResource( 1 )]
position = Vector2( 393.654, 427.999 )

View File

@@ -1,26 +0,0 @@
extends KinematicBody2D
var Bullet = preload("res://Bullet.tscn")
var speed = 200
var velocity = Vector2()
func get_input():
velocity = Vector2()
if Input.is_action_pressed('backward'):
velocity = Vector2(-speed/3, 0).rotated(rotation)
if Input.is_action_pressed('forward'):
velocity = Vector2(speed, 0).rotated(rotation)
if Input.is_action_just_pressed('mouse_click'):
shoot()
func shoot():
var b = Bullet.instance()
b.start($Muzzle.global_position, rotation)
get_parent().add_child(b)
func _physics_process(delta):
get_input()
var dir = get_global_mouse_position() - global_position
if dir.length() > 5:
rotation = dir.angle()
velocity = move_and_slide(velocity)

View File

@@ -1,73 +0,0 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Wall.gd" type="Script" id=1]
[sub_resource type="RectangleShape2D" id=1]
custom_solver_bias = 0.0
extents = Vector2( 170, 10 )
[sub_resource type="Animation" id=2]
resource_name = "flash"
length = 0.5
loop = false
step = 0.1
tracks/0/type = "value"
tracks/0/path = NodePath("Polygon2D:color")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 0, 0, 1 ), Color( 1, 1, 1, 1 ) ]
}
[node name="Wall" type="StaticBody2D"]
position = Vector2( 390.63, 482 )
input_pickable = false
collision_layer = 8
collision_mask = 1
constant_linear_velocity = Vector2( 0, 0 )
constant_angular_velocity = 0.0
friction = 1.0
bounce = 0.0
script = ExtResource( 1 )
__meta__ = {
"_edit_group_": true
}
[node name="Polygon2D" type="Polygon2D" parent="." index="0"]
polygon = PoolVector2Array( -170, -10, 170, -10, 170, 10, -170, 10 )
uv = PoolVector2Array( )
color = Color( 1, 1, 1, 1 )
vertex_colors = PoolColorArray( )
offset = Vector2( 0, 0 )
antialiased = false
texture = null
texture_offset = Vector2( 0, 0 )
texture_scale = Vector2( 1, 1 )
texture_rotation_degrees = 0.0
invert_enable = false
invert_border = 100.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="1"]
shape = SubResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="2"]
root_node = NodePath("..")
autoplay = ""
playback_process_mode = 1
playback_default_blend_time = 0.0
playback_speed = 1.0
anims/flash = SubResource( 2 )
blend_times = [ ]

View File

@@ -1,32 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/soldier1_gun.png-c6a4b98c26f714c536241bcc3abc6d46.stex"
type="CompressedTexture2D"
uid="uid://cwhah7m5urcoe"
path="res://.godot/imported/soldier1_gun.png-c6a4b98c26f714c536241bcc3abc6d46.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/soldier1_gun.png"
source_md5="511c324d0795f775677a90d17b1e8357"
dest_files=[ "res://.import/soldier1_gun.png-c6a4b98c26f714c536241bcc3abc6d46.stex" ]
dest_md5="923c65170fa22250959d5c695ba084a6"
dest_files=["res://.godot/imported/soldier1_gun.png-c6a4b98c26f714c536241bcc3abc6d46.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/normal_map=0
flags/repeat=0
flags/filter=false
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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
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

View File

@@ -1,4 +1,4 @@
"Sunny Land" art pack by Ansimuz:
https://opengameart.org/content/sunny-land-2d-pixel-art-pack
https://opengameart.org/content/sunny-land-2d-pixel-art-pack
Top down shooter character by Kenney:
https://opengameart.org/content/topdown-shooter
https://opengameart.org/content/topdown-shooter

View File

@@ -0,0 +1,11 @@
extends CharacterBody2D
var speed = 300
func get_input():
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
velocity = input_dir * speed
func _physics_process(delta):
get_input()
move_and_collide(velocity * delta)

View File

@@ -0,0 +1,69 @@
[gd_scene load_steps=5 format=3 uid="uid://3wtg30baumld"]
[ext_resource type="Script" path="res://basic_movement.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://bguqcw3nf1n7" path="res://icon.svg" id="2_eod2d"]
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(64, 64)
[sub_resource type="RectangleShape2D" id="2"]
size = Vector2(280, 20)
[node name="BasicMovement" type="Node"]
[node name="KinematicBody2D" type="CharacterBody2D" parent="."]
position = Vector2(536, 288)
script = ExtResource("1")
[node name="Sprite" type="Sprite2D" parent="KinematicBody2D"]
position = Vector2(-7.1466e-05, 4.41372e-05)
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_eod2d")
[node name="CollisionShape2D" type="CollisionShape2D" parent="KinematicBody2D"]
position = Vector2(-6.10352e-05, 3.05176e-05)
shape = SubResource("1")
[node name="Walls" type="Node" parent="."]
[node name="Wall" type="StaticBody2D" parent="Walls"]
position = Vector2(790, 100)
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall"]
polygon = PackedVector2Array(-139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall"]
position = Vector2(1, 0)
shape = SubResource("2")
[node name="Wall2" type="StaticBody2D" parent="Walls"]
position = Vector2(250, 510)
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall2"]
polygon = PackedVector2Array(-139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall2"]
position = Vector2(1, 0)
shape = SubResource("2")
[node name="Wall3" type="StaticBody2D" parent="Walls"]
position = Vector2(240, 210)
rotation = 1.5708
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall3"]
polygon = PackedVector2Array(-139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall3"]
position = Vector2(1.00003, -0.00050354)
shape = SubResource("2")
[node name="Wall4" type="StaticBody2D" parent="Walls"]
position = Vector2(844.578, 387.906)
rotation = -0.785398
[node name="Polygon2D" type="Polygon2D" parent="Walls/Wall4"]
polygon = PackedVector2Array(-139.29, -10.3625, -139.29, 9.63754, 140.71, 9.63754, 140.71, -10.3625)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls/Wall4"]
position = Vector2(0.939087, -0.00012207)
shape = SubResource("2")

View File

@@ -0,0 +1,41 @@
[gd_scene load_steps=5 format=3 uid="uid://dfet1cgypfom2"]
[ext_resource type="Script" path="res://player.gd" id="1_6jxo0"]
[ext_resource type="Texture2D" uid="uid://cwhah7m5urcoe" path="res://assets/soldier1_gun.png" id="2_wnpta"]
[ext_resource type="PackedScene" uid="uid://bucigqlq6k64b" path="res://wall.tscn" id="3_wrjm7"]
[sub_resource type="CircleShape2D" id="1"]
radius = 22.0227
[node name="BounceandCollide" type="Node"]
[node name="Player" type="CharacterBody2D" parent="."]
position = Vector2(350, 139)
script = ExtResource("1_6jxo0")
[node name="Sprite" type="Sprite2D" parent="Player"]
texture = ExtResource("2_wnpta")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
position = Vector2(-5, 0)
shape = SubResource("1")
[node name="Muzzle" type="Marker2D" parent="Player"]
position = Vector2(28, 8)
[node name="Label" type="Label" parent="Player"]
[node name="Walls" type="Node" parent="."]
[node name="Wall" parent="Walls" instance=ExtResource("3_wrjm7")]
[node name="Wall2" parent="Walls" instance=ExtResource("3_wrjm7")]
position = Vector2(668, 85)
[node name="Wall3" parent="Walls" instance=ExtResource("3_wrjm7")]
position = Vector2(827.828, 263.748)
rotation = 1.5708
[node name="Wall4" parent="Walls" instance=ExtResource("3_wrjm7")]
position = Vector2(231.425, 302.296)
rotation = 1.5708

View File

@@ -0,0 +1,19 @@
extends CharacterBody2D
var speed = 750
func start(_position, _direction):
rotation = _direction
position = _position
velocity = Vector2(speed, 0).rotated(rotation)
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision:
velocity = velocity.bounce(collision.get_normal())
if collision.get_collider().has_method("hit"):
collision.get_collider().hit()
func _on_VisibilityNotifier2D_screen_exited():
# Deletes the bullet when it exits the screen.
queue_free()

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=3 format=3]
[ext_resource path="res://Bullet.gd" type="Script" id=1]
[ext_resource type="Script" path="res://bullet.gd" id="1"]
[sub_resource type="RectangleShape2D" id=1]

View File

@@ -1,101 +0,0 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
radiance_size = 4
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
sky_curve = 0.25
sky_energy = 1.0
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
ground_curve = 0.01
ground_energy = 1.0
sun_color = Color( 1, 1, 1, 1 )
sun_latitude = 35.0
sun_longitude = 0.0
sun_angle_min = 1.0
sun_angle_max = 100.0
sun_curve = 0.05
sun_energy = 16.0
texture_size = 2
[resource]
background_mode = 2
background_sky = SubResource( 1 )
background_sky_custom_fov = 0.0
background_color = Color( 0, 0, 0, 1 )
background_energy = 1.0
background_canvas_max_layer = 0
ambient_light_color = Color( 0, 0, 0, 1 )
ambient_light_energy = 1.0
ambient_light_sky_contribution = 1.0
fog_enabled = false
fog_color = Color( 0.5, 0.6, 0.7, 1 )
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
fog_sun_amount = 0.0
fog_depth_enabled = true
fog_depth_begin = 10.0
fog_depth_curve = 1.0
fog_transmit_enabled = false
fog_transmit_curve = 1.0
fog_height_enabled = false
fog_height_min = 0.0
fog_height_max = 100.0
fog_height_curve = 1.0
tonemap_mode = 0
tonemap_exposure = 1.0
tonemap_white = 1.0
auto_exposure_enabled = false
auto_exposure_scale = 0.4
auto_exposure_min_luma = 0.05
auto_exposure_max_luma = 8.0
auto_exposure_speed = 0.5
ss_reflections_enabled = false
ss_reflections_max_steps = 64
ss_reflections_fade_in = 0.15
ss_reflections_fade_out = 2.0
ss_reflections_depth_tolerance = 0.2
ss_reflections_roughness = true
ssao_enabled = false
ssao_radius = 1.0
ssao_intensity = 1.0
ssao_radius2 = 0.0
ssao_intensity2 = 1.0
ssao_bias = 0.01
ssao_light_affect = 0.0
ssao_color = Color( 0, 0, 0, 1 )
ssao_quality = 0
ssao_blur = 3
ssao_edge_sharpness = 4.0
dof_blur_far_enabled = false
dof_blur_far_distance = 10.0
dof_blur_far_transition = 5.0
dof_blur_far_amount = 0.1
dof_blur_far_quality = 1
dof_blur_near_enabled = false
dof_blur_near_distance = 2.0
dof_blur_near_transition = 1.0
dof_blur_near_amount = 0.1
dof_blur_near_quality = 1
glow_enabled = false
glow_levels/1 = false
glow_levels/2 = false
glow_levels/3 = true
glow_levels/4 = false
glow_levels/5 = true
glow_levels/6 = false
glow_levels/7 = false
glow_intensity = 0.8
glow_strength = 1.0
glow_bloom = 0.0
glow_blend_mode = 2
glow_hdr_threshold = 1.0
glow_hdr_scale = 2.0
glow_bicubic_upscale = false
adjustment_enabled = false
adjustment_brightness = 1.0
adjustment_contrast = 1.0
adjustment_saturation = 1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -1,32 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
[deps]
source_file="res://icon.png"
source_md5="ae7e641067601e2184afcade49abd283"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_md5="37fab264f7edd819d74f710b6a7c22dc"
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><g transform="translate(32 32)"><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99z" fill="#363d52"/><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99zm0 4h96c6.64 0 12 5.35 12 11.99v95.98c0 6.64-5.35 11.99-12 11.99h-96c-6.64 0-12-5.35-12-11.99v-95.98c0-6.64 5.36-11.99 12-11.99z" fill-opacity=".4"/></g><g stroke-width="9.92746" transform="matrix(.10073078 0 0 .10073078 12.425923 2.256365)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 919.24059 771.67186)"/><path d="m0 0v-47.514-6.035-5.492c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325c5.09692 6.4164715 9.92323 13.494208 13.621 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.4426579-6.973692 9.2079702-13.9828876 13.621-19.449z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 104.69892 525.90697)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.066.067c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 784.07144 817.24284)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 389.21484 625.67104)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 367.36686 631.05679)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 511.99336 724.73954)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 634.78706 625.67104)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 656.64056 631.05679)"/></g></svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bguqcw3nf1n7"
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

View File

@@ -0,0 +1,22 @@
extends CharacterBody2D
var speed = 300.0
var jump_speed = -400.0
# Get the gravity from the project settings so you can sync with rigid body nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta):
# Add the gravity.
velocity.y += gravity * delta
# Handle Jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jump_speed
# Get the input direction.
var direction = Input.get_axis("ui_left", "ui_right")
velocity.x = direction * speed
move_and_slide()

View File

@@ -0,0 +1,25 @@
[gd_scene load_steps=3 format=3 uid="uid://b7leymer5mvxe"]
[ext_resource type="Script" path="res://platform_player.gd" id="1"]
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(16, 24)
[node name="PlatformPlayer" type="CharacterBody2D"]
collision_layer = 2
collision_mask = 13
script = ExtResource("1")
[node name="Polygon2D" type="Polygon2D" parent="."]
polygon = PackedVector2Array(-8, -12, 8, -12, 8, 12, -8, 12)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("1")
[node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(0, 5)
zoom = Vector2(1.6, 1.6)
limit_left = -75
limit_top = 50
limit_right = 725
limit_bottom = 550

View File

@@ -0,0 +1,30 @@
[gd_scene load_steps=2 format=3 uid="uid://c1qnr7iky2k6f"]
[ext_resource type="PackedScene" uid="uid://b7leymer5mvxe" path="res://platform_player.tscn" id="1"]
[node name="PlatformGame" type="Node"]
[node name="Walls" type="Node" parent="."]
[node name="StaticBody2D" type="StaticBody2D" parent="Walls"]
position = Vector2(485.296, 379.731)
[node name="Polygon2D" type="Polygon2D" parent="Walls/StaticBody2D"]
color = Color(0.341461, 0.523438, 0.34857, 1)
polygon = PackedVector2Array(-435.83, 105.853, -388.346, 74.7186, -86.0178, 74.7186, -32.3343, 50.5918, 9.76965, 11.9966, 68.5397, 12.8737, 72.0483, 64.6264, 26.4358, 104.976)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Walls/StaticBody2D"]
polygon = PackedVector2Array(-436.296, 106.269, -388.296, 75.269, -86.296, 75.269, -33.1687, 51.2337, 10.564, 12.5471, 68.704, 13.269, 71.704, 64.269, 26.704, 105.269)
[node name="StaticBody2D2" type="StaticBody2D" parent="Walls"]
position = Vector2(491.464, 318.057)
[node name="Polygon2D" type="Polygon2D" parent="Walls/StaticBody2D2"]
color = Color(0.341461, 0.523438, 0.34857, 1)
polygon = PackedVector2Array(-330.327, 94.9664, -340.98, 82.6316, -113.906, 86.5563, -127.923, 96.6485)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Walls/StaticBody2D2"]
polygon = PackedVector2Array(-328.645, 96.0878, -341.217, 83.0776, -114.513, 86.9529, -126.802, 97.2092)
[node name="PlatformPlayer" parent="." instance=ExtResource("1")]
position = Vector2(393.654, 427.999)

View File

@@ -0,0 +1,25 @@
extends CharacterBody2D
var Bullet = preload("res://bullet.tscn")
var speed = 200
func get_input():
# Add these actions in Project Settings -> Input Map.
var input_dir = Input.get_axis("backward", "forward")
velocity = transform.x * input_dir * speed
if Input.is_action_just_pressed("shoot"):
shoot()
func shoot():
# "Muzzle" is a Marker2D placed at the barrel of the gun.
var b = Bullet.instantiate()
b.start($Muzzle.global_position, rotation)
get_tree().root.add_child(b)
func _physics_process(delta):
get_input()
var dir = get_global_mouse_position() - global_position
# Don't move if too close to the mouse pointer.
if dir.length() > 5:
rotation = dir.angle()
move_and_slide()

View File

@@ -6,20 +6,20 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=3
config_version=5
[application]
config/name="using_kinematic2d"
config/icon="res://icon.png"
config/name="using_character_body_2d"
config/features=PackedStringArray("4.0")
config/icon="res://icon.svg"
[display]
window/size/resizable=false
window/stretch/mode="2d"
window/size/test_width=1024
window/size/test_height=600
window/stretch/mode="2d"
window/stretch/aspect="keep"
window/stretch/shrink="1"
[importer_defaults]
@@ -45,12 +45,26 @@ texture={
[input]
forward=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
]
backward=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
]
mouse_click=[ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
]
forward={
"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":87,"physical_keycode":0,"key_label":0,"unicode":119,"echo":false,"script":null)
]
}
backward={
"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":83,"physical_keycode":0,"key_label":0,"unicode":115,"echo":false,"script":null)
]
}
shoot={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null)
]
}
jump={
"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,"echo":false,"script":null)
]
}
[layer_names]

View File

@@ -1,4 +1,4 @@
extends StaticBody2D
func hit():
$AnimationPlayer.play('flash')
$AnimationPlayer.play('flash')

View File

@@ -0,0 +1,43 @@
[gd_scene load_steps=5 format=3 uid="uid://bucigqlq6k64b"]
[ext_resource type="Script" path="res://wall.gd" id="1"]
[sub_resource type="RectangleShape2D" id="1"]
size = Vector2(340, 20)
[sub_resource type="Animation" id="2"]
resource_name = "flash"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Polygon2D:color")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_fphgc"]
_data = {
"flash": SubResource("2")
}
[node name="Wall" type="StaticBody2D"]
position = Vector2(390.63, 482)
collision_layer = 8
script = ExtResource("1")
[node name="Polygon2D" type="Polygon2D" parent="."]
polygon = PackedVector2Array(-170, -10, 170, -10, 170, 10, -170, 10)
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("1")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_fphgc")
}