VX/VXA Help with AMN Tomoaky Puzzle Battle VX Ace script

So I'm suing the AMN Tomoaky Puzzle Battle VX Ace script to add a fun little puyo puyo minigame to my game.
However it seems this script is made for the default window and my game window is 640 by 480.

Captura de ecrã 2025-08-15 184055.png


This means the minigame window stays at the top corner and it looks weird.
I wanna know how how to center the game because I'm having trouble doing so.
Heres the script
Spoiler: script
=begin
#==============================================================================#
# AMN Tomoaky Puzzle Battle VX Ace
# Version 1.03
# Author: Tomoaky / AMoonlessNight
# Date: 17 Oct 2020
# Latest: 19 Dec 2020
#==============================================================================#
# Original VX RGSS2 script by Tomoaky - https://twitter.com/tomoaky
#------------------------------------------------------------------------------#
# Original website via Wayback Machine:
# - https://web.archive.org/web/20140421033430/http://hikimoki.sakura.ne.jp/
# - see RGSS2_ぷよ○よ風(09/10/08) / RGSS2 Puyo Puyo
#==============================================================================#
# UPDATE LOG
#------------------------------------------------------------------------------#
# 17 Oct 2020 - created the script
# 23 Oct 2020 - portraits now show above falling blocks; fixed portrait x pos
# 19 Dec 2020 - added neutral game end message for solo mode
#==============================================================================#
# TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit Tomoaky, the creator of the VX script
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use
# - If you would like to edit/adjust this script, please make edits as a new
# script (do not edit this script directly) and provide proper credit
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#

This script is a port of a VX script by Tomoaky that recreates a falling block
puzzle (based on the game Puyo Puyo).

Blocks fall in groups of two and can be rotated clockwise or counter-clockwise.
Group blocks in clusters of four to destroy them. You lose when the fall count
reaches zero (solo mode) or the blocks touch the ceiling. You win by clearing
all of the blocks, or your opponent losing (CPU mode).

You can either play solo mode or against the CPU. When playing against the CPU,
if you destroy a cluster of blocks, you'll send a group of obstacle blocks onto
the opponent's screen.

Please see a copy of Tomoaky's original terms and conditions in the readme.txt

#==============================================================================
# ** SCRIPT CALLS
#------------------------------------------------------------------------------

■ GRAPHICS
-------------------------------------------------------------------------

● $game_tpuzzle.frame = "graphic_name"
Changes the frame to be an image called "graphic_name" in Graphics/System
-------------------------------------------------------------------------

● $game_tpuzzle.bg_pic = ["graphic_name", "graphic_name"]
The first image will be shown on the left-hand side of the screen in the
player 1 stage. The second image will be shown on the right-hand side of
the screen in the player 2 stage.
-------------------------------------------------------------------------

● $game_tpuzzle.puzzle_chara = "graphic_name"
Changes the puzzle blocks to be character set called "graphic_name" in
Graphics/Characters
-------------------------------------------------------------------------

■ SOUNDS
-------------------------------------------------------------------------

● $game_tpuzzle.puzzle_bgm = ["audio_file", X, Y]
Changes the BGM for the puzzle to be a BGM called "audio_file" in the
Audio/BGM folder, where X is the volume and Y is the pitch
-------------------------------------------------------------------------

● $game_tpuzzle.puzzle_me = ["audio_file", X, Y]
Changes the ME for the puzzle end to be a ME called "audio_file" in the
Audio/ME folder, where X is the volume and Y is the pitch
-------------------------------------------------------------------------

■ PUZZLE-RELATED
-------------------------------------------------------------------------

● $game_tpuzzle.solo_mode = true/false
Change the puzzle mode to solo mode if TRUE, or CPU mode if FALSE
(false by default)
-------------------------------------------------------------------------

● $game_tpuzzle.fall_limit = X
Change the maximum number of blocks that can fall before the game is over
(solo mode only)
-------------------------------------------------------------------------

● $game_tpuzzle.start_stage = [
[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 1, 0],
[0, 0, 0, 4, 3, 0], [0, 0, 0, 5, 5, 0],
[0, 0, 4, 4, 4, 0], [0, 0, 3, 3, 3, 0],
[0, 0, 2, 2, 2, 0], [0, 0, 1, 1, 1, 0]
]
Set up the stage with specific blocks already in place. Use the character
index for a specific block or 0 for an empty space.
(solo mode only)
-------------------------------------------------------------------------

● $game_tpuzzle.next_list = [
[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]
]
Set the specific block order. Use the character index for a specific block
-------------------------------------------------------------------------

=end

module TPUZZLE
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
# Change the values in the area below to suit your needs.
#==============================================================================

# ■ ID of the game variable to store the score
RESULT_VAR = 118

# ■ ID of the game switch to store win/loss
RESULT_SWT = 109

# ■ ID of the animation to play when blocks are erased
BREAK_ANIME = 81

# ■ Default character set to use for blocks (in the Graphics/Characters folder)
CHARA_FILENAME = "puzzleg"

# ■ Default graphic to use for puzzle frame (in the Graphics/System folder)
FRAME_FILENAME = "frame"

# ■ Text for Player 1
PLAYER_ONE = "Michael"

# ■ Text for Player 2
PLAYER_TWO = "Trevor"

# ■ Text shown when player is defeated
DEFEAT_TEXT = "Defeat..."

# ■ Text shown when player wins
VICTORY_TEXT = "Victory!"

# ■ Text shown when player runs out of turns (i.e. when fall limit reaches 0)
NEUTRAL_TEXT = "Turns expired..."

# ■ Text shown to exit game
EXIT_BUTTON_TEXT = "Press the shift button"

# ■ Button for exit
EXIT_BUTTON = :A

# ■ Button to rotate block left
ROTATE_L_BUTTON = :C

# ■ Button to rotate block right
ROTATE_R_BUTTON = :B

# ■ Sound effect to play when block is rotated
# ["", 0, 0] to play no sound effect
MOVE_SE = ["8bdidthing", 40, 150]

# ■ Sound effect to play on button input
# ["", 0, 0] to play no sound effect
INPUT_SE = ["8bdidthing", 40, 100]

# ■ Sound effect to play when blocks are chained
# ["", 0, 0] to play no sound effect
CHAIN_SE = ["8bdidthing", 40, 50]

# ■ Amount to add to CHAIN_SE pitch for each block chained
# Set to 0 to not use (pitch will remain the same for each chain)
CHAIN_PITCH_INC = 10

# ■ Sound effect to play at puzzle start
# [] to use battle start SE, ["", 0, 0] to play nothing
PUZZLE_START_SE = []

# ■ ME to play at puzzle end
# [] to use battle end ME, ["", 0, 0] to play nothing
PUZZLE_END_ME = []

# ■ BGM to play during puzzle
# [] to use battle BGM, ["", 0, 0] to play nothing
PUZZLE_BGM = []

#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
# Please do not edit below this point unless you know what you are doing.
#==============================================================================
end

#==============================================================================
# ■ TPuzzleManager
#------------------------------------------------------------------------------
# This module manages puzzle BGM and ME.
#==============================================================================

