Skip to content

Commit

Permalink
tidied up stage
Browse files Browse the repository at this point in the history
  • Loading branch information
cogwoz committed Nov 17, 2019
1 parent c33f9ff commit a020af8
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 191 deletions.
Binary file modified platformer-2d-rework/assets/art/platforms/moving_platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 21 additions & 21 deletions platformer-2d-rework/assets/art/tileset/tileset.tres
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ points = PoolVector2Array( 0, 12, 64, 12, 64, 64, 0, 64 )
[sub_resource type="ConvexPolygonShape2D" id=2]
points = PoolVector2Array( 0, 12, 56, 12, 56, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=8]
[sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=12]
[sub_resource type="ConvexPolygonShape2D" id=4]
points = PoolVector2Array( 0, 12, 64, 12, 64, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=3]
[sub_resource type="ConvexPolygonShape2D" id=5]
points = PoolVector2Array( 64, 76, 64, 128, 0, 128, 0, 12 )

[sub_resource type="ConvexPolygonShape2D" id=4]
[sub_resource type="ConvexPolygonShape2D" id=6]
points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=5]
[sub_resource type="ConvexPolygonShape2D" id=7]
points = PoolVector2Array( 56, 12, 64, 12, 64, 64, 0, 64, 0, 0, 56, 0 )

[sub_resource type="ConvexPolygonShape2D" id=6]
[sub_resource type="ConvexPolygonShape2D" id=8]
points = PoolVector2Array( 0, 12, 64, 12, 64, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=7]
points = PoolVector2Array( 0, 12, 56, 12, 56, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=9]
points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 )
points = PoolVector2Array( 0, 12, 56, 12, 56, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=10]
points = PoolVector2Array( 0, 0, 64, 0, 64, 64, 0, 64 )

[sub_resource type="ConvexPolygonShape2D" id=11]
points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
points = PoolVector2Array( 0, 0, 64, 0, 64, 48, 0, 48 )

[sub_resource type="ConvexPolygonShape2D" id=12]
points = PoolVector2Array( 0, 0, 56, 0, 56, 48, 0, 48 )

