Well, i have some code i can share if you want, but the problem is, it only works with one resolution, 480x320, here's the script i currently used, basically converted an RMXP script i found.
CODE
module Setup
RESOLUTION = [Graphics.width.to_f, Graphics.height.to_f]
def self.x_value
return RESOLUTION[0] / 544
end
def self.y_value
return RESOLUTION[1] / 416
end
def self.c_value
return ( ( RESOLUTION[0] / 544 ) + ( RESOLUTION[1] / 416 ) ) / 2
end
def self.h_value
return RESOLUTION[0]
end
def self.v_value
return RESOLUTION[1]
end
def self.variance
return ( ( ( RESOLUTION[0] / 544 ) + ( RESOLUTION[1] / 416 ) ) / 2 ) - 1
end
end
class Spriteset_Map
alias resolution_initialize initialize
def initialize
@viewport1 = Viewport.new ( 0, 0, Setup.h_value, Setup.v_value )
@viewport2 = Viewport.new ( 0, 0, Setup.h_value, Setup.v_value )
@viewport3 = Viewport.new ( 0, 0, Setup.h_value, Setup.v_value )
resolution_initialize
end
end
class Game_Map
def scroll_down ( distance )
if loop_vertical?
@display_y += distance
@display_y %= @map.height + 3 * ( 256 * Setup.y_value )
@parallax_y += distance
else
last_y = @display_y
@display_y = [@display_y + distance, (height + 3 - 13) * ( 256 * Setup.y_value ) ].min
@parallax_y += @display_y - last_y
end
end
def scroll_right ( distance )
if loop_horizontal?
@display_x += distance
@display_x %= @map.width + 2 * ( 256 * Setup.h_value )
@parallax_x += distance
else
last_x = @display_x
@display_x = [@display_x + distance, (width + 2 - 17) * ( 256 * Setup.x_value ) ].min
@parallax_x += @display_x - last_x
end
end
def start_scroll ( direction, distance, speed )
@scroll_direction = direction
@scroll_rest = distance * ( 256 * Setup.c_value )
@scroll_speed = speed
end
end
class Game_Character
alias resolution_initialize initialize
def initialize
resolution_initialize
@move_speed = 4 + ( Setup.variance * 2 )
end
def moving?
return ( @real_x != @x * ( 256 * Setup.x_value ) or @real_y != @y * ( 256 * Setup.y_value ) )
end
def moveto(x, y)
@x = x % $game_map.width
@y = y % $game_map.height
@real_x = @x * ( 256 * Setup.x_value )
@real_y = @y * ( 256 * Setup.y_value )
@prelock_direction = 0
straighten
update_bush_depth
end
def screen_x
return ( $game_map.adjust_x ( @real_x ) + 8007 ) / 8 - 1000 + ( 16 * Setup.x_value )
end
def screen_y
y = ( $game_map.adjust_y ( @real_y ) + 8007 ) / 8 - 1000 + ( 32 * Setup.y_value )
y -= 4 unless object?
if @jump_count >= @jump_peak
n = @jump_count - @jump_peak
else
n = @jump_peak - @jump_count
end
return y - (@jump_peak * @jump_peak - n * n) / 2
end
def update_animation
speed = @move_speed + (dash? ? 1 : 0)
if @anime_count > 18 - speed * ( 2 - ( Setup.variance * 2 ) )
if not @step_anime and @stop_count > 0
@pattern = @original_pattern
else
@pattern = (@pattern + 1) % 4
end
@anime_count = 0
end
end
def update_jump
@jump_count -= 1
@real_x = ( @real_x * @jump_count + @x * ( 256 * Setup.x_value ) ) / ( @jump_count + 1 )
@real_y = ( @real_y * @jump_count + @y * ( 256 * Setup.y_value) ) / ( @jump_count + 1 )
update_bush_depth
end
def update_move
distance = 2 ** @move_speed
distance *= 2 if dash?
@real_x = [@real_x - distance, @x * ( 256 * Setup.x_value )].max if @x * ( 256 * Setup.x_value ) < @real_x
@real_x = [@real_x + distance, @x * ( 256 * Setup.x_value )].min if @x * ( 256 * Setup.x_value ) > @real_x
@real_y = [@real_y - distance, @y * ( 256 * Setup.y_value)].max if @y * ( 256 * Setup.y_value) < @real_y
@real_y = [@real_y + distance, @y * ( 256 * Setup.y_value)].min if @y * ( 256 * Setup.y_value) > @real_y
update_bush_depth unless moving?
if @walk_anime
@anime_count += 1.5
elsif @step_anime
@anime_count += 1
end
end
end
class Game_Player < Game_Character
CENTER_X = ( ( ( 544 / 2 ) * Setup.x_value ) - 48) * 8
CENTER_Y = ( ( ( 416 / 2 ) * Setup.y_value ) - 48) * 8
def center ( x, y )
display_x = x * ( 256 * Setup.x_value ) - CENTER_X
unless $game_map.loop_horizontal?
max_x = ( $game_map.width - 17 ) * ( 256 * Setup.x_value )
display_x = [0, [display_x, max_x].min].max
end
display_y = y * ( 256 * Setup.y_value ) - CENTER_Y
unless $game_map.loop_vertical?
max_y = ( $game_map.height - 13 ) * ( 256 * Setup.y_value )
display_y = [0, [display_y, max_y].min].max
end
$game_map.set_display_pos ( display_x, display_y )
end
end
The problem code that makes it only one resolution is this:
CODE
def scroll_down ( distance )
if loop_vertical?
@display_y += distance
@display_y %= @map.height + 3 * ( 256 * Setup.y_value )
@parallax_y += distance
else
last_y = @display_y
@display_y = [@display_y + distance, (height + 3 - 13) * ( 256 * Setup.y_value ) ].min
@parallax_y += @display_y - last_y
end
end
def scroll_right ( distance )
if loop_horizontal?
@display_x += distance
@display_x %= @map.width + 2 * ( 256 * Setup.h_value )
@parallax_x += distance
else
last_x = @display_x
@display_x = [@display_x + distance, (width + 2 - 17) * ( 256 * Setup.x_value ) ].min
@parallax_x += @display_x - last_x
end
end
I did a quick fix for the resolution i was in, the width + 2 for scrolling right, and height + 3 for scrolling down, the problem is, i tried to calculate a formula for this, but it doesn't seem constant with different resolutions, this script works absolutely fine for 480x320 (GBA res)
Screenshot of it in action:
This post has been edited by deadlydan: Jan 30 2008, 04:18 PM