module TPuzzleManager
#--------------------------------------------------------------------------
# ● Save map BGM and BGS
#--------------------------------------------------------------------------
def self.save_bgm_and_bgs
@map_bgm = RPG::BGM.last
@map_bgs = RPG::BGS.last
end
#--------------------------------------------------------------------------
# ● Play puzzle BGM
#--------------------------------------------------------------------------
def self.play_puzzle_bgm
if $game_tpuzzle.puzzle_bgm && !$game_tpuzzle.puzzle_bgm.empty?
RPG::BGM.new(*$game_tpuzzle.puzzle_bgm).play
else
$game_system.battle_bgm.play
end
RPG::BGS.stop
end
#--------------------------------------------------------------------------
# ● Play puzzle end ME
#--------------------------------------------------------------------------
def self.play_puzzle_end_me
if $game_tpuzzle.puzzle_me && !$game_tpuzzle.puzzle_me.empty?
RPG::ME.new(*$game_tpuzzle.puzzle_me).play
else
$game_system.battle_end_me.play
end
end
#--------------------------------------------------------------------------
# ● Replay map BGM and BGS
#--------------------------------------------------------------------------
def self.replay_bgm_and_bgs
@map_bgm.replay
@map_bgs.replay
end
#--------------------------------------------------------------------------
# ● Determine puzzle end ME
#--------------------------------------------------------------------------
def self.puzzle_end(win)
win ? $data_system.gameover_me.play : play_puzzle_end_me
end
end

#==============================================================================
# ■ Sound
#------------------------------------------------------------------------------
# This module plays sound effects.
#==============================================================================

module Sound
#--------------------------------------------------------------------------
# ● Play SE for block movement
#--------------------------------------------------------------------------
def self.play_tpuzzle_move_se
RPG::SE.new(*TPUZZLE::MOVE_SE).play
end
#--------------------------------------------------------------------------
# ● Play SE for input
#--------------------------------------------------------------------------
def self.play_tpuzzle_input_se
RPG::SE.new(*TPUZZLE::INPUT_SE).play
end
#--------------------------------------------------------------------------
# ● Play SE for chain
#--------------------------------------------------------------------------
def self.play_tpuzzle_chain_se(pitch_inc = 0)
sound = RPG::SE.new(*TPUZZLE::CHAIN_SE)
sound.pitch = [[sound.pitch + pitch_inc, 150].min, 50].max
sound.play
end
#--------------------------------------------------------------------------
# ● Play puzzle start SE
#--------------------------------------------------------------------------
def self.play_tpuzzle_start
RPG::SE.new(*TPUZZLE:UZZLE_START_SE).play
end
end

#==============================================================================
# ■ TPuzzleSettings
#------------------------------------------------------------------------------
#  Struct class that holds temporary variables for puzzles
#==============================================================================

TPuzzleSettings = Struct.newbg_pic, :solo_mode, :start_stage, :next_list,
:fall_limit, uzzle_bgm, uzzle_me, uzzle_chara, :frame) do
#--------------------------------------------------------------------------
# ● Object initialisation
#--------------------------------------------------------------------------
def initialize(*)
super
self.bg_pic ||= ["", ""]
self.solo_mode ||= false
self.puzzle_bgm ||= TPUZZLE:UZZLE_BGM
self.puzzle_me ||= TPUZZLE:UZZLE_END_ME
self.puzzle_chara ||= TPUZZLE::CHARA_FILENAME
self.frame ||= TPUZZLE::FRAME_FILENAME
end
#--------------------------------------------------------------------------
# ● Reset all variables
#--------------------------------------------------------------------------
def clear
self.members.each {|k| send("#{k}=", nil)}
self.bg_pic = ["", ""]
self.solo_mode = false
self.puzzle_bgm = TPUZZLE:UZZLE_BGM
self.puzzle_me = TPUZZLE:UZZLE_END_ME
self.puzzle_chara = TPUZZLE::CHARA_FILENAME
self.frame = TPUZZLE::FRAME_FILENAME
end
end

#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
# This module manages the database and game objects. Almost all of the
# global variables used by the game are initialized by this module.
#==============================================================================

module DataManager
class << self
alias tpz_datamgr_creategameobjs create_game_objects
end
#--------------------------------------------------------------------------
# ● Create game objects
#--------------------------------------------------------------------------
def self.create_game_objects
tpz_datamgr_creategameobjs
$game_tpuzzle = TPuzzleSettings.new
end
end

#==============================================================================
# ■ Cache
#------------------------------------------------------------------------------
# This module loads graphics, creates bitmap objects, and retains them.
# To speed up load times and conserve memory, this module holds the
# created bitmap object in the internal hash, allowing the program to
# return preexisting objects when the same bitmap is requested again.
#==============================================================================

module Cache
#--------------------------------------------------------------------------
# ● Delete animation cache
#--------------------------------------------------------------------------
def self.clear_animations
@cache ||= {}
@cache.keys.each { |k| @cache[k].dispose if k =~ /Animations/i }
end
end

#==============================================================================
# ■ Sprite_Animation
#------------------------------------------------------------------------------
#  This is a sprite class with animation display processing added.
#==============================================================================

class Sprite_Animation < Sprite_Base
#--------------------------------------------------------------------------
# ● Object initialisation
# x : sprite x coordinate
# y : sprite y coordinate
# id : sprite ID
#--------------------------------------------------------------------------
def initialize(x, y, id)
super(nil)
set_animation(x, y, id)
end
#--------------------------------------------------------------------------
# ● Set animation based on ID and X/Y pos
# x : sprite x coordinate
# y : sprite y coordinate
# id : sprite ID
#--------------------------------------------------------------------------
def set_animation(x, y, id)
self.x = x
self.y = y
@use_sprite = true
@ani_duration = 0
start_animation($data_animations[id])
end
#--------------------------------------------------------------------------
# ● Dispose animation
#--------------------------------------------------------------------------
def dispose_animation
@@_reference_count[@ani_bitmap1] -= 1 if @ani_bitmap1
@@_reference_count[@ani_bitmap2] -= 1 if @ani_bitmap2
if @ani_sprites
@ani_sprites.each {|sprite| sprite.dispose }
@ani_sprites = nil
@animation = nil
end
@ani_bitmap1 = nil
@ani_bitmap2 = nil
end
end

#==============================================================================
# ■ TPuzzle_Cell
#------------------------------------------------------------------------------
#  Cell class of falling object puzzle
#==============================================================================

