add rival to stage

This commit is contained in:
D L 2023-01-28 23:24:33 -08:00
parent e81d347313
commit 8f3edcebb1
29 changed files with 438 additions and 2 deletions

View File

@ -0,0 +1,17 @@
[gd_resource type="AnimatedTexture" load_steps=5 format=2]
[ext_resource path="res://Graphics/Background/sprite_0.png" type="Texture" id=1]
[ext_resource path="res://Graphics/Background/sprite_2.png" type="Texture" id=2]
[ext_resource path="res://Graphics/Background/sprite_3.png" type="Texture" id=3]
[ext_resource path="res://Graphics/Background/sprite_1.png" type="Texture" id=4]
[resource]
frames = 4
fps = 2.0
frame_0/texture = ExtResource( 1 )
frame_1/texture = ExtResource( 4 )
frame_1/delay_sec = 0.0
frame_2/texture = ExtResource( 2 )
frame_2/delay_sec = 0.0
frame_3/texture = ExtResource( 3 )
frame_3/delay_sec = 0.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sprite_0.png-ff81b9ea03806575d623741ef5a30483.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Background/sprite_0.png"
dest_files=[ "res://.import/sprite_0.png-ff81b9ea03806575d623741ef5a30483.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sprite_1.png-24c02427d2ae9f728376fc013b1bd6fe.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Background/sprite_1.png"
dest_files=[ "res://.import/sprite_1.png-24c02427d2ae9f728376fc013b1bd6fe.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sprite_2.png-9a198e44f555bdd03266a60c336dfa09.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Background/sprite_2.png"
dest_files=[ "res://.import/sprite_2.png-9a198e44f555bdd03266a60c336dfa09.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/sprite_3.png-9e974f65603418654212e016e6c9ac60.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Background/sprite_3.png"
dest_files=[ "res://.import/sprite_3.png-9e974f65603418654212e016e6c9ac60.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

BIN
Graphics/Mystia.mdp Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Move+1.png-9a236d6d39b3f34ffdc89a3ec90a5b49.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Units/Mystia/Move+1.png"
dest_files=[ "res://.import/Move+1.png-9a236d6d39b3f34ffdc89a3ec90a5b49.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Move+2.png-f5f412e20b450110f9f086294b1041db.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Units/Mystia/Move+2.png"
dest_files=[ "res://.import/Move+2.png-f5f412e20b450110f9f086294b1041db.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Move-1.png-0400dd59e0a66e2a538ac84d56fe9ae6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Units/Mystia/Move-1.png"
dest_files=[ "res://.import/Move-1.png-0400dd59e0a66e2a538ac84d56fe9ae6.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Move-2.png-0f04babfecb88a70ec5b8929a68cb669.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Units/Mystia/Move-2.png"
dest_files=[ "res://.import/Move-2.png-0f04babfecb88a70ec5b8929a68cb669.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Move0.png-8aac8254368d3791b83519b221c222e6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Graphics/Units/Mystia/Move0.png"
dest_files=[ "res://.import/Move0.png-8aac8254368d3791b83519b221c222e6.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

View File

@ -1,9 +1,11 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://Tile Sets/SnowySlopes.tres" type="TileSet" id=1] [ext_resource path="res://Tile Sets/SnowySlopes.tres" type="TileSet" id=1]
[ext_resource path="res://Units/DownhillAutoscrollerPlayer.tscn" type="PackedScene" id=2] [ext_resource path="res://Units/DownhillAutoscrollerPlayer.tscn" type="PackedScene" id=2]
[ext_resource path="res://Tile Sets/SnowySlopesExtra.tres" type="TileSet" id=3] [ext_resource path="res://Tile Sets/SnowySlopesExtra.tres" type="TileSet" id=3]
[ext_resource path="res://Graphics/Animations/Background.tres" type="Texture" id=4]
[ext_resource path="res://Scripts/GameScene.gd" type="Script" id=5] [ext_resource path="res://Scripts/GameScene.gd" type="Script" id=5]
[ext_resource path="res://Units/DownhillAutoscrollerRival.tscn" type="PackedScene" id=6]
[sub_resource type="Animation" id=1] [sub_resource type="Animation" id=1]
resource_name = "PitTransition" resource_name = "PitTransition"
@ -64,6 +66,14 @@ Vector2( 80, -7 ): "NPC",
Vector2( 218, -29 ): "NPC" Vector2( 218, -29 ): "NPC"
} }
[node name="CanvasLayerBG" type="CanvasLayer" parent="."]
layer = -1
[node name="TextureRect" type="TextureRect" parent="CanvasLayerBG"]
anchor_right = 1.0
anchor_bottom = 1.0
texture = ExtResource( 4 )
[node name="Stage" type="TileMap" parent="."] [node name="Stage" type="TileMap" parent="."]
tile_set = ExtResource( 1 ) tile_set = ExtResource( 1 )
cell_size = Vector2( 48, 48 ) cell_size = Vector2( 48, 48 )
@ -89,6 +99,9 @@ offset = Vector2( 0, -15 )
[node name="SpectatorCam" type="Camera2D" parent="."] [node name="SpectatorCam" type="Camera2D" parent="."]
offset = Vector2( 0, -15 ) offset = Vector2( 0, -15 )
[node name="Rival" parent="." instance=ExtResource( 6 )]
position = Vector2( 91, -197 )
[node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="ColorRect" type="ColorRect" parent="CanvasLayer"] [node name="ColorRect" type="ColorRect" parent="CanvasLayer"]

View File

@ -1,6 +1,7 @@
enum UnitType { enum UnitType {
PLAYER, PLAYER,
NPC, NPC,
RIVAL,
} }
enum ActionType { enum ActionType {
@ -76,6 +77,10 @@ const UNIT_TYPE_ACTIONS = {
UnitType.NPC: [ UnitType.NPC: [
ActionType.MOVE, ActionType.MOVE,
], ],
UnitType.RIVAL: [
ActionType.JUMP,
ActionType.MOVE,
],
} }
const UNIT_TYPE_CURRENT_ACTIONS = { const UNIT_TYPE_CURRENT_ACTIONS = {
@ -88,6 +93,10 @@ const UNIT_TYPE_CURRENT_ACTIONS = {
UnitType.NPC: [ UnitType.NPC: [
UnitCurrentAction.IDLE, UnitCurrentAction.IDLE,
], ],
UnitType.RIVAL: [
UnitCurrentAction.IDLE,
UnitCurrentAction.JUMPING,
],
} }
# default conditions # default conditions
@ -103,6 +112,11 @@ const UNIT_TYPE_CONDITIONS = {
UnitCondition.IS_ON_GROUND: false, UnitCondition.IS_ON_GROUND: false,
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE, UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
}, },
UnitType.RIVAL: {
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
UnitCondition.IS_ON_GROUND: false,
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
},
} }
# in seconds # in seconds
@ -111,6 +125,9 @@ const CURRENT_ACTION_TIMERS = {
UnitCurrentAction.JUMPING: 0.4, UnitCurrentAction.JUMPING: 0.4,
UnitCurrentAction.RECOILING: 0.67, UnitCurrentAction.RECOILING: 0.67,
}, },
UnitType.NPC: {
UnitCurrentAction.JUMPING: 0.4,
},
} }
const UNIT_CONDITION_TIMERS = { const UNIT_CONDITION_TIMERS = {
@ -119,6 +136,7 @@ const UNIT_CONDITION_TIMERS = {
UnitCondition.IS_INVINCIBLE: [2.5, true, false], UnitCondition.IS_INVINCIBLE: [2.5, true, false],
}, },
UnitType.NPC: {}, UnitType.NPC: {},
UnitType.RIVAL: {},
} }
# Position relative to player's origin, list of directions to check for collision # Position relative to player's origin, list of directions to check for collision
@ -140,6 +158,15 @@ const ENV_COLLIDERS = {
[Vector2(.25, 1.25), [Direction.RIGHT]], [Vector2(.25, 1.25), [Direction.RIGHT]],
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]], [Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
], ],
UnitType.RIVAL: [
[Vector2(0, 1.5), [Direction.LEFT, Direction.UP, Direction.RIGHT]],
[Vector2(-.25, .25), [Direction.LEFT]],
[Vector2(.25, .25), [Direction.RIGHT]],
[Vector2(-.25, 1.25), [Direction.LEFT]],
[Vector2(.25, 1.25), [Direction.RIGHT]],
# contact with ground is at (0, 0)
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
],
} }
const INPUT_MAP = { const INPUT_MAP = {
@ -191,15 +218,22 @@ const UNIT_SPRITES = {
SpriteClass.WALK: [true, ["Walk"]], SpriteClass.WALK: [true, ["Walk"]],
SpriteClass.JUMP: [false, ["Jump2"]], SpriteClass.JUMP: [false, ["Jump2"]],
}, },
UnitType.RIVAL: {
SpriteClass.IDLE: [false, ["Idle"]],
SpriteClass.WALK: [false, ["Move0", "Move-1", "Move-2", "Move+1", "Move+2"]],
SpriteClass.JUMP: [false, ["Move0"]],
},
} }
const UNIT_TYPE_MOVE_SPEEDS = { const UNIT_TYPE_MOVE_SPEEDS = {
UnitType.PLAYER: 5, UnitType.PLAYER: 5,
UnitType.NPC: 3, UnitType.NPC: 3,
UnitType.RIVAL: 5,
} }
const UNIT_TYPE_JUMP_SPEEDS = { const UNIT_TYPE_JUMP_SPEEDS = {
UnitType.PLAYER: 4.5, UnitType.PLAYER: 4.5,
UnitType.RIVAL: 4.5,
} }
const SCALE_FACTOR = 1 const SCALE_FACTOR = 1

