Finished FPS agnosticism, removed particle engine

This commit is contained in:
Maruno17
2023-06-03 21:55:02 +01:00
parent 68de25562a
commit 1901675e33
39 changed files with 652 additions and 1504 deletions

View File

@@ -15,30 +15,31 @@
#
#===============================================================================
class HallOfFame_Scene
# When true, all pokémon will be in one line
# When false, all pokémon will be in two lines
# When true, all pokémon will be in one line.
# When false, all pokémon will be in two lines.
SINGLE_ROW_OF_POKEMON = false
# Make the pokémon movement ON in hall entry
# Make the pokémon movement ON in hall entry.
ANIMATION = true
# Speed in pokémon movement in hall entry. Don't use less than 2!
ANIMATIONSPEED = 32
# Time in seconds for a Pokémon to slide to its position from off-screen.
APPEAR_SPEED = 0.4
# Entry wait time (in seconds) between showing each Pokémon (and trainer).
# Waits for twice this tme when showing "Welcome to the Hall of Fame!".
ENTRY_WAIT_TIME = 3.0
# Wait time (in seconds) when showing "Welcome to the Hall of Fame!".
WELCOME_WAIT_TIME = 4.0
# Maximum number limit of simultaneous hall entries saved.
# 0 = Doesn't save any hall. -1 = no limit
# Prefer to use larger numbers (like 500 and 1000) than don't put a limit
# If a player exceed this limit, the first one will be removed
# Prefer to use larger numbers (like 500 and 1000) than don't put a limit.
# If a player exceed this limit, the first one will be removed.
HALL_ENTRIES_LIMIT = 50
# The entry music name. Put "" to doesn't play anything
# The entry music name. Put "" to doesn't play anything.
HALL_OF_FAME_BGM = "Hall of Fame"
# Allow eggs to be show and saved in hall
# Allow eggs to be show and saved in hall.
ALLOW_EGGS = true
# Remove the hallbars when the trainer sprite appears
# Remove the hallbars when the trainer sprite appears.
REMOVE_BARS_WHEN_SHOWING_TRAINER = true
# The final fade speed on entry
# The final fade speed on entry.
FINAL_FADE_DURATION = 1.0
# Sprite's opacity value when it isn't selected
# Sprite's opacity value when it isn't selected.
OPACITY = 64
TEXT_BASE_COLOR = Color.new(248, 248, 248)
TEXT_SHADOW_COLOR = Color.new(0, 0, 0)
@@ -68,8 +69,7 @@ class HallOfFame_Scene
@useMusic = (HALL_OF_FAME_BGM && HALL_OF_FAME_BGM != "")
pbBGMPlay(HALL_OF_FAME_BGM) if @useMusic
saveHallEntry
@xmovement = []
@ymovement = []
@movements = []
createBattlers
pbFadeInAndShow(@sprites) { pbUpdate }
end
@@ -92,14 +92,15 @@ class HallOfFame_Scene
end
def slowFadeOut(duration)
col = Color.new(0, 0, 0, 0)
timer_start = System.uptime
loop do
alpha = lerp(255, 0, duration, timer_start, System.uptime)
pbSetSpritesToColor(@sprites, Color.new(0, 0, 0, alpha))
col.alpha = lerp(0, 255, duration, timer_start, System.uptime)
@viewport.color = col
Graphics.update
Input.update
pbUpdate
break if alpha == 0
break if col.alpha == 255
end
end
@@ -132,120 +133,94 @@ class HallOfFame_Scene
# Return the x/y point position in screen for battler index number
# Don't use odd numbers!
def xpointformula(battlernumber)
ret = 0
if SINGLE_ROW_OF_POKEMON
ret = ((60 * (battlernumber / 2)) + 48) * (xpositionformula(battlernumber) - 1)
ret += (Graphics.width / 2) - 56
else
ret = 32 + (160 * xpositionformula(battlernumber))
ret = ((60 * (battlernumber / 2)) + 48) * (xpositionformula(battlernumber) - 1) # -48, 48, -108, 108, -168, 168
return ret + (Graphics.width / 2) # 208, 304, 148, 364, 88, 424
end
return ret
return 96 + (160 * xpositionformula(battlernumber)) # 256, 96, 456, 256, 456, 96
end
def ypointformula(battlernumber)
ret = 0
if SINGLE_ROW_OF_POKEMON
ret = 96 - (8 * (battlernumber / 2))
else
ret = 32 + (128 * ypositionformula(battlernumber) / 2)
end
return ret
return 180 - (32 * (battlernumber / 2)) if SINGLE_ROW_OF_POKEMON # 180, 180, 148, 148, 116, 116
return 96 + (64 * ypositionformula(battlernumber)) # 90, 90, 90, 160, 160, 160
end
# Returns 0, 1 or 2 as the x/y column value
# Returns 0, 1 or 2 as the x position value (left, middle, right column)
def xpositionformula(battlernumber)
ret = 0
if SINGLE_ROW_OF_POKEMON
ret = (battlernumber % 2) * 2
else
ret = (battlernumber / 3).even? ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3
end
return ret
return (battlernumber % 2) * 2 if SINGLE_ROW_OF_POKEMON # 0, 2, 0, 2, 0, 2
return (1 - battlernumber) % 3 if (battlernumber / 3).even? # First 3 mons: 1, 0, 2
return (1 + battlernumber) % 3 # Second 3 mons: 1, 2, 0
end
# Returns 0, 1 or 2 as the y position value (top, middle, bottom row)
def ypositionformula(battlernumber)
ret = 0
if SINGLE_ROW_OF_POKEMON
ret = 1
else
ret = ((battlernumber / 3) % 2) * 2
end
return ret
return 1 if SINGLE_ROW_OF_POKEMON # 1, 1, 1, 1, 1, 1
return ((battlernumber / 3) % 2) * 2 # 0, 0, 0, 2, 2, 2
end
def moveSprite(i)
spritename = (i > -1) ? "pokemon#{i}" : "trainer"
speed = (i > -1) ? ANIMATIONSPEED : 2
if !ANIMATION # Skips animation
@sprites[spritename].x -= speed * @xmovement[i]
@xmovement[i] = 0
@sprites[spritename].y -= speed * @ymovement[i]
@ymovement[i] = 0
end
if @xmovement[i] != 0
direction = (@xmovement[i] > 0) ? -1 : 1
@sprites[spritename].x += speed * direction
@xmovement[i] += direction
end
if @ymovement[i] != 0
direction = (@ymovement[i] > 0) ? -1 : 1
@sprites[spritename].y += speed * direction
@ymovement[i] += direction
if !ANIMATION # Skips animation, place directly in end position
@sprites[spritename].x = @movements[i][1]
@sprites[spritename].y = @movements[i][3]
@movements[i][0] = @movements[i][1]
@movements[i][2] = @movements[i][3]
return
end
@movements[i][4] = System.uptime if !@movements[i][4]
speed = (i > -1) ? APPEAR_SPEED : APPEAR_SPEED * 3
@sprites[spritename].x = lerp(@movements[i][0], @movements[i][1], speed, @movements[i][4], System.uptime)
@sprites[spritename].y = lerp(@movements[i][2], @movements[i][3], speed, @movements[i][4], System.uptime)
@movements[i][0] = @movements[i][1] if @sprites[spritename].x == @movements[i][1]
@movements[i][2] = @movements[i][3] if @sprites[spritename].y == @movements[i][3]
end
def createBattlers(hide = true)
# Movement in animation
6.times do |i|
# Clear all 6 pokémon sprites and dispose the ones that exists every time
Settings::MAX_PARTY_SIZE.times do |i|
# Clear all pokémon sprites and dispose the ones that exists every time
# that this method is call
restartSpritePosition(@sprites, "pokemon#{i}")
next if i >= @hallEntry.size
xpoint = xpointformula(i)
ypoint = ypointformula(i)
pok = @hallEntry[i]
end_x = xpointformula(i)
end_y = ypointformula(i)
@sprites["pokemon#{i}"] = PokemonSprite.new(@viewport)
@sprites["pokemon#{i}"].setOffset(PictureOrigin::TOP_LEFT)
@sprites["pokemon#{i}"].setPokemonBitmap(pok)
@sprites["pokemon#{i}"].setPokemonBitmap(@hallEntry[i])
# This method doesn't put the exact coordinates
@sprites["pokemon#{i}"].x = xpoint
@sprites["pokemon#{i}"].y = ypoint
if @sprites["pokemon#{i}"].bitmap && !@sprites["pokemon#{i}"].disposed?
@sprites["pokemon#{i}"].x += (128 - @sprites["pokemon#{i}"].bitmap.width) / 2
@sprites["pokemon#{i}"].y += (128 - @sprites["pokemon#{i}"].bitmap.height) / 2
end
@sprites["pokemon#{i}"].z = 7 - i if SINGLE_ROW_OF_POKEMON
@sprites["pokemon#{i}"].x = end_x
@sprites["pokemon#{i}"].y = end_y
@sprites["pokemon#{i}"].z = Settings::MAX_PARTY_SIZE - i if SINGLE_ROW_OF_POKEMON
next if !hide
# Animation distance calculation
horizontal = 1 - xpositionformula(i)
vertical = 1 - ypositionformula(i)
xdistance = (horizontal == -1) ? -@sprites["pokemon#{i}"].bitmap.width : Graphics.width
ydistance = (vertical == -1) ? -@sprites["pokemon#{i}"].bitmap.height : Graphics.height
xdistance = ((xdistance - @sprites["pokemon#{i}"].x) / ANIMATIONSPEED).abs + 1
ydistance = ((ydistance - @sprites["pokemon#{i}"].y) / ANIMATIONSPEED).abs + 1
biggerdistance = (xdistance > ydistance) ? xdistance : ydistance
@xmovement[i] = biggerdistance
@xmovement[i] *= -1 if horizontal == -1
@xmovement[i] = 0 if horizontal == 0
@ymovement[i] = biggerdistance
@ymovement[i] *= -1 if vertical == -1
@ymovement[i] = 0 if vertical == 0
# Hide the battlers
@sprites["pokemon#{i}"].x += @xmovement[i] * ANIMATIONSPEED
@sprites["pokemon#{i}"].y += @ymovement[i] * ANIMATIONSPEED
x_direction = xpositionformula(i) - 1
y_direction = ypositionformula(i) - 1
distance = 0
if y_direction == 0
distance = (x_direction > 0) ? end_x : Graphics.width - end_x
distance += @sprites["pokemon#{i}"].bitmap.width / 2
else
distance = (y_direction > 0) ? end_y : Graphics.height - end_y
distance += @sprites["pokemon#{i}"].bitmap.height / 2
end
start_x = end_x - x_direction * distance
start_y = end_y - y_direction * distance
@sprites["pokemon#{i}"].x = start_x
@sprites["pokemon#{i}"].y = start_y
@movements[i] = [start_x, end_x, start_y, end_y]
end
end
def createTrainerBattler
@sprites["trainer"] = IconSprite.new(@viewport)
@sprites["trainer"].setBitmap(GameData::TrainerType.front_sprite_filename($player.trainer_type))
@sprites["trainer"].setBitmap(GameData::TrainerType.player_front_sprite_filename($player.trainer_type))
if SINGLE_ROW_OF_POKEMON
@sprites["trainer"].x = Graphics.width / 2
@sprites["trainer"].y = 178
@sprites["trainer"].y = 208
else
@sprites["trainer"].x = Graphics.width - 96
@sprites["trainer"].y = 160
end
@movements.push([Graphics.width / 2, @sprites["trainer"].x, @sprites["trainer"].y, @sprites["trainer"].y])
@sprites["trainer"].z = 9
@sprites["trainer"].ox = @sprites["trainer"].bitmap.width / 2
@sprites["trainer"].oy = @sprites["trainer"].bitmap.height / 2
@@ -253,13 +228,8 @@ class HallOfFame_Scene
@sprites["overlay"].bitmap.clear
@sprites["hallbars"].visible = false
end
@xmovement[@battlerIndex] = 0
@ymovement[@battlerIndex] = 0
if ANIMATION && !SINGLE_ROW_OF_POKEMON # Trainer Animation
startpoint = Graphics.width / 2
# 2 is the trainer speed
@xmovement[@battlerIndex] = (startpoint - @sprites["trainer"].x) / 2
@sprites["trainer"].x = startpoint
@sprites["trainer"].x = @movements.last[0]
else
timer_start = System.uptime
loop do
@@ -376,7 +346,9 @@ class HallOfFame_Scene
def pbUpdateAnimation
if @battlerIndex <= @hallEntry.size
if @xmovement[@battlerIndex] != 0 || @ymovement[@battlerIndex] != 0
if @movements[@battlerIndex] &&
(@movements[@battlerIndex][0] != @movements[@battlerIndex][1] ||
@movements[@battlerIndex][2] != @movements[@battlerIndex][3])
spriteIndex = (@battlerIndex < @hallEntry.size) ? @battlerIndex : -1
moveSprite(spriteIndex)
else
@@ -404,7 +376,7 @@ class HallOfFame_Scene
Graphics.update
Input.update
pbUpdate
break if System.uptime - timer_start >= ENTRY_WAIT_TIME * 2
break if System.uptime - timer_start >= WELCOME_WAIT_TIME
end
setPokemonSpritesOpacity(-1, OPACITY) if !SINGLE_ROW_OF_POKEMON
createTrainerBattler