class TPuzzle_Cell
attr_reader :width
attr_reader :height
attr_accessor :x
attr_accessor :y
#--------------------------------------------------------------------------
# ● Object initialisation
# cell_w : cell width
# cell_h : cell height
# sprite_w : sprite width
# sprite_h : sprite height
#--------------------------------------------------------------------------
def initialize(cell_w, cell_h, sprite_w, sprite_h)
@x = 0
@y = 0
@width = cell_w
@height = cell_h
@Cell = Array.new(@width * @height, 0)
@sprite = Sprite.new
@sprite.bitmap = Bitmap.new(sprite_w, sprite_h)
@bitmap_monster = Cache.character($game_tpuzzle.puzzle_chara)
end
#--------------------------------------------------------------------------
# ● Dispose objects
#--------------------------------------------------------------------------
def dispose
@sprite.dispose
@bitmap_monster.dispose
@Cell = nil
end
#--------------------------------------------------------------------------
# ● Get cell value at x/y coordinate
# x : x coordinate
# y : y coordinate
#--------------------------------------------------------------------------
def get(x, y)
return @Cell[x + @width * y]
end
#--------------------------------------------------------------------------
# ● Set cell value at x/y coordinate
# x : x coordinate
# y : y coordinate
# value : cell value
#--------------------------------------------------------------------------
def set(x, y, value)
@Cell[x + @width * y] = value
end
#--------------------------------------------------------------------------
# ● Collision detection between cells
# x : x coordinate
# y : y coordinate
# cell : cell object
#--------------------------------------------------------------------------
def hit?(x, y, cell)
for i in 0...cell.width
for j in 0...cell.height
return true if cell.get(i, j) > 0 && get(i + x, j + y) > 0
end
end
return false
end
#--------------------------------------------------------------------------
# ● Cell-to-cell composition
# x : x coordinate
# y : y coordinate
# cell : cell object
#--------------------------------------------------------------------------
def add(x, y, cell)
for i in 0...cell.width
for j in 0...cell.height
set(i + x, j + y, cell.get(i, j)) if cell.get(i, j) > 0
end
end
end
#--------------------------------------------------------------------------
# ● Sprite display switching
#--------------------------------------------------------------------------
def change_visible
@sprite.visible = [email protected]
end
end

#==============================================================================
# ■ TPuzzle_Stage
#------------------------------------------------------------------------------
#  Stage class of falling object puzzle
#==============================================================================

class TPuzzle_Stage < TPuzzle_Cell
include TPUZZLE

FIELD_WIDTH = 8 # Stage width including walls
FIELD_HEIGHT = 14 # Stage height including walls
FIELD_TOP = 0 # The top edge of the stage, not including walls
FIELD_BOTTOM = 12 # The bottom edge of the stage, not including walls
FIELD_LEFT = 1 # The left edge of the stage, not including walls
FIELD_RIGHT = 6 # The right edge of the stage, not including walls

#--------------------------------------------------------------------------
# ● Object initialisation
# x : x coordinate
# y : y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(FIELD_WIDTH, FIELD_HEIGHT, 192, 384)
@sprite.x = x
@sprite.y = y
@sprite.z = 200
# Create a wall
for i in 0...@height
set(0, i, 1024)
set(@width - 1, i, 1024)
end
for i in 0...@width
set(i, @height - 1, 1024)
end
# Creating the initial state
if $game_tpuzzle.start_stage != nil
for x in FIELD_LEFT..FIELD_RIGHT
for y in FIELD_TOP...FIELD_BOTTOM
set(x, y + 1, $game_tpuzzle.start_stage[y][x - 1])
end
end
draw
end
end
#--------------------------------------------------------------------------
# ● Set a fall flag on the block with an empty cell below and move it
#--------------------------------------------------------------------------
def check_fall
result = false
for x in FIELD_LEFT..FIELD_RIGHT
for i in FIELD_TOP..FIELD_BOTTOM
y = FIELD_BOTTOM - i
next if get(x, y) == 0
if get(x, y + 1) == 0
set(x, y + 1, get(x, y) | 2048)
set(x, y, 0)
# Move all the blocks above with a fall flag
for j in FIELD_TOP...y
y2 = y - j
next if get(x, y2) == 0
set(x, y2 + 1, get(x, y2) | 2048)
set(x, y2, 0)
end
result = true
break
end
end
end
return result
end
#--------------------------------------------------------------------------
# ● Stop the fall flags on all blocks
#--------------------------------------------------------------------------
def stop_fall
for x in FIELD_LEFT..FIELD_RIGHT
for y in FIELD_TOP..FIELD_BOTTOM
set(x, y, get(x, y) & ~2048)
end
end
end
#--------------------------------------------------------------------------
# ● Check if should erase
#--------------------------------------------------------------------------
def check_erase
result = false
for x in FIELD_LEFT..FIELD_RIGHT
for y in FIELD_TOP..FIELD_BOTTOM
n = get(x, y)
next if n == 0 || n == 6
next if n & 8192 != 0 # Ignore counted ones
if count(x, y, n) >= 4
erase(x, y, get(x, y))
result = true
end
end
end
# Stop the count flag of all blocks
for x in FIELD_LEFT..FIELD_RIGHT
for y in FIELD_TOP..FIELD_BOTTOM
set(x, y, get(x, y) & ~8192)
end
end
return result
end
#--------------------------------------------------------------------------
# ● Count the number of adjacent blocks of the same type
# x : x coordinate
# y : y coordinate
# type : type
#--------------------------------------------------------------------------
def count(x, y, type)
n = get(x, y)
return 0 if n != type
set(x, y, n | 8192) # Set a counted flag
return 1 + count(x, y + 1, type) + count(x - 1, y, type) +
count(x + 1, y, type) + count(x, y - 1, type)
end
#--------------------------------------------------------------------------
# ● Flag adjacent blocks of the same type and obstruction
# x : x coordinate
# y : y coordinate
# type : type
#--------------------------------------------------------------------------
def erase(x, y, type)
n = get(x, y)
if n == type
set(x, y, n | 4096) # Set the erase flag
SceneManager.scene.add_animation(@sprite.x + (x << 5) - 16, @sprite.y + (y << 5) - 16, TPUZZLE::BREAK_ANIME)
erase(x, y + 1, type)
erase(x - 1, y, type)
erase(x + 1, y, type)
erase(x, y - 1, type)
elsif n == 6
# If it is an obstacle block, set the erase flag
set(x, y, n | 4096)
end
end
#--------------------------------------------------------------------------
# ● Erase blocks with the erase flag
#--------------------------------------------------------------------------
def stop_erase
n = 0
for x in FIELD_LEFT..FIELD_RIGHT
for y in FIELD_TOP..FIELD_BOTTOM
next if get(x, y) == 0
if get(x, y) & 4096 != 0
set(x, y, 0)
n += 1
end
end
end
return n # Returns the number of erased blocks
end
#--------------------------------------------------------------------------
# ● Draw
# cnt : count
#--------------------------------------------------------------------------
def draw(cnt = 0)
@sprite.bitmap.clear
rect = Rect.new(0, 0, 332, 332)
alpha = cnt
for x in FIELD_LEFT..FIELD_RIGHT
for y in FIELD_TOP..FIELD_BOTTOM
n = get(x, y)
next if n == 0
index = (n & 15) - 1
rect.set(index % 4 * 96 + 32, index / 4 * 128, 32, 32)
x2 = x - 1
y2 = y - 1
if n & 2048 != 0
# if the fall flag is set, the y coordinate is corrected and drawn
@sprite.bitmap.blt(x2 << 5, (y2 << 5) - cnt, @bitmap_monster, rect)
elsif n & 4096 != 0
# If the erase flag is set, set the transparency and draw
@sprite.bitmap.blt(x2 << 5, y2 << 5, @bitmap_monster, rect, alpha)
else
@sprite.bitmap.blt(x2 << 5, y2 << 5, @bitmap_monster, rect)
end
end
end
end
#--------------------------------------------------------------------------
# ● Win / loss drawing
# flag : defeat flag (0 = victory, 1 = defeat)
# id : player ID
#--------------------------------------------------------------------------
def draw_result(flag, id)
if $game_tpuzzle.bg_pic[id] != ""
bitmap = Cache.picture($game_tpuzzle.bg_pic[id])
rect = Rect.new(0, 0, bitmap.width, bitmap.height)
@sprite.bitmap.blt(96 - bitmap.width / 2, 384 - bitmap.height, bitmap, rect)
end
@sprite.bitmap.fill_rect(0, 320, 192, 24, Color.new(0, 0, 0, 128))
if $game_tpuzzle.solo_mode
@sprite.bitmap.draw_text(0, 320, 192, 24, NEUTRAL_TEXT, 1)
else
@sprite.bitmap.draw_text(0, 320, 192, 24, flag == 1 ? DEFEAT_TEXT : VICTORY_TEXT, 1)
end
if id == 0
@sprite.bitmap.fill_rect(0, 352, 192, 24, Color.new(0, 0, 0, 128))
@sprite.bitmap.draw_text(0, 352, 192, 24, EXIT_BUTTON_TEXT, 1)
end
end
#--------------------------------------------------------------------------
# ● Returns whether it is in the erased state
#--------------------------------------------------------------------------
def empty?
for x in FIELD_LEFT..FIELD_RIGHT
for y in FIELD_TOP..FIELD_BOTTOM
return false if get(x, y) != 0
end
end
return true
end
end

