1
0
Fork 0

Compare commits

...

5 Commits

Author SHA1 Message Date
Felipe M 0f3f6f0133
Missiles unlockable 2021-05-18 21:05:50 +02:00
Felipe M 2e1bcbc225
Missiles break bricks 2021-05-18 20:53:49 +02:00
Felipe M 632d927938
Missiles limit & UI 2021-05-18 20:43:07 +02:00
Felipe M 853eb28d33
Player Missile 2021-05-18 20:33:18 +02:00
Felipe M b7b4d03fda
Fixed crawling enemy 2021-05-18 20:17:08 +02:00
19 changed files with 269 additions and 25 deletions

View File

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

View File

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/PlayerMissle.png-2c0430788415884763891e31b76bacad.stex"
path="res://.import/PlayerMissile.png-f8921134c7e116ae2eaef486ddb58b3b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Player/PlayerMissle.png"
dest_files=[ "res://.import/PlayerMissle.png-2c0430788415884763891e31b76bacad.stex" ]
source_file="res://Assets/Player/PlayerMissile.png"
dest_files=[ "res://.import/PlayerMissile.png-f8921134c7e116ae2eaef486ddb58b3b.stex" ]
[params]

View File

@ -19,7 +19,7 @@ func _physics_process(delta):
floorCast.rotation_degrees = -MAX_SPEED * 10 * WALKING_DIRECTION * delta
if floorCast.is_colliding():
global_position = floorCast.get_collision_point()
var normal = wallCast.get_collision_normal()
var normal = floorCast.get_collision_normal()
rotation = normal.rotated(deg2rad(90)).angle()
else:
rotation_degrees += 20 * WALKING_DIRECTION

View File

@ -4,7 +4,7 @@
[ext_resource path="res://Assets/Enemies/CrawlingEnemy.png" type="Texture" id=2]
[ext_resource path="res://Scenes/Enemies/CrawlingEnemy.gd" type="Script" id=3]
[sub_resource type="Animation" id=3]
[sub_resource type="Animation" id=1]
resource_name = "Animate"
length = 0.8
loop = true
@ -18,13 +18,13 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 1,
"values": [ 0, 1, 1, 1 ]
"values": [ 0, 1, 2, 3 ]
}
[sub_resource type="RectangleShape2D" id=1]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 7, 3 )
[sub_resource type="RectangleShape2D" id=2]
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 5, 2 )
[node name="CrawlingEnemy" instance=ExtResource( 1 )]
@ -34,24 +34,24 @@ script = ExtResource( 3 )
position = Vector2( 0, -8 )
texture = ExtResource( 2 )
hframes = 4
frame = 1
frame = 3
[node name="AnimationPlayer" parent="." index="2"]
autoplay = "Animate"
anims/Animate = SubResource( 3 )
anims/Animate = SubResource( 1 )
[node name="Collider" parent="Hurtbox" index="0"]
position = Vector2( 0, -3 )
shape = SubResource( 1 )
shape = SubResource( 2 )
[node name="Collider" parent="Hitbox" index="0"]
position = Vector2( 0, -2 )
shape = SubResource( 2 )
shape = SubResource( 3 )
[node name="FloorCast" type="RayCast2D" parent="." index="6"]
position = Vector2( 0, -4 )
enabled = true
cast_to = Vector2( 0, 4 )
cast_to = Vector2( 0, 8 )
collision_mask = 2
[node name="WallCast" type="RayCast2D" parent="." index="7"]
@ -61,5 +61,4 @@ cast_to = Vector2( 4, 0 )
collision_mask = 2
[editable path="Hurtbox"]
[editable path="Hitbox"]

View File

@ -6,11 +6,13 @@
extents = Vector2( 8, 8 )
[node name="Brick" type="StaticBody2D"]
collision_layer = 18
collision_mask = 0
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
[node name="Collider" type="CollisionShape2D" parent="."]
position = Vector2( 8, 8 )
shape = SubResource( 1 )

View File

@ -0,0 +1,5 @@
extends Powerup
func _pickup():
PlayerStats.missiles_unlocked = true
queue_free()

View File

@ -0,0 +1,18 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Scenes/Player/PowerUp.tscn" type="PackedScene" id=1]
[ext_resource path="res://Assets/Player/PlayerMissile.png" type="Texture" id=2]
[ext_resource path="res://Scenes/Player/MissilesPowerup.gd" type="Script" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 3, 7 )
[node name="MissilesPowerup" instance=ExtResource( 1 )]
script = ExtResource( 3 )
[node name="Sprite" parent="." index="0"]
rotation = -1.5708
texture = ExtResource( 2 )
[node name="Collision" parent="." index="1"]
shape = SubResource( 1 )

