adjusted level and barrier

This commit is contained in:
pennyrigate 2022-12-19 21:08:18 -05:00
parent 209884f133
commit b2baccfa57
16 changed files with 138 additions and 46 deletions

View file

@ -1,15 +1,24 @@
extends Node2D
export var cost = 0
export var label_offset = Vector2.ZERO
onready var label = $Label
onready var sprite = $Sprite
onready var hitbox = $StaticBody2D/CollisionShape2D
func _ready():
if scale.y != 1:
sprite.set_region_rect(Rect2(0,0,4,scale.y))
hitbox.scale.y = scale.y
scale.y = 1
#Label
label.visible = true
label.set_text(str(cost))
label.rect_position.y = scale.y / 2
func _physics_process(delta):
#Open
if Game.golds >= cost: $AnimationPlayer.play("open")
if Game.golds >= cost: queue_free()
func _on_AnimationPlayer_animation_finished(anim_name):
if anim_name == "open":

View file

@ -1,11 +1,11 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://objects/barrier/barrier.gd" type="Script" id=1]
[ext_resource path="res://graphics/barrier/barrier.png" type="Texture" id=2]
[ext_resource path="res://graphics/barrier/barrier_2px.png" type="Texture" id=2]
[ext_resource path="res://fonts/2ndpuberty..fnt" type="BitmapFont" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 2, 8 )
extents = Vector2( 2, 0.5 )
[sub_resource type="Animation" id=4]
resource_name = "initial"
@ -97,12 +97,12 @@ script = ExtResource( 1 )
texture = ExtResource( 2 )
centered = false
region_enabled = true
region_rect = Rect2( 0, 0, 16, 16 )
region_rect = Rect2( 0, 0, 4, 1 )
[node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
position = Vector2( 8, 8 )
position = Vector2( 2, 0.5 )
shape = SubResource( 1 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
@ -110,13 +110,12 @@ anims/initial = SubResource( 4 )
anims/open = SubResource( 3 )
[node name="Label" type="Label" parent="."]
visible = false
margin_left = -12.0
margin_left = -18.0
margin_top = -15.0
margin_right = 28.0
margin_right = 22.0
margin_bottom = 5.0
theme = SubResource( 5 )
text = "0"
text = "00"
align = 1
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]

View file

@ -26,7 +26,7 @@ animations = [ {
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 8, 8 )
extents = Vector2( 5.5, 6 )
[node name="Snake" type="Node2D"]
script = ExtResource( 3 )
@ -39,9 +39,9 @@ frame = 1
playing = true
[node name="Area2D" type="Area2D" parent="."]
visible = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 0.5, 2 )
shape = SubResource( 5 )
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]

View file

@ -17,7 +17,9 @@ position = Vector2( 4, 4 )
shape = SubResource( 1 )
[node name="LeftSnap" type="Position2D" parent="."]
visible = false
position = Vector2( 0, 4 )
[node name="RightSnap" type="Position2D" parent="."]
visible = false
position = Vector2( 8, 4 )

View file

@ -14,6 +14,7 @@ enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT}
var current_state = State.IDLE
##Runtime
var axis = Vector2.ZERO #Current direction being held
var trail_color = Color(0.25,0,1,0.4)
#Physics
var velocity = Vector2.ZERO
var walk_speed = 50
@ -66,9 +67,7 @@ func _physics_process(delta):
#Apply velocity
move_and_slide(velocity,Vector2.UP)
#Debug
if Input.is_action_pressed("debug_move_player"):
position = get_viewport().get_mouse_position()
print(get_viewport().get_mouse_position())
debug()
func _process_idle():
if anims.get_current_animation() != "idle": anims.play("idle")
@ -246,3 +245,8 @@ func _on_AnimationPlayer_animation_finished(anim_name):
else:
current_state = State.FALL
return
func debug():
#Move player to mouse
if Input.is_action_pressed("debug_move_player"):
position = get_viewport().get_mouse_position()
print(get_viewport().get_mouse_position())

View file

@ -15,7 +15,8 @@
[ext_resource path="res://scripts/recolor.tres" type="Shader" id=13]
[ext_resource path="res://graphics/player/sg_doublejump.png" type="Texture" id=14]
[sub_resource type="ShaderMaterial" id=27]
[sub_resource type="ShaderMaterial" id=38]
resource_local_to_scene = true
shader = ExtResource( 4 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = true
@ -598,8 +599,10 @@ extents = Vector2( 6, 7 )
[node name="Player" type="KinematicBody2D"]
script = ExtResource( 1 )
[node name="Trail" type="Node" parent="."]
[node name="Sprite" type="Sprite" parent="."]
material = SubResource( 27 )
material = SubResource( 38 )
texture = ExtResource( 3 )
region_enabled = true
region_rect = Rect2( 0, 0, 20, 20 )