#==============================================================================
# ■ TPuzzle_Block
#------------------------------------------------------------------------------
#  Block class of falling object puzzle
#==============================================================================

class TPuzzle_Block < TPuzzle_Cell
attr_reader :angle
attr_accessor :cx
attr_accessor :cy
#--------------------------------------------------------------------------
# ● Object initialisation
# id : player ID
#--------------------------------------------------------------------------
def initialize(id)
@id = id
super(3, 3, 128, 128)
@sprite.z = 250
if id == 0
@block_next = TPuzzle_BlockNext.new(184, 24)
@block_next2 = TPuzzle_BlockNext.new(192, 96)
else
@block_next = TPuzzle_BlockNext.new(264, 24)
@block_next2 = TPuzzle_BlockNext.new(256, 96)
end
# Load fall block list
if $game_tpuzzle.next_list != nil
@pattern_next = [$game_tpuzzle.next_list[0], $game_tpuzzle.next_list[1]]
@next_cursor = 2 # Current position of falling block list
else
@pattern_next = [[rand(5) + 1, rand(5) + 1], [rand(5) + 1, rand(5) + 1]]
end
refresh
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
set_pattern(@pattern_next[0])
@pattern_next[0] = @pattern_next[1]
if $game_tpuzzle.next_list != nil
@pattern_next[1] = $game_tpuzzle.next_list[@next_cursor]
@next_cursor += 1
@next_cursor = 0 if @next_cursor == $game_tpuzzle.next_list.size
else
@pattern_next[1] = [rand(5) + 1, rand(5) + 1]
end
@cx = 2
@cy = 0
@x = cx << 5
@y = cy << 5
@angle = 0
update_sprite
@sprite.visible = true
draw
@block_next.set_pattern(@pattern_next[0])
@block_next2.set_pattern(@pattern_next[1])
end
#--------------------------------------------------------------------------
# ● Draw
#--------------------------------------------------------------------------
def draw
@sprite.bitmap.clear
rect = Rect.new(0, 0, 32, 32)
for x in 0...@width
for y in 0...@height
n = get(x, y)
next if n == 0
rect.set((n - 1) % 4 * 96 + 32, (n - 1) / 4 * 128, 32, 32)
@sprite.bitmap.blt(x << 5, y << 5, @bitmap_monster, rect)
end
end
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
@block_next.dispose
@block_next2.dispose
super
end
#--------------------------------------------------------------------------
# ● Sprite coordinate update
#--------------------------------------------------------------------------
def update_sprite
@sprite.x = @x - 16
@sprite.x += 320 if @id == 1 # Position correction for the 2P side
@sprite.y = @y - 8
end
#--------------------------------------------------------------------------
# ● Rotation processing
# dir : Rotation direction (true = counterclockwise)
#--------------------------------------------------------------------------
def rotate(dir)
# If the block is moved up in the cell, undo it
if @angle == 2 && @Cell[7] == 0
@Cell[7] = @Cell[4]
@Cell[4] = @Cell[1]
@Cell[1] = 0
end
# Update rotation angle
@angle = (@angle + (dir ? -1 : 1) + 4) % 4
n = @Cell[1]
if dir
# Counterclockwise
@Cell[1] = @Cell[5]
@Cell[5] = @Cell[7]
@Cell[7] = @Cell[3]
@Cell[3] = n
else
# Clockwise
@Cell[1] = @Cell[3]
@Cell[3] = @Cell[7]
@Cell[7] = @Cell[5]
@Cell[5] = n
end
end
#--------------------------------------------------------------------------
# ● Change pattern
#--------------------------------------------------------------------------
def set_pattern(pattern)
@cell.fill(0)
@Cell[1] = pattern[0]
@Cell[4] = pattern[1]
end
#--------------------------------------------------------------------------
# ● Change Z pos for end game result
#--------------------------------------------------------------------------
def end_game_z
@sprite.z = 199
end

end

#==============================================================================
# ■ TPuzzle_BlockNext
#------------------------------------------------------------------------------
#  Next block class for falling object puzzles
#==============================================================================

class TPuzzle_BlockNext < TPuzzle_Cell
#--------------------------------------------------------------------------
# ● Object initialisation
# x : x coordinate
# y : y coordinate
#--------------------------------------------------------------------------
def initialize(x, y)
super(3, 3, 128, 128)
@sprite.x = x
@sprite.y = y
@sprite.z = 250
end
#--------------------------------------------------------------------------
# ● Draw
#--------------------------------------------------------------------------
def draw
@sprite.bitmap.clear
rect = Rect.new(0, 0, 32, 32)
for x in 0...@width
for y in 0...@height
n = get(x, y)
next if n == 0
rect.set((n - 1) % 4 * 96 + 32, (n - 1) / 4 * 128, 32, 32)
@sprite.bitmap.blt(x << 5, y << 5, @bitmap_monster, rect)
end
end
end
#--------------------------------------------------------------------------
# ● Set pattern
#--------------------------------------------------------------------------
def set_pattern(pattern)
@cell.fill(0)
@Cell[1] = pattern[0]
@Cell[4] = pattern[1]
draw
end
end

#==============================================================================
# ■ TPuzzle_Score
#------------------------------------------------------------------------------
#  Falling block puzzle score display sprite class
#==============================================================================

