parent
60d660adbd
commit
e44e063bb5
Binary file not shown.
@ -0,0 +1,15 @@ |
||||
[remap] |
||||
|
||||
importer="ogg_vorbis" |
||||
type="AudioStreamOGGVorbis" |
||||
path="res://.import/cast.ogg-7c445777357274a1b62f366377232704.oggstr" |
||||
|
||||
[deps] |
||||
|
||||
source_file="res://objects/characters/monsters/03/assets/cast.ogg" |
||||
dest_files=[ "res://.import/cast.ogg-7c445777357274a1b62f366377232704.oggstr" ] |
||||
|
||||
[params] |
||||
|
||||
loop=false |
||||
loop_offset=0 |
Binary file not shown.
@ -0,0 +1,15 @@ |
||||
[remap] |
||||
|
||||
importer="ogg_vorbis" |
||||
type="AudioStreamOGGVorbis" |
||||
path="res://.import/shoot.ogg-49351e8bfb5f39cc00d1fa5c2e262bb7.oggstr" |
||||
|
||||
[deps] |
||||
|
||||
source_file="res://objects/characters/monsters/03/assets/shoot.ogg" |
||||
dest_files=[ "res://.import/shoot.ogg-49351e8bfb5f39cc00d1fa5c2e262bb7.oggstr" ] |
||||
|
||||
[params] |
||||
|
||||
loop=false |
||||
loop_offset=0 |
Binary file not shown.
@ -0,0 +1,15 @@ |
||||
[remap] |
||||
|
||||
importer="ogg_vorbis" |
||||
type="AudioStreamOGGVorbis" |
||||
path="res://.import/hurt.ogg-9b76aab68e3c879188a86aedb77f6e8f.oggstr" |
||||
|
||||
[deps] |
||||
|
||||
source_file="res://objects/characters/player/assets/hurt.ogg" |
||||
dest_files=[ "res://.import/hurt.ogg-9b76aab68e3c879188a86aedb77f6e8f.oggstr" ] |
||||
|
||||
[params] |
||||
|
||||
loop=false |
||||
loop_offset=0 |
@ -0,0 +1,190 @@ |
||||
extends "res://objects/characters/character.gd" |
||||
|
||||
const SPEED = 400 |
||||
const JUMP_HEIGHT = 1000 |
||||
const STRIKED_HEIGHT = 400 |
||||
export var background_scene : Resource |
||||
|
||||
onready var level = get_parent() |
||||
onready var main = level.get_parent() |
||||
|
||||
const ANIMATIONS = { |
||||
"idle": { |
||||
"animation": "idle", |
||||
"transistion": "idle", |
||||
"blocks": [] |
||||
}, |
||||
"run": { |
||||
"animation": "run", |
||||
"transistion": "run", |
||||
"blocks": [] |
||||
}, |
||||
"jump_start": { |
||||
"animation": "jump_start", |
||||
"transistion": "jump", |
||||
"blocks": ["idle", "run", "fall_start", "fall", "fall_end"] |
||||
}, |
||||
"jump": { |
||||
"animation": "jump", |
||||
"transistion": "jump", |
||||
"blocks": ["idle", "run", "fall_start", "fall", "fall_end", "jump_start"] |
||||
}, |
||||
"jump_end": { |
||||
"animation": "jump_end", |
||||
"transistion": "idle", |
||||
"blocks": ["idle", "run", "fall_start", "fall", "fall_end", "jump"] |
||||
}, |
||||
"fall_start": { |
||||
"animation": "fall_start", |
||||
"transistion": "fall", |
||||
"blocks": ["idle", "run", "fall", "fall_end", "jump_start", "jump", "jump_end"] |
||||
}, |
||||
"fall": { |
||||
"animation": "fall", |
||||
"transistion": "fall", |
||||
"blocks": ["idle", "run", "fall_start", "jump_start", "jump", "jump_end"] |
||||
}, |
||||
"fall_end": { |
||||
"animation": "fall_end", |
||||
"transistion": "idle", |
||||
"blocks": ["idle", "run", "fall_start", "fall", "jump_start", "jump", "jump_end"] |
||||
}, |
||||
"striked_start": { |
||||
"animation": "jump_start", |
||||
"transistion": "striked", |
||||
"blocks": ["idle", "run", "fall_start", "fall", "fall_end", "jump_start", "jump", "jump_end"] |
||||
}, |
||||
"striked": { |
||||
"animation": "jump", |
||||
"transistion": "striked_end", |
||||
"blocks": ["idle", "run", "fall_start", "fall", "fall_end", "jump_start", "jump", "jump_end"] |
||||
}, |
||||
"striked_end": { |
||||
"animation": "hurt", |
||||
"transistion": "idle", |
||||
"blocks": ["idle", "run", "fall_start", "fall", "fall_end", "jump_start", "jump", "jump_end"] |
||||
} |
||||
} |
||||
var player_state = "idle" |
||||
var invincible_hit = false |
||||
|
||||
var score = 0 |
||||
|
||||
func _ready(): |
||||
$Camera2D.add_child(background_scene.instance()) |
||||
$Sprite.connect("animation_finished", self, "_next_player_state") |
||||
$Sprite.animation = ANIMATIONS[player_state]['animation'] |
||||
$Camera2D.limit_left = level.camera_limit_left |
||||
$Camera2D.limit_right = level.camera_limit_right |
||||
$Camera2D.limit_top = level.camera_limit_top |
||||
$Camera2D.limit_bottom = level.camera_limit_bottom |
||||
yield(get_tree().create_timer(0.5), "timeout") |
||||
$Camera2D.smoothing_enabled = true |
||||
|
||||
func _physics_process(delta): |
||||
# out-of-screen checking |
||||
if position.y > level.camera_limit_bottom and health > 0: |
||||
_add_damage(100) |
||||
|
||||
# Fall animation if not on floor |
||||
if velocity.y > 1 and not is_on_floor(): |
||||
_set_player_state("fall_start") |
||||
|
||||
# Movement |
||||
if Input.is_action_pressed("move_left") and not Input.is_action_pressed("move_right") \ |
||||
and not player_state in ["striked_start", "striked", "striked_end"]: |
||||
move_left(SPEED) |
||||
elif Input.is_action_pressed("move_right") and not Input.is_action_pressed("move_left") \ |
||||
and not player_state in ["striked_start", "striked", "striked_end"]: |
||||
move_right(SPEED) |
||||
elif player_state in ["idle", "run", "jump", "jump_end", "fall_end", "striked_end"]: |
||||
move_stop() |
||||
|
||||
# On floor detection |
||||
if is_on_floor() and not player_state in ["striked", "striked_start"]: |
||||
snap = SNAP |
||||
_end_animation() |
||||
|
||||
# Jump |
||||
if Input.is_action_just_pressed("jump"): |
||||
if $RayBottomLeft.is_colliding() or $RayBottomRight.is_colliding() or $RayBottomCenter.is_colliding(): |
||||
jump() |
||||
|
||||
func _next_player_state(): |
||||
player_state = ANIMATIONS[player_state]["transistion"] |
||||
$Sprite.animation = ANIMATIONS[player_state]['animation'] |
||||
|
||||
func _set_player_state(new_state): |
||||
if not new_state in ANIMATIONS[player_state]["blocks"]: |
||||
player_state = new_state |
||||
$Sprite.animation = ANIMATIONS[player_state]['animation'] |
||||
return true |
||||
return false |
||||
|
||||
func move_right(delta): |
||||
_set_player_state("run") |
||||
get_node("Sprite").set_flip_h(false) |
||||
if position.x < level.camera_limit_right: |
||||
velocity.x = delta |
||||
else: |
||||
velocity.x = 0 |
||||
|
||||
func move_left(delta): |
||||
_set_player_state("run") |
||||
get_node("Sprite").set_flip_h(true) |
||||
if position.x > level.camera_limit_left: |
||||
velocity.x = -delta |
||||
else: |
||||
velocity.x = 0 |
||||
|
||||
func move_stop(): |
||||
_set_player_state("idle") |
||||
velocity.x = 0 |
||||
|
||||
func jump(): |
||||
if _set_player_state("jump_start"): |
||||
snap = Vector2.ZERO |
||||
position.y += get_floor_velocity().y * get_physics_process_delta_time() \ |
||||
- GRAVITY * get_physics_process_delta_time() - 3 |
||||
velocity.y -= JUMP_HEIGHT |
||||
|
||||
func _on_GroundCheck_body_entered(body): |
||||
_end_animation() |
||||
|
||||
func _end_animation(): |
||||
if velocity.y > 0 and player_state in ["jump_start", "jump"]: |
||||
_set_player_state("jump_end") |
||||
if velocity.y > 0 and player_state in ["fall_start", "fall"]: |
||||
_set_player_state("fall_end") |
||||
if velocity.y > 0 and player_state in ["striked_start", "striked"]: |
||||
_set_player_state("striked_end") |
||||
|
||||
func monster_hit(direction : int, damage: int): |
||||
if not invincible_hit: |
||||
invincible_hit = true |
||||
$HurtSound.play() |
||||
_set_player_state("striked_start") |
||||
_add_damage(damage) |
||||
snap = Vector2.ZERO |
||||
velocity.y = -300 |
||||
velocity.x = direction * 5 |
||||
yield(get_tree().create_timer(1.0), "timeout") |
||||
invincible_hit = false |
||||
|
||||
func _on_Enemy_Entered(body): |
||||
body.stomped_on_head() |
||||
_set_player_state("jump") |
||||
|
||||
func coin_collected(value): |
||||
main.add_score(value) |
||||
|
||||
func _add_damage(value): |
||||
health -= value |
||||
GlobalState.health = health |
||||
if health <= 0: |
||||
main.player_died() |
||||
|
||||
func _on_screen_exited(): |
||||
print("exited") |
||||
print($VisibilityNotifier2D.is_on_screen()) |
||||
_add_damage(100) |
@ -0,0 +1,81 @@ |
||||
[gd_scene load_steps=7 format=2] |
||||
|
||||
[ext_resource path="res://objects/characters/flopsy/flopsy.tres" type="SpriteFrames" id=1] |
||||
[ext_resource path="res://objects/characters/player/assets/hurt.ogg" type="AudioStream" id=2] |
||||
[ext_resource path="res://objects/characters/player/player.gd" type="Script" id=11] |
||||
|
||||
[sub_resource type="CapsuleShape2D" id=4] |
||||
radius = 164.75 |
||||
height = 138.75 |
||||
|
||||
[sub_resource type="RectangleShape2D" id=3] |
||||
extents = Vector2( 190.5, 100.625 ) |
||||
|
||||
[sub_resource type="CircleShape2D" id=5] |
||||
radius = 79.0 |
||||
|
||||
[node name="Player" type="KinematicBody2D"] |
||||
z_index = 10 |
||||
collision_mask = 4 |
||||
script = ExtResource( 11 ) |
||||
|
||||
[node name="Sprite" type="AnimatedSprite" parent="."] |
||||
frames = ExtResource( 1 ) |
||||
animation = "idle" |
||||
frame = 2 |
||||
playing = true |
||||
__meta__ = { |
||||
"_edit_lock_": true |
||||
} |
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] |
||||
position = Vector2( -14.75, -7.875 ) |
||||
shape = SubResource( 4 ) |
||||
|
||||
[node name="GroundCheck" type="Area2D" parent="."] |
||||
collision_mask = 4 |
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GroundCheck"] |
||||
position = Vector2( -22.5, 323.375 ) |
||||
shape = SubResource( 3 ) |
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."] |
||||
current = true |
||||
limit_left = 0 |
||||
limit_bottom = 1080 |
||||
limit_smoothed = true |
||||
|
||||
[node name="RayBottomLeft" type="RayCast2D" parent="."] |
||||
position = Vector2( -184, 0 ) |
||||
enabled = true |
||||
cast_to = Vector2( 0, 400 ) |
||||
collision_mask = 6 |
||||
collide_with_areas = true |
||||
|
||||
[node name="RayBottomRight" type="RayCast2D" parent="."] |
||||
position = Vector2( 154, 0 ) |
||||
enabled = true |
||||
cast_to = Vector2( 0, 400 ) |
||||
collision_mask = 6 |
||||
collide_with_areas = true |
||||
|
||||
[node name="RayBottomCenter" type="RayCast2D" parent="."] |
||||
position = Vector2( -14, 0 ) |
||||
enabled = true |
||||
cast_to = Vector2( 0, 400 ) |
||||
collision_mask = 6 |
||||
collide_with_areas = true |
||||
|
||||
[node name="EnemyBottomCheck" type="Area2D" parent="."] |
||||
collision_mask = 2 |
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyBottomCheck"] |
||||
position = Vector2( -13, 225 ) |
||||
shape = SubResource( 5 ) |
||||
|
||||
[node name="HurtSound" type="AudioStreamPlayer2D" parent="."] |
||||
stream = ExtResource( 2 ) |
||||
volume_db = -5.0 |
||||
|
||||
[connection signal="body_entered" from="GroundCheck" to="." method="_on_GroundCheck_body_entered"] |
||||
[connection signal="body_entered" from="EnemyBottomCheck" to="." method="_on_Enemy_Entered"] |
After Width: | Height: | Size: 444 KiB |
@ -0,0 +1,35 @@ |
||||
[remap] |
||||
|
||||
importer="texture" |
||||
type="StreamTexture" |
||||
path="res://.import/castle.svg-00d8399a3079f218c23cbd3d369eff6d.stex" |
||||
metadata={ |
||||
"vram_texture": false |
||||
} |
||||
|
||||
[deps] |
||||
|
||||
source_file="res://scenes/levels/02/assets/castle.svg" |
||||
dest_files=[ "res://.import/castle.svg-00d8399a3079f218c23cbd3d369eff6d.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=true |
||||
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=true |
||||
svg/scale=3.0 |
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,35 @@ |
||||
[remap] |
||||
|
||||
importer="texture" |
||||
type="StreamTexture" |
||||
path="res://.import/castle_door_closed.svg-fb9796fc691d76fc7dc625ac4b74f124.stex" |
||||
metadata={ |
||||
"vram_texture": false |
||||
} |
||||
|
||||
[deps] |
||||
|
||||
source_file="res://scenes/levels/02/assets/castle_door_closed.svg" |
||||
dest_files=[ "res://.import/castle_door_closed.svg-fb9796fc691d76fc7dc625ac4b74f124.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=true |
||||
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=true |
||||
svg/scale=3.0 |