View File

@ -60,6 +60,9 @@ func _ready():
player_cam = player.get_node("Camera2D") player_cam = player.get_node("Camera2D")
player_cam.make_current() player_cam.make_current()
units.append(get_node("Rival"))
get_node("Rival").init_unit_w_scene(self)
stage_env = load("res://Scripts/StageEnvironment.gd").new(self) stage_env = load("res://Scripts/StageEnvironment.gd").new(self)
player.get_node("Camera2D").make_current() player.get_node("Camera2D").make_current()
for spawning_key in spawning: for spawning_key in spawning:

View File

@ -80,6 +80,8 @@ func get_condition(condition_num : int, default):
return default return default
func is_current_action_timer_done(current_action : int): func is_current_action_timer_done(current_action : int):
if Constants.CURRENT_ACTION_TIMERS[unit_type].keys().find(current_action) == -1:
print(Constants.UnitType.keys()[unit_type] + " " + Constants.UnitCurrentAction.keys()[current_action])
assert(current_action in Constants.CURRENT_ACTION_TIMERS[unit_type].keys()) assert(current_action in Constants.CURRENT_ACTION_TIMERS[unit_type].keys())
return current_action_time_elapsed >= Constants.CURRENT_ACTION_TIMERS[unit_type][current_action] return current_action_time_elapsed >= Constants.CURRENT_ACTION_TIMERS[unit_type][current_action]