class TPuzzle_Score < Sprite
include TPUZZLE
#--------------------------------------------------------------------------
# ● Object initialisation
#--------------------------------------------------------------------------
def initialize
super(nil)
self.bitmap = Bitmap.new(112, 56)
self.x = 216
self.y = 208
self.z = 300
@score = [0, 0]
@p1_rect = Rect.new(4, 0, 104, 24)
@p2_rect = Rect.new(4, 28, 104, 24)
refresh
update_fall_limit
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# ● Update fall limit
#--------------------------------------------------------------------------
def update_fall_limit
return unless $game_tpuzzle.solo_mode
if @fall_limit != $game_tpuzzle.fall_limit
@fall_limit = $game_tpuzzle.fall_limit
draw_fall_limit
end
end
#--------------------------------------------------------------------------
# ● Update
# s1 : player 1 score
# s2 : player 2 score
#--------------------------------------------------------------------------
def update(s1, s2)
update_fall_limit
if @score[0] != s1 || @score[1] != s2
@score = [s1, s2]
refresh
end
end
#--------------------------------------------------------------------------
# ● Draw fall limit
#--------------------------------------------------------------------------
def draw_fall_limit
self.bitmap.clear_rect(@p2_rect)
self.bitmap.draw_text(@p2_rect, "Limit:")
self.bitmap.draw_text(@p2_rect, @fall_limit, 2)
end
#--------------------------------------------------------------------------
# ● Draw player one score
#--------------------------------------------------------------------------
def draw_player_one_text
self.bitmap.clear_rect(@p1_rect)
self.bitmap.draw_text(@p1_rect, PLAYER_ONE)
self.bitmap.draw_text(@p1_rect, @score[0], 2)
end
#--------------------------------------------------------------------------
# ● Draw player two score
#--------------------------------------------------------------------------
def draw_player_two_text
self.bitmap.clear_rect(@p2_rect)
self.bitmap.draw_text(@p2_rect, PLAYER_TWO)
self.bitmap.draw_text(@p2_rect, @score[1], 2)
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
draw_player_one_text
draw_player_two_text unless $game_tpuzzle.solo_mode
end
end

#==============================================================================
# ■ TPuzzle_Game
#------------------------------------------------------------------------------
#  A class that manages games for each player
#==============================================================================
class TPuzzle_Game
include TPUZZLE
attr_reader :game_end, :id
#--------------------------------------------------------------------------
# ● Object initialisation
# id: Player ID (0 = P1, 1 = P2)
#--------------------------------------------------------------------------
def initialize(id)
@id = id
@stage = TPuzzle_Stage.new((id == 0 ? 16 : 336), 24)
@Block = TPuzzle_Block.new(id)
init_variables
end
#--------------------------------------------------------------------------
# ● Set opponent
#--------------------------------------------------------------------------
def enemy=(enemy)
@enemy = enemy
end
#--------------------------------------------------------------------------
# ● Change block's Z pos at end of the game
#--------------------------------------------------------------------------
def end_game_block_z
@block.end_game_z
end
#--------------------------------------------------------------------------
# ● Initialise variables
#--------------------------------------------------------------------------
def init_variables
@score = 0
@game_cnt = 0 # game elapsed time
@state = 0 # game processing status
@cnt = 0
@attack_cnt = 0 # number of obstacle blocks accumulated
@chain_cnt = 0 # number of chains
@attack_fall = false # obstacle block falling flag
@fall_pos = -1 # fall target point for AI
@fall_angle = 0 # rotation angle
@game_end = 0
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
@stage.dispose
@block.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
# update for each state
case @state
when 0 then update_input
when 1 then update_check_fall
when 2 then update_fall
when 3 then update_check_erase
when 4 then update_erase
when 5 then update_pop
end
@game_cnt += 1
end
#--------------------------------------------------------------------------
# ● Once the block has touched the ground
#--------------------------------------------------------------------------
def ground_touch_processing
@stage.add(@block.cx, @block.cy, @Block) # Combine blocks into stage
@block.change_visible # Hide blocks
@stage.draw # Redrawing the stage
@state = 1 # Transition to the fall judgment state
Sound.play_tpuzzle_input_se
end
#--------------------------------------------------------------------------
# ● Process drop
#--------------------------------------------------------------------------
def drop_processing(key)
if @block.y == @block.cy << 5
if @stage.hit?(@block.cx, @block.cy + 1, @Block)
@cnt = 16 # Set the grace time until landing is confirmed
else
@block.cy += 1
end
end
@block.y = [@block.y + (key & 4 == 4 ? 8 : 1), @block.cy << 5].min
end
#--------------------------------------------------------------------------
# ● Check for left/right input
#--------------------------------------------------------------------------
def left_right_processing(key)
if key & 1 != 0 || key & 2 != 0
n = key & 1 != 0 ? 1 : -1
unless @stage.hit?(@block.cx + n, @block.cy, @Block)
@block.cx += n
Sound.play_tpuzzle_move_se
end
end
end
#--------------------------------------------------------------------------
# ● Check for rotation
#--------------------------------------------------------------------------
def rotation_input_processing(key)
flag = key & 16 != 0
if flag || key & 8 != 0
@block.rotate(flag)
check_rotate(flag)
end
end
#--------------------------------------------------------------------------
# ● Update input status
#--------------------------------------------------------------------------
def update_input
key = check_input # confirmation of input
if @cnt > 0
# processing within the grace period until landing is confirmed
@cnt -= 1
if @cnt == 0
# If you touch the ground with a count of 0, go to the fall judgment
if @stage.hit?(@block.cx, @block.cy + 1, @Block)
return ground_touch_processing
end
end
else
drop_processing(key)
end
# Accepts left / right movement input if not moving left / right
if @block.x == @block.cx << 5
left_right_processing(key)
else
@block.x += @block.x < @block.cx << 5 ? 4 : -4
end
rotation_input_processing(key)
@block.update_sprite # Block coordinate update
end
#--------------------------------------------------------------------------
# ● Collision detection after rotation
#--------------------------------------------------------------------------
def check_rotate(dir)
if @stage.hit?(@block.cx, @block.cy, @Block)
if @block.angle == 2
# If the bottom hits, move the block up in the cell
@block.set(1, 0, @block.get(1, 1))
@block.set(1, 1, @block.get(1, 2))
@block.set(1, 2, 0)
elsif @block.angle == 1 && [email protected]?(@block.cx - 1, @block.cy, @Block)
@block.cx -= 1
@block.x = @block.cx << 5
elsif @block.angle == 3 && [email protected]?(@block.cx + 1, @block.cy, @Block)
@block.cx += 1
@block.x = @block.cx << 5
else
# Cancel rotation
@block.rotate(!dir)
return
end
end
Sound.play_tpuzzle_move_se
@block.draw
end
#--------------------------------------------------------------------------
# ● Update of fall judgment status
#--------------------------------------------------------------------------
def update_check_fall
if @stage.check_fall
# If there is a falling block, it will fall
@cnt = 32
@state = 2
update_fall # drop smoothly
else
# If there is no falling block, go to erase judgment
@state = 3
end
end
#--------------------------------------------------------------------------
# ● Falling state update
#--------------------------------------------------------------------------
def update_fall
@cnt = [@cnt - 8, 0].max
if @cnt == 0
# If it falls one step, it returns to the fall judgment
@stage.stop_fall
pop_attack if @attack_fall # Pop until the block isn't falling
@state = 1
end
@stage.draw(@cnt)
end
#--------------------------------------------------------------------------
# ● Update of erasure judgment status
#--------------------------------------------------------------------------
def update_check_erase
if @stage.check_erase
# If there is a block to be erased, go to the erased state
@cnt = 255
@state = 4
@chain_cnt += 1 # increase the number of chains
play_chain_se
else
# If there is no block to erase, obstacle block drop processing
if @attack_cnt > 0 && !enemy_chain?
@attack_fall = true # Flag the obstacle block while falling
pop_attack
@state = 1 # Return to the fall judgment state
else
# If there is no obstacle block or the opponent is in the middle of
# the chain, the next block will appear
@attack_fall = false # Defeat the flag while the block is falling
@state = 5
end
end
end
#--------------------------------------------------------------------------
# ● Play chain SE
#--------------------------------------------------------------------------
def play_chain_se
# Increase SE pitch based on number of chains
if CHAIN_PITCH_INC.is_a?(Integer) && CHAIN_PITCH_INC != 0
chain_cnt = [1, [@chain_cnt, 7].min].max - 1
Sound.play_tpuzzle_chain_se(chain_cnt * CHAIN_PITCH_INC)
else
Sound.play_tpuzzle_chain_se
end
end
#--------------------------------------------------------------------------
# ● Update erase status
#--------------------------------------------------------------------------
def update_erase
@cnt = [@cnt - 16, 0].max
if @cnt == 0
# Return to drop judgment when completely erased
n = (@stage.stop_erase - 4 + 1) * @chain_cnt # Number of attack blocks
@score += n * n * 10 # Score addition
if @attack_cnt > 0 # Offset processing
m = n
n = [n - @attack_cnt, 0].max
@attack_cnt = [@attack_cnt - m, 0].max
end
attack_enemy(n) # add obstacle blocks to the opponent's stage
@state = 1
end
@stage.draw(@cnt)
end
#--------------------------------------------------------------------------
# ● Add obstacle blocks to the opponent's stage
#--------------------------------------------------------------------------
def attack_enemy(value)
if @enemy && !$game_tpuzzle.solo_mode
@enemy.add_attack(value)
end
end
#--------------------------------------------------------------------------
# ● Reappearance status update
#--------------------------------------------------------------------------
def update_pop
# Nazopuyo/solo mode
if $game_tpuzzle.solo_mode
if @stage.empty?
@game_end = 2
elsif $game_tpuzzle.fall_limit != nil
# Check fall limit
$game_tpuzzle.fall_limit -= 1
@game_end = 1 if $game_tpuzzle.fall_limit == 0
end
end
@block.refresh
@game_end = 1 if @stage.hit?(@block.cx, @block.cy, @Block)
@state = 0
@fall_pos = -1 # Reset the planned drop position for AI
@chain_cnt = 0 # Reset chain count
end
#--------------------------------------------------------------------------
# ● Addition of obstacle blocks
#--------------------------------------------------------------------------
def add_attack(num)
@attack_cnt += num
end
#--------------------------------------------------------------------------
# ● Returns whether in a chain
#--------------------------------------------------------------------------
def chain?
return (@chain_cnt > 0)
end
#--------------------------------------------------------------------------
# ● Returns whether the opponent is in a chain
#--------------------------------------------------------------------------
def enemy_chain?
return false if $game_tpuzzle.solo_mode || @enemy.nil?
return @enemy.chain?
end
#--------------------------------------------------------------------------
# ● Make one block appear
#--------------------------------------------------------------------------
def pop_attack
r = rand(6)
for i in 0...6
x = (i + r) % 6 + 1
if @attack_cnt > 0 && @stage.get(x, 1) == 0
@stage.set(x, 1, 6)
@attack_cnt -= 1
end
end
@attack_fall = false if @attack_cnt == 0
end
#--------------------------------------------------------------------------
# ● Return score
#--------------------------------------------------------------------------
def get_score
return @score
end
#--------------------------------------------------------------------------
# ● Draw result
#--------------------------------------------------------------------------
def draw_result
@stage.draw_result(@game_end, @id)
end
#--------------------------------------------------------------------------
# ● Decide drop position for AI
#--------------------------------------------------------------------------
def decide_ai_drop_pos
pos = rand(6) + 1
angle = 0
score = 0
type = @block.get(1, 1)
type2 = @block.get(1, 0)
for x in 1..6
for y in 1..13
if @stage.get(x, y) != 0
# If it does not rotate
n = 0
n += 2 if @stage.get(x, y) == type
n += 2 if @stage.get(x - 1, y - 1) == type
n += 2 if @stage.get(x + 1, y - 1) == type
n += 2 if @stage.get(x + 1, y - 2) == type2
n += 2 if @stage.get(x - 1, y - 2) == type2
n += y - 4
if n > score
pos = x
angle = 0
score = n
end
# When swapping up and down
n = 0
n += 2 if @stage.get(x, y) == type2
n += 2 if @stage.get(x - 1, y - 1) == type2
n += 2 if @stage.get(x + 1, y - 1) == type2
n += 2 if @stage.get(x + 1, y - 2) == type
n += 2 if @stage.get(x - 1, y - 2) == type
n += y - 4
if n > score
pos = x
angle = 2
score = n
end
break
end
end
end
@fall_pos = pos - 1
@fall_angle = angle
end
#--------------------------------------------------------------------------
# ● Process AI
#--------------------------------------------------------------------------
def process_ai
key = 0
# AI processing
if @fall_pos == -1
# If the drop position is not decided, decide
decide_ai_drop_pos
else
if @block.x == @block.cx << 5
if @block.cx < @fall_pos
key = key | 1
elsif @block.cx > @fall_pos
key = key | 2
else
key = 4 # Enter below if it is directly above the drop target point
end
end
key = key | 16 if @block.angle != @fall_angle
end
return key
end
#--------------------------------------------------------------------------
# ● Confirmation of input, AI processing for P2
#--------------------------------------------------------------------------
def check_input
key = 0
key = @id == 1 ? process_ai : set_key_by_press(key)
return key
end
#--------------------------------------------------------------------------
# ● P1 input processing
#--------------------------------------------------------------------------
def set_key_by_press(key)
# 1P input processing
key = key | 1 if Input.press?RIGHT)
key = key | 2 if Input.press?LEFT)
key = key | 4 if Input.press?DOWN)
key = key | 8 if Input.trigger?(ROTATE_R_BUTTON)
key = key | 16 if Input.trigger?(ROTATE_L_BUTTON)
return key
end
end