View File

@ -3,6 +3,7 @@ extends KinematicBody2D
const DustEffect = preload("res://Scenes/Effects/DustEffect.tscn")
const WallDustEffect = preload("res://Scenes/Effects/WallDustEffect.tscn")
const PlayerBullet = preload("res://Scenes/Player/PlayerBullet.tscn")
const PlayerMissile = preload("res://Scenes/Player/PlayerMissile.tscn")
const JumpEffect = preload("res://Scenes/Effects/JumpEffect.tscn")
var PlayerStats = ResourceLoader.PlayerStats
@ -17,6 +18,7 @@ export (int) var wall_slide_speed = 42
export (int) var max_wall_slide_speed = 128
export (int) var max_slope = 46
export (int) var bullet_speed = 250
export (int) var missile_speed = 250
enum {
MOVE,
@ -37,6 +39,7 @@ onready var playerGun = $Sprite/PlayerGun
onready var muzzle = $Sprite/PlayerGun/Sprite/Muzzle
onready var fireBulletTimer = $FireBulletTimer
onready var blinkAnimator = $BlinkAnimator
onready var powerupDetector = $PowerupDetector
func set_invincible(value):
@ -79,6 +82,9 @@ func _physics_process(delta):
if Input.is_action_pressed("fire") and fireBulletTimer.time_left == 0:
fire_bullet()
if Input.is_action_pressed("fire_missile") and fireBulletTimer.time_left == 0 and PlayerStats.missiles > 0 and PlayerStats.missiles_unlocked:
fire_missile()
func fire_bullet():
var bullet = Utils.instance_scene_on_main(PlayerBullet, muzzle.global_position)
@ -87,6 +93,15 @@ func fire_bullet():
bullet.rotation = bullet.velocity.angle()
fireBulletTimer.start()
func fire_missile():
var missile = Utils.instance_scene_on_main(PlayerMissile, muzzle.global_position)
missile.velocity = Vector2.RIGHT.rotated(playerGun.rotation) * missile_speed
missile.velocity.x *= sprite.scale.x # Flip left/right depending on players direction
motion -= missile.velocity * 0.25
missile.rotation = missile.velocity.angle()
fireBulletTimer.start()
PlayerStats.missiles -= 1
func create_dust_effect():
var dust_position = global_position
dust_position.x += rand_range(-4, 4)
@ -134,7 +149,9 @@ func apply_gravity(delta):
motion.y = min(motion.y, jump_force)
func update_animations(input_vector):
sprite.scale.x = sign(get_local_mouse_position().x)
var facing = sign(get_local_mouse_position().x)
if facing != 0:
sprite.scale.x = facing
animation.playback_speed = 1
if input_vector.x != 0:
@ -221,3 +238,7 @@ func _on_Hurtbox_hit(damage):
func _on_died():
queue_free()
func _on_PowerupDetector_area_entered(area):
if area is Powerup:
area._pickup()

View File

@ -74,7 +74,7 @@ tracks/1/keys = {
} ]
}
[sub_resource type="Animation" id=5]
[sub_resource type="Animation" id=4]
resource_name = "WallSlide"
length = 0.1
tracks/0/type = "value"
@ -90,8 +90,7 @@ tracks/0/keys = {
"values": [ 10 ]
}
[sub_resource type="Animation" id=4]
resource_name = "Blink"
[sub_resource type="Animation" id=5]
length = 0.9
tracks/0/type = "value"
tracks/0/path = NodePath("Sprite:visible")
@ -145,10 +144,10 @@ shape = ExtResource( 6 )
anims/Idle = SubResource( 1 )
anims/Jump = SubResource( 2 )
anims/Run = SubResource( 3 )
anims/WallSlide = SubResource( 5 )
anims/WallSlide = SubResource( 4 )
[node name="BlinkAnimator" type="AnimationPlayer" parent="."]
anims/Blink = SubResource( 4 )
anims/Blink = SubResource( 5 )
[node name="Debug" parent="." instance=ExtResource( 3 )]
visible = false
@ -174,6 +173,16 @@ position = Vector2( 0, -7 )
shape = ExtResource( 6 )
[node name="InvincibleTimer" type="Timer" parent="."]
[node name="PowerupDetector" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 32
[node name="Collision" type="CollisionShape2D" parent="PowerupDetector"]
position = Vector2( 0, -7 )
shape = ExtResource( 6 )
[connection signal="hit" from="Hurtbox" to="." method="_on_Hurtbox_hit"]
[connection signal="area_entered" from="PowerupDetector" to="." method="_on_PowerupDetector_area_entered"]
[editable path="Hurtbox"]

View File

@ -0,0 +1,15 @@
extends "res://Scenes/Objects/Proyectile.gd"
const EnemyDeathEffect = preload("res://Scenes/Effects/EnemyDeathEffect.tscn")
const BRICK_LAYER_BIT = 4
func _ready():
pass # Replace with function body.
func _on_Hitbox_body_entered(body):
if body.get_collision_layer_bit(BRICK_LAYER_BIT):
body.queue_free()
Utils.instance_scene_on_main(EnemyDeathEffect, body.global_position + Vector2(8, 8))
._on_Hitbox_body_entered(body)

View File

@ -0,0 +1,53 @@
[gd_scene load_steps=9 format=2]
[ext_resource path="res://Assets/Player/PlayerMissile.png" type="Texture" id=1]
[ext_resource path="res://Scenes/Objects/Proyectile.tscn" type="PackedScene" id=2]
[ext_resource path="res://Assets/Effects/Particle.png" type="Texture" id=3]
[ext_resource path="res://Scenes/Player/PlayerMissile.gd" type="Script" id=4]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 2 )
[sub_resource type="Curve" id=2]
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=3]
curve = SubResource( 2 )
[sub_resource type="ParticlesMaterial" id=4]
emission_shape = 2
emission_box_extents = Vector3( 0, 2, 0 )
flag_disable_z = true
gravity = Vector3( 0, 10, 0 )
initial_velocity = 5.0
initial_velocity_random = 0.5
orbit_velocity = 0.0
orbit_velocity_random = 0.0
scale_curve = SubResource( 3 )
[node name="PlayerMissile" instance=ExtResource( 2 )]
script = ExtResource( 4 )
[node name="Sprite" parent="." index="0"]
texture = ExtResource( 1 )
[node name="VisibilityNotifier2D" parent="." index="1"]
position = Vector2( -0.5, 0 )
scale = Vector2( 2.125, 1 )
[node name="Hitbox" parent="." index="3"]
collision_mask = 26
damage = 3
[node name="Collider" parent="Hitbox" index="0"]
shape = SubResource( 1 )
[node name="Particles2D" type="Particles2D" parent="." index="4"]
position = Vector2( -8, 0 )
lifetime = 0.4
preprocess = 0.2
local_coords = false
process_material = SubResource( 4 )
texture = ExtResource( 3 )
[editable path="Hitbox"]

