initial commit

main
Tylan Tyson 1 year ago
commit 63fe9eb62f

1
.gitignore vendored

@ -0,0 +1 @@
.DS_STORE

@ -0,0 +1,3 @@
source_md5="457c0a7f86e70ac9030adc9afdb46c6f"
dest_md5="3a4a088e13ed17cd7011a3f43306b7c6"

@ -0,0 +1,3 @@
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
dest_md5="a88e70cd2a781a9949d2f6ee2829937a"

@ -0,0 +1,3 @@
source_md5="856bc53ef0408e71bf5663288d9f1fa0"
dest_md5="ad99476f857fcc86b7e0b3c6d5501415"

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://tiles_packed.png" type="Texture" id=1]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 9, 9 )
[node name="Block" type="StaticBody2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 126, 36, 18, 18 )

@ -0,0 +1,35 @@
extends KinematicBody2D
onready var RightLedgeCheck: = $RightLedgeCheck
onready var LeftLedgeCheck: = $LeftLedgeCheck
onready var colisionPolygon: = $CollisionPolygon2D
var direction = Vector2.RIGHT
var velocity = Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _physics_process(delta):
var found_wall = is_on_wall()
var found_ledge = not RightLedgeCheck.is_colliding()
var found_left_ledge = not LeftLedgeCheck.is_colliding()
if found_wall or found_ledge or found_left_ledge:
direction *= -1
if $AnimatedSprite.flip_h:
$AnimatedSprite.flip_h = false
colisionPolygon.position.x = -0.5
else:
$AnimatedSprite.flip_h = true
colisionPolygon.position.x = 0.5
velocity = direction * 25
move_and_slide(velocity, Vector2.UP)

@ -0,0 +1,51 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://characters_packed.png" type="Texture" id=1]
[ext_resource path="res://Enemies/WalkingEnemy/WalkingEnemy.gd" type="Script" id=2]
[ext_resource path="res://Res/Hitbox.tscn" type="PackedScene" id=3]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 144, 24, 24, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 168, 24, 24, 24 )
[sub_resource type="SpriteFrames" id=3]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ) ],
"loop": true,
"name": "Walking",
"speed": 5.0
} ]
[node name="KinematicBody2D" type="KinematicBody2D"]
collision_layer = 2
script = ExtResource( 2 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
position = Vector2( 0.5, -9 )
scale = Vector2( 0.75, 0.9 )
polygon = PoolVector2Array( 2, -10, 2, -8.88889, 3.33333, -8.88889, 3.33333, -6.66667, 4.66667, -6.66667, 4.66667, -3.33333, 7.33333, -3.33333, 7.33333, -2.22222, 8.66667, -2.22222, 8.66667, -1.11111, 10, -1.11111, 10, 8.88889, 7.33333, 10, -7.33333, 10, -10, 8.88889, -10, -1.11111, -8.66667, -1.11111, -8.66667, -2.22222, -7.33333, -2.22222, -7.33333, -3.33333, -4.66667, -3.33333, -4.66667, -6.66667, -3.33333, -6.66667, -3.33333, -8.88889, -2, -8.88889, -2, -10 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 0, -12 )
frames = SubResource( 3 )
animation = "Walking"
flip_h = true
[node name="RightLedgeCheck" type="RayCast2D" parent="."]
position = Vector2( 8, 0 )
enabled = true
cast_to = Vector2( 0, 5 )
[node name="LeftLedgeCheck" type="RayCast2D" parent="."]
position = Vector2( -6, 0 )
enabled = true
cast_to = Vector2( 0, 5 )
[node name="Hitbox" parent="." instance=ExtResource( 3 )]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hitbox"]
polygon = PoolVector2Array( 1, -16, 2, -14, 2, -10, 5, -10, 6, -9, 6, -2, 4, -2, 4, -3, 0, -3, 0, -2, -2, -2, -2, -3, -5, -3, -5, -9, -4, -10, -1, -10, -1, -14, 0, -16 )

@ -0,0 +1,2 @@
extends Area2D
class_name Ladder

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Ladder.gd" type="Script" id=1]
[ext_resource path="res://tiles_packed.png" type="Texture" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 9, 9 )
[node name="Area2D" type="Area2D"]
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
region_enabled = true
region_rect = Rect2( 198, 54, 18, 18 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )

@ -0,0 +1,3 @@
extends StaticBody2D
class_name LadderTop

@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://tiles_packed.png" type="Texture" id=1]
[ext_resource path="res://LadderTop.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 9, 7.5 )
[node name="Area2D" type="StaticBody2D"]
collision_mask = 2
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 198, 36, 18, 18 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 1.64787e-05, 1.5 )
shape = SubResource( 1 )
one_way_collision = true

@ -0,0 +1,37 @@
[gd_resource type="SpriteFrames" load_steps=6 format=2]
[ext_resource path="res://characters_packed.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 96, 0, 24, 24 )
[sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 1 )
region = Rect2( 120, 0, 24, 24 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 120, 0, 24, 24 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 1 )
region = Rect2( 96, 0, 24, 24 )
[resource]
animations = [ {
"frames": [ SubResource( 2 ) ],
"loop": true,
"name": "Idle",
"speed": 5.0
}, {
"frames": [ SubResource( 7 ) ],
"loop": true,
"name": "Jump",
"speed": 5.0
}, {
"frames": [ SubResource( 5 ), SubResource( 6 ) ],
"loop": true,
"name": "Run",
"speed": 5.0
} ]

@ -0,0 +1,154 @@
# Extends
extends KinematicBody2D
class_name Player
enum { MOVE, CLIMB, TRANSITION }
export(Resource) var moveData
var velocity = Vector2.ZERO
var state = MOVE
onready var animatedSprite = $AnimatedSprite
onready var ladderCheck = $LadderCheck
onready var ladderCheckTwo = $LadderCheck2
func _ready():
animatedSprite.frames = load("res://PinkPlayerSkin.tres")
# Called every physics frame.
func _physics_process(delta):
var input = Vector2.ZERO
input.x = Input.get_axis("ui_left", "ui_right")
input.y = Input.get_axis("ui_up", "ui_down")
print(state)
match state:
MOVE: move_state(input)
CLIMB: climb_state(input)
TRANSITION: transition_state(input)
func is_on_ladder():
if not ladderCheck.is_colliding(): return false
var collider = ladderCheck.get_collider()
if not collider is Ladder and not collider is LadderTop: return false
return true
func is_ontop_ladder():
if ladderCheck.is_colliding():
if ladderCheck.get_collider() is LadderTop:
if not ladderCheckTwo.is_colliding():
return true
return false
func apply_gravity():
velocity.y += moveData.GRAVITY
velocity.y = min(velocity.y, 200)
func apply_friction():
velocity.x = move_toward(velocity.x, 0, moveData.FRICTION)
func apply_acceleration(amount):
velocity.x = move_toward(velocity.x, moveData.MAXIMUM_SPEED * amount, moveData.ACCELERATION)
pass
func move_state(input):
if not is_on_ladder() and not is_ontop_ladder(): state = MOVE
if is_on_ladder(): state = CLIMB
if is_ontop_ladder(): state = TRANSITION
apply_gravity()
if input.x > 0:
animatedSprite.flip_h = true
if input.x < 0:
animatedSprite.flip_h = false
if input.x == 0:
apply_friction()
animatedSprite.animation = "Idle"
else:
apply_acceleration(input.x)
animatedSprite.animation = "Run"
if is_on_floor():
if Input.is_action_just_pressed("ui_up"):
velocity.y = moveData.MAXIMUM_JUMP
else:
animatedSprite.animation = "Jump"
if Input.is_action_just_released("ui_up") and velocity.y < moveData.MINIMUM_JUMP:
velocity.y = moveData.MINIMUM_JUMP
if velocity.y > 0:
velocity.y += moveData.ADDITIONAL_FALL_GRAVITY
var was_in_air = not is_on_floor()
velocity = move_and_slide(velocity, Vector2.UP)
var just_landed = is_on_floor() and was_in_air
if just_landed:
animatedSprite.animation = "Run"
animatedSprite.frame = 1
func climb_state(input):
if not is_on_ladder() and not is_ontop_ladder(): state = MOVE
if is_on_ladder(): state = CLIMB
if is_ontop_ladder(): state = TRANSITION
velocity = input * 50
velocity = move_and_slide(velocity, Vector2.UP)
func transition_state(input):
if not is_on_ladder() and not is_ontop_ladder(): state = MOVE
if is_on_ladder(): state = CLIMB
if is_ontop_ladder(): state = TRANSITION
if not is_ontop_ladder():
velocity.y += moveData.GRAVITY
velocity.y = min(velocity.y, 200)
if input.x > 0:
animatedSprite.flip_h = true
if input.x < 0:
animatedSprite.flip_h = false
if input.x == 0:
apply_friction()
animatedSprite.animation = "Idle"
else:
apply_acceleration(input.x)
animatedSprite.animation = "Run"
if is_ontop_ladder():
if Input.is_action_just_pressed("ui_up"):
velocity.y = moveData.MAXIMUM_JUMP
else:
animatedSprite.animation = "Jump"
if Input.is_action_just_released("ui_up") and velocity.y < moveData.MINIMUM_JUMP:
velocity.y = moveData.MINIMUM_JUMP
if velocity.y > 0:
velocity.y += moveData.ADDITIONAL_FALL_GRAVITY
if Input.is_action_just_pressed("ui_down"):
var tr = ladderCheck.get_collider().get_node("CollisionShape2D").get_transform()
tr.origin = Vector2.ZERO
tr = tr.rotated(float(180))
ladderCheck.get_collider().get_node("CollisionShape2D").set_transform(tr)
velocity.y = 10
var was_in_air = not is_ontop_ladder()
velocity = move_and_slide(velocity, Vector2.UP)
var just_landed = is_ontop_ladder() and was_in_air
if just_landed:
animatedSprite.animation = "Run"
animatedSprite.frame = 1

@ -0,0 +1,36 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://PinkPlayerSkin.tres" type="SpriteFrames" id=1]
[ext_resource path="res://Player.gd" type="Script" id=2]
[ext_resource path="res://Settings/Resources/PlayerMovementSettings.tres" type="Resource" id=3]
[node name="Player" type="KinematicBody2D"]
collision_layer = 2
script = ExtResource( 2 )
moveData = ExtResource( 3 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = ExtResource( 1 )
animation = "Idle"
playing = true
flip_h = true
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
scale = Vector2( 1, 1.2 )
polygon = PoolVector2Array( -5, 10, -6, 9.16667, -7, 7.5, -8, 5.83333, -9, 5, -10, 3.33333, -10, -5.83333, -9, -7.5, -8, -8.33333, -6, -9.16667, 6, -9.16667, 8, -8.33333, 9, -7.5, 10, -5.83333, 10, 3.33333, 9, 5, 8, 5.83333, 7, 8.33333, 6, 9.16667, 5, 10 )
[node name="Camera2D" type="Camera2D" parent="."]
current = true
process_mode = 0
smoothing_enabled = true
smoothing_speed = 1.0
[node name="LadderCheck" type="RayCast2D" parent="."]
enabled = true
cast_to = Vector2( 0, 13 )
collide_with_areas = true
[node name="LadderCheck2" type="RayCast2D" parent="."]
enabled = true
cast_to = Vector2( 0, 10 )
collide_with_areas = true

@ -0,0 +1,23 @@
extends Area2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Hitbox_body_entered(body):
if body is Player:
get_tree().reload_current_scene()

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Res/Hitbox.gd" type="Script" id=1]
[node name="Hitbox" type="Area2D"]
collision_layer = 0
collision_mask = 2
script = ExtResource( 1 )
[connection signal="body_entered" from="." to="." method="_on_Hitbox_body_entered"]

@ -0,0 +1,6 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://Settings/Scripts/PlayerMovementSettings.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )

@ -0,0 +1,9 @@
[gd_scene format=2]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Button" type="Button" parent="."]
margin_right = 45.0
margin_bottom = 20.0

@ -0,0 +1,14 @@
# Extends
extends Resource
# Class Name
class_name Player_Movement_Settings
# Settings
export(int) var MAXIMUM_JUMP = - 130
export(int) var MINIMUM_JUMP = - 70
export(int) var MAXIMUM_SPEED = 50
export(int) var ACCELERATION = 10
export(int) var FRICTION = 10
export(int) var GRAVITY = 4
export(int) var ADDITIONAL_FALL_GRAVITY = 4

@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://tiles_packed.png" type="Texture" id=1]
[ext_resource path="res://Res/Hitbox.tscn" type="PackedScene" id=2]
[node name="Area2D" type="Node2D"]
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, -9 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 144, 54, 18, 18 )
[node name="Hitbox" parent="." instance=ExtResource( 2 )]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hitbox"]
position = Vector2( 0, -5 )
scale = Vector2( 1, 0.5 )
polygon = PoolVector2Array( -7, 10, -7, 4, -6, 0, -5, -4, -3, -4, -2, 0, -1, 4, -1, 8, 1, 8, 1, 4, 2, 4, 2, 0, 3, 0, 3, -4, 5, -4, 5, 0, 6, 0, 6, 4, 7, 4, 7, 10, 0, 10 )

File diff suppressed because one or more lines are too long

@ -0,0 +1,11 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
VisualServer.set_default_clear_color(Color.lightblue)

@ -0,0 +1,56 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://TileMap.tscn" type="PackedScene" id=1]
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://Spikes.tscn" type="PackedScene" id=3]
[ext_resource path="res://World.gd" type="Script" id=4]
[ext_resource path="res://Enemies/WalkingEnemy/WalkingEnemy.tscn" type="PackedScene" id=5]
[ext_resource path="res://Ladder.tscn" type="PackedScene" id=6]
[ext_resource path="res://LadderTop.tscn" type="PackedScene" id=7]
[node name="World" type="Node2D"]
script = ExtResource( 4 )
[node name="KinematicBody2D2" parent="." instance=ExtResource( 5 )]
position = Vector2( 283, 126 )
[node name="TileMap" parent="." instance=ExtResource( 1 )]
[node name="Area2D" parent="." instance=ExtResource( 3 )]
position = Vector2( 80, 146 )
[node name="Area2D2" parent="." instance=ExtResource( 3 )]
position = Vector2( 97, 146 )
[node name="Area2D3" parent="." instance=ExtResource( 3 )]
position = Vector2( 243, 164 )
[node name="Area2D4" parent="." instance=ExtResource( 3 )]
position = Vector2( 261, 164 )
[node name="Area2D5" parent="." instance=ExtResource( 3 )]
position = Vector2( 603, 236 )
[node name="Area2D6" parent="." instance=ExtResource( 3 )]
position = Vector2( 621, 236 )
[node name="KinematicBody2D" parent="." instance=ExtResource( 5 )]
position = Vector2( 134, 144 )
[node name="KinematicBody2D3" parent="." instance=ExtResource( 5 )]
position = Vector2( 609, 144 )
[node name="Area2D7" parent="." instance=ExtResource( 6 )]
position = Vector2( 387, 225 )
[node name="Area2D8" parent="." instance=ExtResource( 6 )]
position = Vector2( 387, 207 )
[node name="Area2D9" parent="." instance=ExtResource( 6 )]
position = Vector2( 387, 189 )
[node name="Area2D10" parent="." instance=ExtResource( 7 )]
position = Vector2( 387, 171 )
[node name="Player" parent="." instance=ExtResource( 2 )]
position = Vector2( 417, 148 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/characters_packed.png-890290c811414ed077a6b10fd28e12f1.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://characters_packed.png"
dest_files=[ "res://.import/characters_packed.png-890290c811414ed077a6b10fd28e12f1.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=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
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=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
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

@ -0,0 +1,93 @@
; 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=4
_global_script_classes=[ {
"base": "Area2D",
"class": "Ladder",
"language": "GDScript",
"path": "res://Ladder.gd"
}, {
"base": "StaticBody2D",
"class": "LadderTop",
"language": "GDScript",
"path": "res://LadderTop.gd"
}, {
"base": "KinematicBody2D",
"class": "Player",
"language": "GDScript",
"path": "res://Player.gd"
}, {
"base": "Resource",
"class": "Player_Movement_Settings",
"language": "GDScript",
"path": "res://Settings/Scripts/PlayerMovementSettings.gd"
} ]
_global_script_class_icons={
"Ladder": "",
"LadderTop": "",
"Player": "",
"Player_Movement_Settings": ""
}
[application]
config/name="Pixel Platformer"
run/main_scene="res://World.tscn"
config/icon="res://icon.png"
[display]
window/size/width=320
window/size/height=180
window/size/test_width=1280
window/size/test_height=720
window/stretch/mode="2d"
[gui]
common/drop_mouse_on_gui_input_disabled=true
[importer_defaults]
texture={
"compress/bptc_ldr": 0,
"compress/hdr_mode": 0,
"compress/lossy_quality": 0.7,
"compress/mode": 0,
"compress/normal_map": 0,
"detect_3d": false,
"flags/anisotropic": false,
"flags/filter": false,
"flags/mipmaps": false,
"flags/repeat": 0,
"flags/srgb": 2,
"process/HDR_as_SRGB": false,
"process/fix_alpha_border": true,
"process/invert_color": false,
"process/normal_map_invert_y": false,
"process/premult_alpha": false,
"size_limit": 0,
"stream": false,
"svg/scale": 1.0
}
[layer_names]
2d_physics/layer_1="World"
2d_physics/layer_2="Characters"
[physics]
common/enable_pause_aware_picking=true
[rendering]
2d/snapping/use_gpu_pixel_snap=true
environment/default_environment="res://default_env.tres"

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/tiles_packed.png-fd6b33d2b56a22feb83002d47ed8ee64.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://tiles_packed.png"
dest_files=[ "res://.import/tiles_packed.png-fd6b33d2b56a22feb83002d47ed8ee64.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=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
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Loading…
Cancel
Save