#==============================================================================
# ■ TPuzzle_Scene
#------------------------------------------------------------------------------
#  Scene class of falling object puzzle
#==============================================================================

class TPuzzle_Scene < Scene_Base
attr_accessor :game_end
#--------------------------------------------------------------------------
# ● Object initialisation
#--------------------------------------------------------------------------
def initialize
unless $game_tpuzzle.solo_mode
$game_tpuzzle.start_stage = nil
$game_tpuzzle.next_list = nil
$game_tpuzzle.fall_limit = nil
end
super
end
#--------------------------------------------------------------------------
# ● Start processing
#--------------------------------------------------------------------------
def start
super
TPuzzleManager.save_bgm_and_bgs
Sound.play_tpuzzle_start
TPuzzleManager.play_puzzle_bgm
create_menu_background
create_players
@sprite_score = TPuzzle_Score.new
@sprite_animation = []
end
#--------------------------------------------------------------------------
# ● Create players
#--------------------------------------------------------------------------
def create_players
@Player = [TPuzzle_Game.new(0), $game_tpuzzle.solo_mode ? nil : TPuzzle_Game.new(1)]
@Player[0].enemy = @Player[1]
@Player[1].enemy = @Player[0] if @Player[1]
end
#--------------------------------------------------------------------------
# ● Dispose players
#--------------------------------------------------------------------------
def dispose_players
@player.each { |player| player.dispose if player }
end
#--------------------------------------------------------------------------
# ● Dispose sprites
#--------------------------------------------------------------------------
def dispose_sprites
@sprite_animation.each { |sprite| sprite.dispose if sprite }
end
#--------------------------------------------------------------------------
# ● Update sprites
#--------------------------------------------------------------------------
def update_sprites
@sprite_animation.each { |sprite| sprite.update if sprite }
end
#--------------------------------------------------------------------------
# ● Dispose all
#--------------------------------------------------------------------------
def dispose_all
dispose_background
dispose_players
@sprite_score.dispose
dispose_sprites
Cache.clear_animations # Delete animation cache
end
#--------------------------------------------------------------------------
# ● Set game variables/switches
#--------------------------------------------------------------------------
def set_game_variables
$game_switches[TPUZZLE::RESULT_SWT] = @Player[0].game_end != 1
$game_variables[TPUZZLE::RESULT_VAR] = @Player[0].get_score
end
#--------------------------------------------------------------------------
# ● Terminate
#--------------------------------------------------------------------------
def terminate
super
set_game_variables
TPuzzleManager.replay_bgm_and_bgs
dispose_all
reset_tpuzzle
end
#--------------------------------------------------------------------------
# ● Reset temporary variables
#--------------------------------------------------------------------------
def reset_tpuzzle
$game_tpuzzle.clear
end
#--------------------------------------------------------------------------
# ● Update input for game end
#--------------------------------------------------------------------------
def update_input
SceneManager.return if @game_end && Input.trigger?(TPUZZLE::EXIT_BUTTON)
end
#--------------------------------------------------------------------------
# ● Update each player
#--------------------------------------------------------------------------
def update_players
@player.each { |player| player.update if player }
end
#--------------------------------------------------------------------------
# ● Draw player result
#--------------------------------------------------------------------------
def draw_player_result
@player.each do |player|
if player
player.draw_result
player.end_game_block_z
end
end
end
#--------------------------------------------------------------------------
# ● Update solo mode processing
#--------------------------------------------------------------------------
def update_tpuzzle_nazopuyo
# Nazopuyo mode processing
@sprite_score.update(@Player[0].get_score, nil)
process_puzzle_end if @Player[0].game_end != 0
end
#--------------------------------------------------------------------------
# ● Update 2P mode processing
#--------------------------------------------------------------------------
def update_tpuzzle_cpu
# Processing of CPU battle
@sprite_score.update(@Player[0].get_score, @Player[1].get_score)
process_puzzle_end if @Player[0].game_end == 1 || @Player[1].game_end == 1
end
#--------------------------------------------------------------------------
# ● Puzzle end processing
#--------------------------------------------------------------------------
def process_puzzle_end
@game_end = true
draw_player_result
TPuzzleManager.puzzle_end(@Player[0].game_end == 1)
end
#--------------------------------------------------------------------------
# ● Update game result
#--------------------------------------------------------------------------
def update_result
return if @game_end
update_players
$game_tpuzzle.solo_mode ? update_tpuzzle_nazopuyo : update_tpuzzle_cpu
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
update_sprites
update_result
update_input
end
#--------------------------------------------------------------------------
# ● Create Background
#--------------------------------------------------------------------------
def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = SceneManager.background_bitmap
@background_sprite.color.set(16, 16, 16, 128)
end
#--------------------------------------------------------------------------
# ● Dispose Background
#--------------------------------------------------------------------------
def dispose_background
@background_sprite.dispose
end
#--------------------------------------------------------------------------
# ● Create background for the menu screen
#--------------------------------------------------------------------------
def create_menu_background
create_background
if $game_tpuzzle.bg_pic[0] != ""
bitmap = Cache.picture($game_tpuzzle.bg_pic[0])
rect = Rect.new(0, 0, bitmap.width, bitmap.height)
@background_sprite.bitmap.blt(112 - bitmap.width / 2, 408 - bitmap.height, bitmap, rect)
end
if $game_tpuzzle.bg_pic[1] != ""
bitmap = Cache.picture($game_tpuzzle.bg_pic[1])
rect = Rect.new(0, 0, bitmap.width, bitmap.height)
@background_sprite.bitmap.blt(432 - bitmap.width / 2, 408 - bitmap.height, bitmap, rect)
end
bitmap = Cache.system($game_tpuzzle.frame)
rect = Rect.new(0, 0, Graphics.width, Graphics.height)
@background_sprite.bitmap.blt(0, 0, bitmap, rect)
end
#--------------------------------------------------------------------------
# ● Add animation
#--------------------------------------------------------------------------
def add_animation(x, y, id)
if @sprite_animation[id] && !@sprite_animation[id].animation?
return @sprite_animation[id].set_animation(x, y, id)
end
@sprite_animation << Sprite_Animation.new(x, y, id)
end
end