View File

@ -0,0 +1,53 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://Scripts/Units/NPCUnit.gd" type="Script" id=1]
[ext_resource path="res://Graphics/Units/Mystia/Move-1.png" type="Texture" id=3]
[ext_resource path="res://Graphics/Units/Mystia/Move+2.png" type="Texture" id=4]
[ext_resource path="res://Graphics/Units/Mystia/Move+1.png" type="Texture" id=5]
[ext_resource path="res://Graphics/Units/Mystia/Move0.png" type="Texture" id=6]
[ext_resource path="res://Graphics/Units/Mystia/Move-2.png" type="Texture" id=7]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 9, 34 )
[node name="Rival" type="Area2D"]
z_index = 1
collision_layer = 0
script = ExtResource( 1 )
unit_type = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, -36 )
shape = SubResource( 1 )
[node name="Idle" type="Sprite" parent="."]
visible = false
texture = ExtResource( 6 )
offset = Vector2( 0, -48 )
[node name="Move0" type="Sprite" parent="."]
visible = false
texture = ExtResource( 6 )
offset = Vector2( 0, -48 )
[node name="Move+1" type="Sprite" parent="."]
visible = false
texture = ExtResource( 5 )
offset = Vector2( 0, -48 )
[node name="Move+2" type="Sprite" parent="."]
visible = false
texture = ExtResource( 4 )
offset = Vector2( 0, -48 )
[node name="Move-1" type="Sprite" parent="."]
visible = false
texture = ExtResource( 3 )
offset = Vector2( 0, -48 )
[node name="Move-2" type="Sprite" parent="."]
visible = false
texture = ExtResource( 7 )
offset = Vector2( 0, -48 )
[connection signal="area_entered" from="." to="." method="_on_Player_area_entered"]

Binary file not shown.

View File

@ -99,4 +99,3 @@ common/enable_pause_aware_picking=true
[rendering] [rendering]
2d/snapping/use_gpu_pixel_snap=true 2d/snapping/use_gpu_pixel_snap=true
environment/default_environment="res://default_env.tres"