[resource]
0/name = "ground"
Expand Down Expand Up @@ -83,7 +83,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 3 ),
"shape": SubResource( 5 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
2/z_index = 0
Expand All @@ -99,7 +99,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 4 ),
"shape": SubResource( 6 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
3/z_index = 0
Expand All @@ -115,7 +115,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 5 ),
"shape": SubResource( 7 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
4/z_index = 0
Expand All @@ -131,7 +131,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": true,
"one_way_margin": 1.0,
"shape": SubResource( 6 ),
"shape": SubResource( 8 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
5/z_index = 0
Expand All @@ -147,7 +147,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": true,
"one_way_margin": 1.0,
"shape": SubResource( 7 ),
"shape": SubResource( 9 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
6/z_index = 0
Expand All @@ -163,7 +163,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 9 ),
"shape": SubResource( 10 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
7/z_index = 0
Expand All @@ -179,7 +179,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 10 ),
"shape": SubResource( 11 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
8/z_index = 0
Expand All @@ -195,7 +195,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 11 ),
"shape": SubResource( 12 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
9/z_index = 0
Expand All @@ -211,7 +211,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 8 ),
"shape": SubResource( 3 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
10/z_index = 0
Expand Down Expand Up @@ -247,7 +247,7 @@ points = PoolVector2Array( 0, 0, 56, 0, 56, 64, 0, 64 )
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 12 ),
"shape": SubResource( 4 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
13/z_index = 0
Expand Down
2 changes: 1 addition & 1 deletion platformer-2d-rework/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/Actors/Gun.gd"
}, {
"base": "KinematicBody2D",
"base": "Node2D",
"class": "MovingPlatform",
"language": "GDScript",
"path": "res://src/Platforms/MovingPlatform.gd"
Expand Down
11 changes: 10 additions & 1 deletion platformer-2d-rework/src/Actors/Actor.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
extends KinematicBody2D
class_name Actor

"""
Both the Player and Enemy inherit this scene as they have shared behaviours such as
speed and are affected by gravity.
"""


export var speed: = Vector2(400.0, 500.0)
export var gravity: = 3500.0
Expand All @@ -9,6 +14,10 @@ const FLOOR_NORMAL: = Vector2.UP

var _velocity: = Vector2.ZERO


"""
_physics_process is called after the inherited _physics_process function.
This allows the Player and Enemy scenes to be affected by gravity.
"""
func _physics_process(delta: float) -> void:

_velocity.y += gravity * delta
6 changes: 3 additions & 3 deletions platformer-2d-rework/src/Actors/Enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var _state = State.WALKING
This function is called when the scene enters the scene tree.
We can initialize variables here.
"""
func _ready():
func _ready() -> void:
_velocity.x = speed.x

"""
Expand All @@ -33,7 +33,7 @@ Splitting the physics process logic into functions not only makes it easier to r
- If you need to change a calculation, you can use Go To -> Function (Ctrl Alt F) to quickly jump to the corresponding function.
- If you split the character into a state machine or more advanced pattern, you can easily move individual functions.
"""
func _physics_process(delta):
func _physics_process(delta: float) -> void:
_velocity = calculate_move_velocity(_velocity)

# We only update the y value of _velocity as we want to handle the horizontal movement ourselves.
Expand All @@ -48,7 +48,7 @@ func _physics_process(delta):
animation_player.play(animation)


func destroy():
func destroy() -> void:
_state = State.DEAD
_velocity = Vector2.ZERO

Expand Down
1 change: 1 addition & 0 deletions platformer-2d-rework/src/Actors/Enemy.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ shape = SubResource( 5 )
[node name="Explosion" type="Particles2D" parent="."]
self_modulate = Color( 1, 1, 1, 0.12 )
material = SubResource( 6 )
emitting = false
amount = 32
lifetime = 0.5
one_shot = true
Expand Down
4 changes: 2 additions & 2 deletions platformer-2d-rework/src/Actors/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ change or improve the code later on:
"""
func _physics_process(delta: float) -> void:
var direction: = get_direction()

var is_jump_interrupted: = Input.is_action_just_released("jump") and _velocity.y < 0.0
_velocity = calculate_move_velocity(_velocity, direction, speed, is_jump_interrupted)

Expand Down Expand Up @@ -86,7 +86,7 @@ func calculate_move_velocity(
func get_new_animation(is_shooting: bool = false) -> String:
var animation_new: = ""
if is_on_floor():
animation_new = "run" if abs(_velocity.x) > 0 else "idle"
animation_new = "run" if abs(_velocity.x) > 0.1 else "idle"
else:
animation_new = "falling" if _velocity.y > 0 else "jumping"
if is_shooting:
Expand Down
75 changes: 18 additions & 57 deletions platformer-2d-rework/src/Objects/Coin.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=7 format=2]

[ext_resource path="res://assets/art/player/bullet/bullet.png" type="Texture" id=1]
[ext_resource path="res://assets/art/coin/coin.png" type="Texture" id=2]
[ext_resource path="res://assets/audio/sfx/coin_pickup.wav" type="AudioStream" id=3]
[ext_resource path="res://src/Objects/Coin.gd" type="Script" id=4]

[sub_resource type="Animation" id=2]
[sub_resource type="Animation" id=1]
resource_name = "picked"
length = 1.5
step = 0.25
Expand Down Expand Up @@ -36,68 +35,55 @@ tracks/1/keys = {
} ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("Particles:emitting")
tracks/2/path = NodePath("Sprite:self_modulate")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"times": PoolRealArray( 0, 0.98 ),
"times": PoolRealArray( 0.25, 1.25 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ true, false ]
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
}
tracks/3/type = "value"
tracks/3/path = NodePath("Sprite:self_modulate")
tracks/3/path = NodePath("Pickup:playing")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/keys = {
"times": PoolRealArray( 0.25, 1.25 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
"times": PoolRealArray( 0.01 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
}
tracks/4/type = "value"
tracks/4/path = NodePath("Pickup:playing")
tracks/4/path = NodePath(".:monitoring")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/keys = {
"times": PoolRealArray( 0.01 ),
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ true ]
"values": [ false ]
}
tracks/5/type = "value"
tracks/5/path = NodePath(".:monitoring")
tracks/5/path = NodePath("Sprite:position")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/keys = {
"times": PoolRealArray( 0 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ false ]
}
tracks/6/type = "value"
tracks/6/path = NodePath("Sprite:position")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/keys = {
"times": PoolRealArray( 0, 1.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 0, 0 ), Vector2( 0, -42 ) ]
}

[sub_resource type="Animation" id=1]
resource_name = "spinning"
[sub_resource type="Animation" id=2]
length = 1.5
loop = true
step = 0.25
Expand All @@ -116,23 +102,6 @@ tracks/0/keys = {

[sub_resource type="CircleShape2D" id=3]

[sub_resource type="CanvasItemMaterial" id=4]
blend_mode = 1

[sub_resource type="GradientTexture" id=5]

[sub_resource type="ParticlesMaterial" id=6]
emission_shape = 1
emission_sphere_radius = 10.0
flag_disable_z = true
gravity = Vector3( 0, 90, 0 )
initial_velocity = 121.98
angular_velocity = -2.49891e+038
orbit_velocity = 0.0
orbit_velocity_random = 0.0
scale = 0.2
color_ramp = SubResource( 5 )

[node name="Coin" type="Area2D"]
collision_layer = 0
script = ExtResource( 4 )
Expand All @@ -144,20 +113,12 @@ hframes = 4
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "spinning"
playback_speed = 1.5
anims/picked = SubResource( 2 )
anims/spinning = SubResource( 1 )
anims/picked = SubResource( 1 )
anims/spinning = SubResource( 2 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 3 )

[node name="Pickup" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 3 )

[node name="Particles" type="Particles2D" parent="."]
material = SubResource( 4 )
lifetime = 2.0
explosiveness = 1.0
draw_order = 65793
process_material = SubResource( 6 )
texture = ExtResource( 1 )
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
Loading

0 comments on commit a020af8

Please sign in to comment.