There are some other things that I would like changed, if possible of course.
The window always fades in and out and when you break the pieces they fade out, which looks weird for my game since it's going for something more 1980's computer game. is there a way to remove these fade ins?
Another thing is the colors. The window and the character portraits are suposed to be white however in game they are greyed out which could kinda mess with my games color palette.
These last two things aren't really that bad to be honest but I would still like them changed if possible.

thank you
There is one thing that you can help yourself with and really you need to anyways is resize the frame image. Increase it to 640 x 480, which when I tried in photoshop it went to 640 x 489. So careful how you change the size.
second is the colour. Line 1475 says @background_sprite.color.set(16, 16, 16, 128)
delete this line. It's what is putting the shade on your image. Technically a tone I believe.

Some of the other parts (resizing) will take a bit of effort from someone. I'm looking at it but not sure I will be able to do it easily, or at all.
And fading, I don't see as it plays an animation for the parts that get removed so it's covered over. I assume you don't have an animation playing that covers it so you see the fade.

* adjusting the item positions
Text - line 848 and down.
For the frame image that I resized these settings worked for me.
Ruby:
    self.bitmap = Bitmap.new(112, 56)
    self.x = 255
    self.y = 240
    self.z = 300
    @score = [0, 0]
    @p1_rect = Rect.new(4, 0, 104, 24)
    @p2_rect = Rect.new(4, 32, 104, 24)

For the next block position these settings worked for me, line 681 and down
Ruby:
    super(3, 3, 128, 128)
    @sprite.z = 250
    if id == 0
      @block_next = TPuzzle_BlockNext.new(225, 30)
      @block_next2 = TPuzzle_BlockNext.new(235, 115)
    else
      @block_next = TPuzzle_BlockNext.new(319, 30)
      @block_next2 = TPuzzle_BlockNext.new(309, 115)
    end

Now to understand how the blocks work.
There is one thing that you can help yourself with and really you need to anyways is resize the frame image. Increase it to 640 x 480, which when I tried in photoshop it went to 640 x 489. So careful how you change the size.
second is the colour. Line 1475 says @background_sprite.color.set(16, 16, 16, 128)
delete this line. It's what is putting the shade on your image. Technically a tone I believe.

Some of the other parts (resizing) will take a bit of effort from someone. I'm looking at it but not sure I will be able to do it easily, or at all.
And fading, I don't see aas it plays an animation for the parts that get removed so it's covered over. I assume you don't have an animation playing that covers it so you see the fade.