View File

@ -3,8 +3,13 @@ class_name PlayerStats
var max_health = 4
var health = max_health setget set_health
var missiles_unlocked = false setget set_missiles_unlocked
var max_missiles = 3
var missiles = max_missiles setget set_missiles
signal player_health_changed(value)
signal player_missiles_unlocked(value)
signal player_missiles_changed(value)
signal player_died
func set_health(value):
@ -16,3 +21,11 @@ func set_health(value):
if health == 0:
emit_signal("player_died")
func set_missiles(value):
missiles = clamp(value, 0, max_missiles)
emit_signal("player_missiles_changed", missiles)
func set_missiles_unlocked(value):
missiles_unlocked = value
emit_signal("player_missiles_unlocked", value)

View File

@ -0,0 +1,7 @@
extends Area2D
class_name Powerup
var PlayerStats = ResourceLoader.PlayerStats
func _pickup():
pass

View File

@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Scenes/Player/PowerUp.gd" type="Script" id=1]
[node name="PowerUp" type="Area2D"]
collision_layer = 32
collision_mask = 0
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
[node name="Collision" type="CollisionShape2D" parent="."]

View File

@ -0,0 +1,15 @@
extends HBoxContainer
var PlayerStats = ResourceLoader.PlayerStats
onready var label = $Label
func _ready():
PlayerStats.connect("player_missiles_changed", self, "_on_player_missiles_changed")
PlayerStats.connect("player_missiles_unlocked", self, "_on_player_missiles_unlocked")
func _on_player_missiles_changed(value):
label.text = str(value)
func _on_player_missiles_unlocked(value):
visible = value

View File

