04-24-2011, 07:18 PM
There are a few other errors with Selwyn's rewrite. I, too, use it in my Resolution kit, however I have modified it a bit to fix several errors, mainly with how the bitmap is tiled across the sprite. Here is my modified version of Selwyn's script:
This should work with different resolutions.
As for your scrolling issue on the title screen. it's most likely how you are calling the plane class. If this doesn't fix the error, please post the script you use to scrol a plane on the title screen and I'll see what I can do to fix it for you.
Content Hidden
Code:
#==============================================================================
# – SG::Plane
#------------------------------------------------------------------------------
# originally by Selwyn
# edited and remastered by Draycos Goldaryn
#------------------------------------------------------------------------------
# This is a replacement for the Plane class. Planes are special sprites that
# tile bitmap patterns across the entire screen, and are used to display
# panoramas and fog.
#==============================================================================
module SG
class Plane
attr_reader :ox, :oy
#--------------------------------------------------------------------------
# — initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil)
@sprite = Sprite.new(viewport) # The special Sprite
@max_width = 640 # The maximum viewable width
@max_height = 480 # The maximum viewable height
@bitmap = nil # The Bitmap to be tiled across the Plane
@ox = 0 # The Plane's starting x coordinate
@oy = 0 # The Plane's starting y coordinate
end
#--------------------------------------------------------------------------
# — z, zoom_x, zoom_y, opacity, blend_type, color, tone
# z=, zoom_x=, zoom_y=, opacity=, blend_type=, color=, tone=
#--------------------------------------------------------------------------
def method_missing(symbol, *args)
@sprite.method(symbol).call(*args)
end
#--------------------------------------------------------------------------
# — bitmap=
#--------------------------------------------------------------------------
def bitmap=(bitmap)
@bitmap = bitmap
refresh
end
#--------------------------------------------------------------------------
# — ox=
#--------------------------------------------------------------------------
def ox=(ox)
# If the bitmap hasn't been defined, don't do anything.
return if @bitmap.nil?
w = (@sprite.bitmap.width / 2)
# If there is no change, don't do anything.
if @ox == ox or @ox == ox % w
return
end
# Otherwise, scroll the Plane horizontally
@ox = ox % w
@sprite.ox = @ox
end
#--------------------------------------------------------------------------
# — oy=
#--------------------------------------------------------------------------
def oy=(oy)
# If the bitmap hasn't been defined, don't do anything.
return if @bitmap.nil?
h = (@sprite.bitmap.height / 2)
# If there is no change, don't do anything.
if @oy == oy or @oy == oy % h
return
end
# Otherwise, scroll the Plane vertically
@oy = oy % h
@sprite.oy = @oy
end
#--------------------------------------------------------------------------
# — refresh
#--------------------------------------------------------------------------
def refresh
# If there was already a bitmap made, get rid of it.
if @sprite.bitmap != nil
@sprite.bitmap.dispose
end
# If the bitmap hasn't been defined, don't do anything.
return if @bitmap.nil?
# Set the maximum viewable area
w = @sprite.viewport != nil ? @sprite.viewport.rect.width : @max_width
h = @sprite.viewport != nil ? @sprite.viewport.rect.height : @max_height
# Set the size of the Sprite.Bitmap. it should be greater than 4x the
# viewable area for proper scrolling
bw,bh = @bitmap.width,@bitmap.height
until bw > w * 2
bw += @bitmap.width
end
until bh > h * 2
bh += @bitmap.height
end
@sprite.bitmap = Bitmap.new(bw * 2, bh * 2)
# Now that the size is set, find out how many times the bitmap will fit
max_x = @sprite.bitmap.width / @bitmap.width
max_y = @sprite.bitmap.height / @bitmap.height
# Go ahead and tile the bitmap till it fills the Sprite
for x in 0..max_x
for y in 0..max_y
@sprite.bitmap.blt(x * @bitmap.width, y * @bitmap.height,
@bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height))
end
end
end
end
end
This should work with different resolutions.
As for your scrolling issue on the title screen. it's most likely how you are calling the plane class. If this doesn't fix the error, please post the script you use to scrol a plane on the title screen and I'll see what I can do to fix it for you.