* adjusting the item positions
Text - line 848 and down.
For the frame image that I resized these settings worked for me.
Ruby:
    self.bitmap = Bitmap.new(112, 56)
    self.x = 255
    self.y = 240
    self.z = 300
    @score = [0, 0]
    @p1_rect = Rect.new(4, 0, 104, 24)
    @p2_rect = Rect.new(4, 32, 104, 24)

For the next block position these settings worked for me, line 681 and down
Ruby:
    super(3, 3, 128, 128)
    @sprite.z = 250
    if id == 0
      @block_next = TPuzzle_BlockNext.new(225, 30)
      @block_next2 = TPuzzle_BlockNext.new(235, 115)
    else
      @block_next = TPuzzle_BlockNext.new(319, 30)
      @block_next2 = TPuzzle_BlockNext.new(309, 115)
    end

Now to understand how the blocks work.
oohhh yeah, thank you!
Following your advice I definetly notice the scores being more in the center like I asked.
Captura de ecrã 2025-08-16 081911-min.png


Now all I gotta do is fix the background like you said and also fix the falling blocks which I am still trying to figure out myself looking at the script. If you figure out how to do it, please tell me.
I also this the character images are separate as well but I also know how to move them as I accidentally came across that yesterday

Thank you so much
Also another thing I just found is the win/ loss screen
I can edit the coordinates just fine I think
But for some reason the images are cropped and I can't for the life if me figure out how to uncrop them
Captura de ecrã 2025-08-16 095110-min.png

Captura de ecrã 2025-08-16 095037-min.png
the character images are separate
Looking and they are set in def create_menu_background line 1486
the @background_sprite.bitmap.blt part has two numbers you can adjust 112 and 408 then 428 and 408, (x, y)

Looks like you found the other part, draw_result but the victory image is drawn in the space for the game window which is created on line 931. change 386 to 416. looked ok to me. as for the shinkage, It might actually be the normal image size? not sure, but maybe the background is stretched. But like you said, hoq? I don't see much different between the two.

But yes there are several parts that are in play here. unsure how to make the correct changes. Most of my tests are not providing clues how to move forward.
Looking and they are set in def create_menu_background line 1486
the @background_sprite.bitmap.blt part has two numbers you can adjust 112 and 408 then 428 and 408, (x, y)

Looks like you found the other part, draw_result but the victory image is drawn in the space for the game window which is created on line 931. change 386 to 416. looked ok to me. as for the shinkage, It might actually be the normal image size? not sure, but maybe the background is stretched. But like you said, hoq? I don't see much different between the two.

But yes there are several parts that are in play here. unsure how to make the correct changes. Most of my tests are not providing clues how to move forward.
Not sure if I found the exact line of code you were talking about because for some reason our line numbers don't align, BUT, with what you said now the placed blocks are a lot better alligned with the frame. The falling blocks though still fall in their original position so that still needs to change. Also the victory screens are still cropped but it does seem we are getting closer. Thank you so much for your help!

Captura de ecrã 2025-08-16 104307-min.png
Captura de ecrã 2025-08-16 104345-min.png
Captura de ecrã 2025-08-16 104403-min.png

If you want, I could send you my game if that would help
I somehow figured it out?
I found the bit of code that changes the falling blocks positions and edited it like this.
Captura de ecrã 2025-08-16 114132.png

Now it looks perfect!
Captura de ecrã 2025-08-16 114119-min.png

Now the only thing left to fix is is the victory screens and then I'll do some tweaks to the frame itself in aseprite
Looking and they are set in def create_menu_background line 1486
the @background_sprite.bitmap.blt part has two numbers you can adjust 112 and 408 then 428 and 408, (x, y)

Looks like you found the other part, draw_result but the victory image is drawn in the space for the game window which is created on line 931. change 386 to 416. looked ok to me. as for the shinkage, It might actually be the normal image size? not sure, but maybe the background is stretched. But like you said, hoq? I don't see much different between the two.

But yes there are several parts that are in play here. unsure how to make the correct changes. Most of my tests are not providing clues how to move forward.
Also I've been looking at them closely and I don't think the background is stretched, it really does seem that the victory screen is cropped because the full image isn't showing
I somehow figured it out?
Well done, but this works for me. (you need to correct the double negative anyways)
Ruby:
  def update_sprite
    @sprite.x = @x
    @sprite.x += 384 if @id == 1      # Position correction on the 2P side
    @sprite.y = @y - 8

I was also thinking it needed to be taller. but not sure how to do that. At least it will be working once we figure out the player images

I've got it aligned like this now.
1755358044418.png

Ruby:
  def create_menu_background
    create_background
    if $game_tpuzzle.bg_pic[0] != ""
      bitmap = Cache.picture($game_tpuzzle.bg_pic[0])
      rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      @background_sprite.bitmap.blt(120 - bitmap.width / 2, 160 - bitmap.height / 2, bitmap, rect)
    end
    if $game_tpuzzle.bg_pic[1] != ""
      bitmap = Cache.picture($game_tpuzzle.bg_pic[1])
      rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      @background_sprite.bitmap.blt(500 - bitmap.width / 2, 160 - bitmap.height / 2, bitmap, rect)
    end
Ruby:
  def draw_result(flag, id)
    if $game_tpuzzle.bg_pic[id] != ""
      bitmap = Cache.picture($game_tpuzzle.bg_pic[id])
      rect = Rect.new(0, 0, bitmap.width, bitmap.height)
      @sprite.bitmap.blt(88 - bitmap.width / 2, 148 - bitmap.height / 2, bitmap, rect)
So if I change the 148 to 160 then they should align. * correction 160 went the other way. trying 140 now
how does it look for you with this?
136 instead of 148 worked for me, the player 2 image was just misaligned by 4 pixels on the x axis.

Your numbers are still misaligned
1755358664294.png
1755358643503.png

try this
Ruby:
class TPuzzle_Score < Sprite
  include TPUZZLE
  #--------------------------------------------------------------------------
  # ● Object initialisation
  #--------------------------------------------------------------------------
  def initialize
    super(nil)
    self.bitmap = Bitmap.new(120, 56)
    self.x = 255
    self.y = 240
    self.z = 300
    @score = [0, 0]
    @p1_rect = Rect.new(4, 0, 120, 24)
    @p2_rect = Rect.new(4, 32, 120, 24)
def update_sprite @sprite.x = @x @sprite.x += 384 if @id == 1 # Position correction on the 2P side @sprite.y = @y - 8
I ended up adding +4 instead of the double negative. I tried to do it the way you had it but it was slightly misaligned and it was annoying me. There's nothing wrong with the +4 right?
Captura de ecrã 2025-08-16 161031.png




def draw_result(flag, id) if $game_tpuzzle.bg_pic[id] != "" bitmap = Cache.picture($game_tpuzzle.bg_pic[id]) rect = Rect.new(0, 0, bitmap.width, bitmap.height) @sprite.bitmap.blt(88 - bitmap.width / 2, 148 - bitmap.height / 2, bitmap, rect)
Had to mess around with the numbers a bit but ended up getting something I'm happy with.
Captura de ecrã 2025-08-16 160955-min.png


Also touched up the scores a bit.
Captura de ecrã 2025-08-16 161802.png


Thank you so much for your help man, you've been a real blessing for me.
I'll probably record a video of the game in action later today.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-amn-tomoaky-puzzle-battle-vx-ace-script.179588/