@ -0,0 +1,28 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Assets/UI/PlayerMissileIcon.png" type="Texture" id=1]
[ext_resource path="res://Scenes/UI/PixelFont.tres" type="DynamicFont" id=2]
[ext_resource path="res://Scenes/UI/MissilesUI.gd" type="Script" id=3]
[node name="MissilesUI" type="HBoxContainer"]
visible = false
margin_right = 33.0
margin_bottom = 12.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Icon" type="TextureRect" parent="."]
margin_right = 8.0
margin_bottom = 12.0
texture = ExtResource( 1 )
[node name="Label" type="Label" parent="."]
margin_left = 12.0
margin_right = 17.0
margin_bottom = 7.0
size_flags_horizontal = 2
size_flags_vertical = 2
custom_fonts/font = ExtResource( 2 )
text = "3"

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Scenes/UI/HealthMeter.tscn" type="PackedScene" id=1]
[ext_resource path="res://Scenes/Menus/PauseMenu.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scenes/UI/MissilesUI.tscn" type="PackedScene" id=3]
[node name="UI" type="CanvasLayer"]
@ -13,3 +14,10 @@ margin_bottom = 16.0
[node name="PauseMenu" parent="." instance=ExtResource( 2 )]
visible = false
[node name="MissilesUI" parent="." instance=ExtResource( 3 )]
visible = false
margin_left = 4.0
margin_top = 19.0
margin_right = 37.0
margin_bottom = 31.0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=13 format=2]
[ext_resource path="res://Scenes/World/TileMap.tscn" type="PackedScene" id=1]
[ext_resource path="res://Scenes/Player/Player.tscn" type="PackedScene" id=2]
@ -10,6 +10,8 @@
[ext_resource path="res://Scenes/Enemies/FlyingEnemy.tscn" type="PackedScene" id=8]
[ext_resource path="res://Scenes/Enemies/PlantEnemy.tscn" type="PackedScene" id=9]
[ext_resource path="res://Scenes/Enemies/CrawlingEnemy.tscn" type="PackedScene" id=10]
[ext_resource path="res://Scenes/Objects/Brick.tscn" type="PackedScene" id=11]
[ext_resource path="res://Scenes/Player/MissilesPowerup.tscn" type="PackedScene" id=12]
[node name="World" type="Node"]
script = ExtResource( 3 )
@ -43,7 +45,30 @@ position = Vector2( 224, 88 )
[node name="PlantEnemy" parent="." instance=ExtResource( 9 )]
position = Vector2( 136, 128 )
[node name="PlantEnemy2" parent="." instance=ExtResource( 9 )]
position = Vector2( 402.842, 16 )
rotation = 3.14159
[node name="CrawlingEnemy" parent="." instance=ExtResource( 10 )]
position = Vector2( 72, 160 )
[node name="Brick" parent="." instance=ExtResource( 11 )]
position = Vector2( 111, 96 )
[node name="Brick2" parent="." instance=ExtResource( 11 )]
position = Vector2( 111, 112 )
[node name="Brick3" parent="." instance=ExtResource( 11 )]
position = Vector2( 111, 80 )
[node name="Brick4" parent="." instance=ExtResource( 11 )]
position = Vector2( 111, 64 )
[node name="Brick5" parent="." instance=ExtResource( 11 )]
position = Vector2( 111, 48 )
[node name="MissilesPowerup" parent="." instance=ExtResource( 12 )]
position = Vector2( 64, 42 )
[editable path="Player"]
[editable path="Player/Hurtbox"]

View File

@ -18,10 +18,16 @@ _global_script_classes=[ {
"class": "PlayerStats",
"language": "GDScript",
"path": "res://Scenes/Player/PlayerStats.gd"
}, {
"base": "Area2D",
"class": "Powerup",
"language": "GDScript",
"path": "res://Scenes/Player/PowerUp.gd"
} ]
_global_script_class_icons={
"MainInstances": "",
"PlayerStats": ""
"PlayerStats": "",
"Powerup": ""
}
[application]
@ -110,6 +116,11 @@ pause={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
]
}
fire_missile={
"deadzone": 0.5,
"events": [ 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":2,"pressed":false,"doubleclick":false,"script":null)
]
}
[layer_names]
@ -117,8 +128,11 @@ pause={
2d_physics/layer_2="World"
2d_physics/layer_3="PlayerHurtbox"
2d_physics/layer_4="EnemyHurtbox"
2d_physics/layer_5="Brick"
2d_physics/layer_6="PowerUp"
[rendering]
quality/2d/use_pixel_snap=true
2d/snapping/use_gpu_pixel_snap=true
environment/default_environment="res://default_env.tres"
quality/2d/use_pixel_snap=true