Help - Search - Members - Calendar
Full Version: [REUPLOADED LINK] Mode 7 for VX version 1.5
RPG RPG Revolution Forums > Scripting > Script Submissions > RGSS2-Submissions
Dusk noun
MODE 7 for VX Version 1.5 REUPLOADED LINK

Author: Dusk Noun
Based on the original script by: 2chan web page
Version: 1.5


Features


Displays the map in conic perspective to create a 3-D feeling


From BETA to 1.5

I've been working on this script and i've changed the politic of it.

- Use a variable to declare if mode 7 is on or off and a method to display/dispose fader

- Corrected Mapping Guide

- Reduced classes creation increasing compatibility.

Code
<div style="margin:20px; margin-top:5px"><div style="margin-bottom:2px">[Show/Hide] Script</div><div style="margin: 0px; padding: 6px; border: 1px inset;"><div style="display: none;">



#==============================================================================#
# ■ Mode 7 Script 1.5 for RMVX #
# |-> Author: Dusk Noun (24/1/09) #
# '-> Based on the original Script: 2chan (http://www.2ch.net/) #
#==============================================================================#
# ■ Chronology #
# |-> Analyzed the original script by 2chan #
# |-> Edit useful methods and created the needed windows #
# |-> BETA release -> Made the mode 7 independent with 2 bugs #
# '-> 1.5 -> Made the mode 7, you can evade bugs with work #
#==============================================================================#
# ■ Emproved from BETA #
# |-> Possibility to switch on/off the mode 7 #
# |-> Possibility to switch on/off the fader (evaded bug) #
# '-> Corrected mapping guide #
#==============================================================================#
# ■ Developing ideas #
# |-> Parallax on looped maps #
# |-> Angle settable #
# |-> Fix side-scrolling bitmap bug #
# '-> Add depth to characters #
#==============================================================================#
# ■ Notes of the author #
# - To avoid missunderstandings: I didn't create this script. I looked on the #
# script of the 2chan page (designed only for airships) and i made another #
# script based on it. So, I OWN this if they're credit as base script. I #
# haven't stolen anyone's idea. #
# - This is a BETA version. It's still developing so it shall have bugs #
#==============================================================================#
# ■ Instructions #
# - Place it above main #
# - $game_map.mode3D controls the on/off Mode 7 #
# - Call draw_fader (n) to put as fader n graphic (in pictures folder), put #
# nil to dispose the fader -> draw_fader(nil) #
#==============================================================================#
# ■ Compatibility #
# - This script changes the spriteset_map class and makes other 2 classes. No #
# compatibility errors detected but they could be #
#==============================================================================#

#==============================================================================#
# MODE 7 MAPPING GUIDE #
#==============================================================================#
=begin

One of the problems of this script is, the rules you need to respect to make a
map in perspective.

The 1st thing you need to know is, this script ONLY affects the map vision. The
players & events layer aren't touched, maybe in the 1st FINISHED release...

So you must repect the rules.

1. The fader
The fader is an image put over the events layer to simulate an horizont. It can
resemble useless but if we don't have it, the scrolling events will crash the
3-D enviroment. It's hard to explain, i'll try it:
Normally, the floor covers all the screen and the events scroll from up to
down always in the floor. But with Mode 7, the floor doesn't cover all the
screen, it leaves 3 rows (in this angle) without covering, and the scrolling
isn't touched so when the events are in those 3 rows, they're in the air. The
effect is that you'll see the events falling from the sky. The fader covers
those 3 lines so the events are shown only when they're in the floor. That way
you don't solve the problem but you neither see it.

To display a fader, call method draw_fader(i). If i's nil, fader will dispose..
Any other way, the variable must have the name of a graphic in pictures folder.
Note that that graphic must only cover the upper size. You can use the deafult
one for not making a new one.

NOTE: the draw_fader doesn't update never, if you start with a map with fader.
Call it in an autorun event. It's recommended to call it before transfering
the player to a new room, such as $game_map.mode3D to avoid the 1st frame of
the new room without the settings (if you call them on an autorun event, 1st
frame won't be affected by the event).

2. Vertical loop
If you have the vertical loop on or a map with a larger height than the screen
you must put a fader to avoid the events falling from sky when they appear at
the top of the screen.

If you don't have a vertical loop, you have the risk to end walking on the air.
To avoid that, i've calculated: the floor ends in the 3rd row from up to down.
So if you put a wall of non-sprite but solid and with the same priority as
characters events (to block the pass) in the 3rd row, you won't pass from the
floors limit.


3. Horizontal loop
If you put horizontal loop, you'll have no problem, just a view bug that will
dissappear once you've walked a bit.

If you don't put it, you'll have the problem as with non-vertical loop, you can
end walking in the air. And with the vertical, it was a line to block the pass,
but here there's no precision. If you don't block the pass, you end in tha air
and if you block it, there'sa piece of floor you can't pass. The best way is:
Put an empty event on the 2nd extremes tiles of the 4th row:
-------------
| || | | || | (4th row)
-------------
And put an empty event in the extremes of the 5th and 6th rows (you can get
inspired in the 3rd map of the demo if you have doubts.)

NOTE: all the tiles where to put empty events are thought for an angle of 60, if
you change the angle, everything changes.

NOTE: When you put a long height and none horizontal looped map... just as the
other non-looped maps, horizontally there's no problem untill the end of
the map.

DO NOT DO THIS
In mode 7, the map tileset is the floor and events are the rest. Don't make
buildings with map tiles or combine events with tiles. To draw buildings use
events with tiles sprite. Get inspired with the 1st map of the demo.


NOTE: $game_map.mode3D variable updates every frame so declare it true or false
before switching to a map.

=end

$m7_default = true # Default on/off mode 7 (just at the begining of the game)

module Game
DISPLAY_WIDTH = 544
DISPLAY_HEIGHT = 416

DISPLAY_CHIP_WIDTH = DISPLAY_WIDTH / 32
DISPLAY_CHIP_HEIGHT = DISPLAY_HEIGHT / 32

DISPLAY_REAL_WIDTH = DISPLAY_CHIP_WIDTH * 256
DISPLAY_REAL_HEIGHT = DISPLAY_CHIP_HEIGHT * 256

end


class Rect
def set_pos(x, y)
self.x = x
self.y = y
end

def set_size(w, h)
self.width = w
self.height = h
end
end


class TileBitmap < Bitmap
def initialize(width, height, tilemap)
super(width, height)
@tilemap = tilemap
@map_width = width / 32
@map_height = height / 32
@buffer = Bitmap.new(width, height)
@map_x = 999
@map_y = 999
@anime_face = 0
@anime_face_x = 0
@anime_speed = 30
@anime_count = @anime_speed
@main_autotile = MainAutotile.new(self, @tilemap.bitmaps)
@temprect = Rect.new(0,0,32,32)
@range = -1..1
end

def dispose
@buffer.dispose
@main_autotile.dispose
super
end

def set_tile(id, dx, dy)
case id
when 2048...2816
set_auto_tile1(id - 2048, dx, dy)
when 2816...4352
chipid, atid = (id -2816).divmod(48)
@main_autotile.draw(1,
atid, (chipid & 7) << 6 , (chipid >> 3) * 96, dx, dy, chipid)
when 4352...5888
set_auto_tile2(@tilemap.bitmaps[2], id - 4352, dx, dy)
when 5888...8000
set_auto_tile2(@tilemap.bitmaps[3], id - 5888, dx, dy)
when 1536...2048
set_normal_tile(@tilemap.bitmaps[4], id - 1536, dx, dy)
when 1...256
#0は書き込まない
set_normal_tile(@tilemap.bitmaps[5], id, dx, dy)
when 256...512
set_normal_tile(@tilemap.bitmaps[6], id - 256, dx, dy)
when 512...768
set_normal_tile(@tilemap.bitmaps[7], id - 512, dx, dy)
when 768...1536
set_normal_tile(@tilemap.bitmaps[8], id - 768, dx, dy)
end
end

def set_normal_tile(bitmap, id, dx, dy)
if(id < 128)
@temprect.set((id & 7) << 5, id >> 3 << 5, 32, 32)
else
id = id - 128
@temprect.set(((id & 7) + 8) << 5, id >> 3 << 5, 32, 32)
end
blt(dx, dy, bitmap, @temprect)
end

def set_auto_tile1(id, dx, dy)
chip_id, atid = id.divmod(48)

f = @anime_face
fx = @anime_face_x
case chip_id
when 0
@main_autotile.draw(0, atid, fx, 0, dx, dy, f)
when 1
@main_autotile.draw(0, atid, fx, 96, dx, dy, 8 + f)
when 2
@main_autotile.draw(0, atid, 192, 0, dx, dy, 3)
blt(dx, dy, @tilemap.bitmaps[0], Rect.new(192, 0, 32, 32))
when 3
blt(dx, dy, @tilemap.bitmaps[0], Rect.new(192, 96, 32, 32))
when 4
@main_autotile.draw(0, atid, 256 + fx, 0, dx, dy, f + 4)
when 6
@main_autotile.draw(0, atid, 256 + fx, 96, dx, dy, f + 12)
when 8
@main_autotile.draw(0, atid, fx, 192, dx, dy, f + 16)
when 10
@main_autotile.draw(0, atid, fx, 288, dx, dy, f + 20)
when 12
@main_autotile.draw(0, atid, 256 + fx, 192, dx, dy, f + 24)
when 14
@main_autotile.draw(0, atid, 256 + fx, 288, dx, dy, f + 28)
end

end

def anime_tile? (tile_id)
return tile_id && tile_id.between?(2048, 2815)
end

def set_auto_tile2(bitmap, id, dx, dy)
autotile_id = id % 48

real = id / 48
@temprect.set((real & 7) << 5, real >> 3 << 5, 32, 32)
blt(dx, dy, bitmap, @temprect)
end

def set_map(ox, oy)
return update_anime(ox, oy) if @map_x == ox && @map_y == oy

dir_x = ox - @map_x
dir_y = oy - @map_y
update_anime(ox - dir_x, oy - dir_y)
if @range === dir_x && @range === dir_y
case
when dir_x.zero? && dir_y == -1
copy_from_buffer(Rect.new(0, 0, width, height - 32), 0, 32)
draw_map(0, 0, ox, oy,
ox + @map_width, oy + 1)
when dir_x.zero? && dir_y == 1
copy_from_buffer(Rect.new(0, 32, width, height - 32), 0, 0)
draw_map(0, height - 32, ox, oy + @map_height - 1,
ox + @map_width, oy + @map_height)
when dir_y.zero? && dir_x == -1
copy_from_buffer(Rect.new(0, 0, width - 32, height), 32, 0)
draw_map(0, 0, ox, oy,
ox + 1, oy + @map_height)
when dir_y.zero? && dir_x == 1
copy_from_buffer(Rect.new(32, 0, width - 32, height), 0, 0)
draw_map(width - 32, 0, ox + @map_width - 1, oy,
ox + @map_width, oy + @map_height)

end

else
clear
draw_map(0, 0, ox, oy, ox + @map_width, oy + @map_height)
end
@map_x = ox
@map_y = oy
return true
end

def next_anime_face
@anime_face = (@anime_face + 1) % 3
@anime_face_x = @anime_face << 6
end

def update_anime(ox, oy)
if @anime_count.zero?
next_anime_face

x = y = dx = dy = 0
data = $game_map.data
map_each(ox+3, oy, ox + @map_width-3, oy + @map_height) do |x, y, dx, dy|
if anime_tile?(data[x, y, 0])
for z in 0..2
tile_id = data[x, y, z]
set_tile(tile_id, 96 + dx, dy) if tile_id
end
end
end

@anime_count = @anime_speed
return true
else
@anime_count -= 1
return false
end
end

def copy_from_buffer(r, bx, by)
@buffer.clear
@buffer.blt(0, 0, self, self.rect)

clear
blt(bx, by, @buffer, r)
end

def draw_map(tox, toy, ox, oy, xmax, ymax)
data = $game_map.data
x = y = dx = dy = 0
map_each(ox, oy, xmax, ymax) do |x, y, dx, dy|
for z in 0..2
tile_id = data[x, y, z]
set_tile(tile_id, tox + dx, toy + dy) if tile_id
end
end
end

def map_each(sx, sy, ex, ey)
mapw = $game_map.width
maph = $game_map.height
isv = $game_map.loop_vertical?
ish = $game_map.loop_horizontal?
draw_y = 0
for y in sy...ey
y = get_looped_point(y, maph) if isv
draw_x = 0
for x in sx...ex
x = get_looped_point(x, mapw) if ish
yield(x, y, draw_x, draw_y)
draw_x += 32
end
draw_y += 32
end
end

def get_looped_point(val, size)
return case
when size <= val then val -= size
when val < 0 then val += size
else val
end
end
end

class TileSprite < Sprite
def initialize(width, height, tilemap, viewport)
super(viewport)
self.bitmap = Bitmap.new(Game::DISPLAY_WIDTH, Game::DISPLAY_HEIGHT)
self.x = 0
self.y = 0
self.ox = 0
self.oy = 0
self.z = 0
@backbuffer = TileBitmap.new(width, height, tilemap)
@bg = Sprite.new(viewport)
@bg.z = 1
@bg.blend_type = 1
@bg.bitmap = Cache.picture('m7')

@mapx = -999
@mapy = -999

@x_plus = (width - Game::DISPLAY_WIDTH) / 2
@y_plus = 128

@draw_count = false

@x_table = Table.new(416)
@y_table = Table.new(416)
set_render_table(45)
end

def dispose
@bg.dispose if @bg
@backbuffer.dispose if @backbuffer
self.bitmap.dispose if self.bitmap
super
end

def hide
self.visible = false
@bg.visible = false
end

def show
self.visible = true
@bg.visible = true
end


def set_render_table(angle)
return false if angle == @angle
@angle = angle
d = 400.0
rad = angle * Math:tongue.gifI / 180
sina = Math.sin(rad)
cosa = Math.cos(rad)

x_zoom = 272 * 1.5
for i in 0...416

sy = 208 - i

unless angle == 90
aaa = sy == 0 ? 0: (90 - angle) / 208.0 * sy
aaa = sy < 0 ? 90 + aaa : 90 - aaa
rad = aaa * Math:tongue.gifI / 180
sy = (sy / Math.sin(rad)) * (d + (sy * Math.cos(rad))) / d
end


to_y = sina.zero? ? -256: ((sy / sina) * (d + (sy * cosa)) / d).round
@y_table[i] = 208 - to_y

to_x = (-x_zoom * (d + (sy * -cosa)) / d) + x_zoom
@x_table[i] = - (272 * to_x / (272 - to_x )).round
end

case @angle
when 45
@bg.zoom_y = 1.0
when 90
@bg.zoom_y = 0.0
else
@bg.zoom_y = (1.0 / 45) * (90 - @angle)
end
@bg.opacity = 255 * @bg.zoom_y
return true
end



def update_map(ox, oy)
return unless self.visible

aox = ($game_map.display_x >> 3 & 31) + @x_plus
aoy = ($game_map.display_y >> 3 & 31) + @y_plus

ud = set_render_table($game_map.get_angle)
sd = @backbuffer.set_map(ox, oy)
return if !sd && !ud && aox == @mapx && aoy == @mapy
update_bitmap(aox, aoy)
end

def update_bitmap(aox, aoy)
@mapx = aox
@mapy = aoy

unless aox == @x_plus && aoy == @y_plus
@draw_count = !@draw_count
return if @draw_count
end

bmp = self.bitmap
bmp.clear

bmph = bmp.height
bmpw = bmp.width

yt = @y_table
xt = @x_table
bb = @backbuffer
from_r = Rect.new(0, 0, 1 , 1)
to_r = Rect.new(0, 0, bmpw, 1)
i = 0
while i < bmph
to_y = yt[i]
if to_y < -@y_plus
i += 1
next
end

to_x = xt[i]
to_r.y = i

ww = 0
while i < bmph
ww += 1
i += 1
break unless to_x == xt[i] && to_y + ww == yt[i]
end


to_r.height = ww
from_r.set(to_x + aox, to_y + aoy, bmpw - to_x - to_x, ww)
bmp.stretch_blt(to_r, bb, from_r)
end
end


end

class Game_Map
attr_accessor :mode3D
attr_accessor :map_id

alias a9_003_initialize initialize
def initialize
a9_003_initialize
@mode3D = $m7_default
@angle3D = 60
end

def set_angle(v)
@angle3D = v
end

def get_angle
@angle3D
end

end

class Spriteset_Map
alias a9_003_create_viewports create_viewports
def create_viewports
a9_003_create_viewports
@viewport_invisible = Viewport.new(0, 0, 1, 1)
@viewport_invisible.visible = false
end

alias a9_003_dispose_viewports dispose_viewports
def dispose_viewports
a9_003_dispose_viewports

@viewport_invisible.dispose
end
alias a9_003_create_tilemap create_tilemap
def create_tilemap
a9_003_create_tilemap
@tilemap.visible = false
@tile_sprite = TileSprite.new(544+448, 416+128, @tilemap, @viewport1)
end

def begin_3d
@tilemap.viewport = @viewport_invisible
@mode3d = true
@tile_sprite.show
end

def end_3d
@tilemap.viewport = @viewport1
@mode3d = false
@tile_sprite.hide
end

alias a9_003_dispose_tilemap dispose_tilemap
def dispose_tilemap
a9_003_dispose_tilemap
@tile_sprite.dispose
end



alias a9_003update_tilemap update_tilemap
def update_tilemap
g = $game_map
unless g.mode3D == @mode3d
@mode3d ? end_3d: begin_3d
end
unless @mode3d
a9_003update_tilemap
else
@tile_sprite.update_map((g.display_x >> 8) - 7, (g.display_y >> 8) - 4)
end
end
end

class Game_Vehicle < Game_Character

#--------------------------------------------------------------------------
# ● Not sure if it's removable
#--------------------------------------------------------------------------
alias a9_003_update update
def update
a = @altitude
a9_003_update
update_angle(a)
end

def update_angle(alti)
def set_angle
$game_map.set_angle(90 - (45 / 8 * (@altitude / 4 + 1)))
end
end
end
#-------------------------------------------------------------------------

class MainAutotile
def initialize(parent, tilebitmaps)
super()
@parent = parent
@bitmaps = tilebitmaps

@rect = Rect.new(0, 0, 16, 16)
@lt_buffer = {0=>1, 4=>1, 6=>1, 8=>1, 12=>1, 19=>1, 23=>1, 32=>1, 33=>1}
@lt_buf_0 = {0=>1, 4=>1, 6=>1, 8=>1, 12=>1}
@lt_buf_1 = {19=>1, 32=>1}
@lt_buf_2 = {23=>1,33=>1}
@lt_1 = {1=>1, 3=>1, 5=>1, 7=>1, 9=>1, 11=>1, 13=>1,
15=>1, 26=>1, 27=>1, 29=>1, 31=>1, 39=>1}
@lt_2 = {34=>1, 35=>1, 42=>1, 43=>1, 46=>1 }
@lt_3 = {20=>1, 21=>1, 22=>1, 36=>1, 37=>1, 45=>1}#23, 33
@lt_4 = {16=>1, 17=>1, 18=>1, 40=>1, 41=>1, 44=>1}#17..19, 32
@lt_5 = {2=>1, 4=>1, 8=>1, 10=>1, 14=>1, 24=>1,
25=>1, 28=>1, 30=>1, 38=>1}#0, 6, 12

@rt_buffer = {27=>1}
@rt_height = {6=>1, 14=>1, 20=>1, 22=>1, 27=>1, 28=>1, 29=>1}#7

@lb_buffer = {1=>1, 2=>1, 3=>1, 31=>1}
@lb_width = {1=>1, 2=>1, 3=>1, 12=>1, 14=>1, 16=>1, 17=>1, 26=>1, 31=>1}

make_buffer
end

def draw(bmpNo, atid, ox, oy, dx, dy, bufid)
r = @rect
r.set_size(16, 16)
b = @parent
bw = bufid << 5
bmps = rect = nil
return if draw_lt(r, atid, ox, oy, bw) do |bmps, rect|
b.blt(dx, dy, bmps[bmpNo], rect)
end

draw_rt(r, atid, ox, oy, bw) do |bmps, rect|
b.blt(dx + 16, dy, bmps[bmpNo], rect)
end

return if draw_lb(r, atid, ox, oy, bw) do |bmps, rect|
b.blt(dx, dy + 16, bmps[bmpNo], rect)
end

draw_rb(r, atid, ox, oy) do |bmps, rect|
b.blt(dx + 16, dy + 16, bmps[bmpNo], rect)
end
end

def dispose
@buffers.each do |v|
v.dispose
end
end

private

def make_buffer
@buffers = []

bmp1 = Bitmap.new(1024, 96)
@buffers[0] = bmp1
tobmp = @bitmaps[0]
for i in 0..6
draw_buffer(tobmp, i * 64, 0, bmp1, i * 32, 0)
end
for i in 0..6
draw_buffer(tobmp, i * 64, 96, bmp1, 256 + (i * 32), 0)
end
for i in [0, 1, 2, 4, 5, 6]
draw_buffer(tobmp, i * 64, 192, bmp1, 512 + (i * 32), 0)
end
for i in [0, 1, 2, 4, 5, 6]
draw_buffer(tobmp, i * 64, 288, bmp1, 768 + (i * 32), 0)
end

bmp2 = Bitmap.new(1024, 96)
@buffers[1] = bmp2
tobmp = @bitmaps[1]
for i in 0..7
draw_buffer(tobmp, i * 64, 0, bmp2, i * 32, 0)
end
for i in 0..7
draw_buffer(tobmp, i * 64, 96, bmp2, 256 + (i * 32), 0)
end
for i in 0..7
draw_buffer(tobmp, i * 64, 192, bmp2, 512 + (i * 32), 0)
end
for i in 0..7
draw_buffer(tobmp, i * 64, 288, bmp2, 768 + (i * 32), 0)
end
end

def draw_buffer(bmp, ox, oy, tobmp, tox, toy)
r = Rect.new(0, 0, 16, 16)
r.set_pos(ox + 32, oy + 64)
tobmp.blt(tox, toy, bmp, r)
r.set_pos(ox + 16, oy + 64)
tobmp.blt(tox + 16, toy, bmp, r)
r.set_pos(ox + 32, oy + 48)
tobmp.blt(tox, toy + 16, bmp, r)
r.set_pos(ox + 16, oy + 48)
tobmp.blt(tox + 16, toy + 16, bmp, r)

r.set_pos(ox, oy + 64)
tobmp.blt(tox, toy + 32, bmp, r)
r.set_pos(ox + 48, oy + 64)
tobmp.blt(tox + 16, toy + 32, bmp, r)
r.set_pos(ox, oy + 48)
tobmp.blt(tox, toy + 48, bmp, r)
r.set_pos(ox + 48, oy + 48)
tobmp.blt(tox + 16, toy + 48, bmp, r)

r.set_pos(ox + 32, oy + 32)
tobmp.blt(tox, toy + 64, bmp, r)
r.set_pos(ox + 16, oy + 32)
tobmp.blt(tox + 16, toy + 64, bmp, r)
r.set_pos(ox + 32, oy + 80)
tobmp.blt(tox, toy + 80, bmp, r)
r.set_pos(ox + 16, oy + 80)
tobmp.blt(tox + 16, toy + 80, bmp, r)
end

def draw_lt(r, atid, ox, oy, bx)
case
when @lt_buf_0.key?(atid)
r.x = bx
r.y = 0
when @lt_buf_1.key?(atid)
r.x = bx
r.y = 32
when @lt_buf_2.key?(atid)
r.x = bx
r.y = 64
when @lt_1.key?(atid)
r.x = ox + 32
r.y = oy
when @lt_2.key?(atid)
r.x = ox
r.y = oy + 32
when @lt_3.key?(atid)
r.x = ox + 32
r.y = oy + 32
when @lt_4.key?(atid)
r.x = ox
r.y = oy + 64
when @lt_5.key?(atid)
r.x = ox + 32
r.y = oy + 64
end
bool = false
case atid
when 0, 15, 32..34, 36, 38, 40
r.set(r.x, r.y, 32, 32)
bool = true
when 3, 4, 7, 8, 11, 12, 16, 18, 23, 25, 35, 37
r.width = 32
when 6, 9, 13, 19, 20, 28, 41
r.height = 32
end
yield(@lt_buffer.key?(atid) ? @buffers : @bitmaps , r)
return bool
end

def draw_rt(r, atid, ox, oy, bx)
if case atid
when 27
r.set_pos(bx + 16, 32)
when 2, 6, 10, 14, 15, 17, 19, 30, 31, 41 #2, 3, 7, 11
r.set_pos(ox + 48, oy)
when 1, 5, 9, 13, 28, 29, 40 #0, 1, 4, 8, 12, 16, 18
r.set_pos(ox + 16, oy + 64)
when 20..22, 34, 43 #35, 33, 23
r.set_pos(ox + 16, oy + 32)
when 24, 26, 38, 39, 44 #25, 27, 32
r.set_pos(ox + 48, oy + 64)
when 36, 42, 45, 46 #37
r.set_pos(ox + 48, oy + 32)
end then
r.set(r.x, r.y, 16, @rt_height.key?(atid) ? 32: 16)
yield(@rt_buffer.key?(atid) ? @buffers : @bitmaps, r)
end
return false
end

def draw_lb(r, atid, ox, oy, bx)
if case atid
when 1, 2, 3
r.set_pos(bx, 16)
when 31
r.set_pos(bx, 80)
when 8, 10, 11, 12, 14, 15, 22, 23, 25, 27, 37 #9, 13
r.set_pos(ox + 32, oy + 16)
when 4, 5, 7, 21, 24, 26, 36 #0, 1,2,3, 6, 20
r.set_pos(ox + 32, oy + 48)
when 16, 17, 18, 32, 34, 35, 42 #19
r.set_pos(ox, oy + 48)
when 29, 30, 38, 39, 45 #28, 33, 31
r.set_pos(ox + 32, oy + 80)
when 40, 43, 44, 46 #41
r.set_pos(ox, oy + 80)
end then
is_buf = @lb_width.key?(atid)
r.set(r.x, r.y, is_buf ? 32: 16, 16)
yield(@lb_buffer.key?(atid) ? @buffers : @bitmaps, r)
return is_buf || @rt_height.key?(atid)
end
return false
end

def draw_rb(r, atid, ox, oy)
case atid
when 4, 5, 7, 13, 15, 18, 19, 21, 23, 35 #6, 12, 14
r.set_pos(ox + 48, oy + 16)
when 8..11, 16, 34 #0,1,2,3, 17, 20, 22
r.set_pos(ox + 16, oy + 48)
when 24, 25, 27, 32, 36, 37, 42 #26
r.set_pos(ox + 48, oy + 48)
when 30, 40, 41, 43 #28, 29, 31, 33
r.set_pos(ox + 16, oy + 80)
when 38, 39, 44..46
r.set_pos(ox + 48, oy + 80)
else return
end
yield (@bitmaps, r)
end
end

# Global method
def draw_fader(img)
if img != nil
$wall = Sprite.new
$wall.bitmap = Cache.picture(img)
$wall.x = 0
$wall.y = 0
$wall.z = 300
else
$wall.dispose
end
end




</div></div></div>



Bugs

- In horizontal looped maps, sometimes the floor isn't fully drawn. walk a bit to fix it.

Compatibility

- This script changes the spriteset_map and game_map classes and makes other 2 classes. Anyways there were aliased methods on the classes so they're compatible with other scripts. No compatibility errors detected but they could be.

To future users

-This script ONLY affects the floor view. The event are still without depth. So to create maps in Mode 7, you must respect some rules. You can learn those rules by trying and failing or reading the mapping guide, within the script. Anyways, in the demo you have models of all mode 7 possible maps and some minimal rules of mapping, but you must read the guide to map succesfully your rooms in perspective.

EDIT

Well, since the links wherebroken, my apologize for the delay when rescuing this script, and here it is:

http://www.mediafire.com/?xdnwt0mvgnq

PS: Sorry for this ugly presentation. I'm not good at decorating.

NOTE: those links will fall sooner or later, PM me to re-upload them when that happens.

[/quote]
Shu
The 1.5 demo just crashes for me...but the script itself is pretty amazing. This has some potential. =]
SuperMega
I am glad to see that you got to the update, Dusk Noun. I will try this ASAP. Thanks!

EDIT: Demo doesn't seem to run. Also, are those emoticons in the script? That may be causing a few issues.
Dusk noun
QUOTE (SuperMega @ Apr 1 2009, 01:45 AM) *
I am glad to see that you got to the update, Dusk Noun. I will try this ASAP. Thanks!

EDIT: Demo doesn't seem to run. Also, are those emoticons in the script? That may be causing a few issues.


THIS IS TO CALL THE ATTENTION OF EVERY FUTURE USERS OF THIS SCRIPT. THIS DOUBT WON'T BE ANSWERED ANYMORE.

I was creating a reply of the RGSS202E.dll and i forgot to remove it. So the demo crashes because the dll isn't working properly. If you delete it, the RGSS2 Player should load the one from the RTP. Do it so

Actually, the emoticons is something i hate from this forum. They're not in the script but when a script has smile.gif together (for example), the web makes an emoticon. I'll correct it soon, till then, get it from the demo.
SuperMega
Just got done playing the demo, and I must say, I am very pleased with this. Thanks for fixing and taking some of my suggestions! I appreciate it, it turned out great.

EDIT: Just implemented this into a project, and so far so good.
ClazZeal
Heya, I'm new to the forums but I had made a script for mode 7, you have the same errors I did, the tiles are replaced. Exaple blue roofs are green roofs. I myself dont know how to fix it but hopefuly it will be fixed soon, I need it for my MMORPG.
Dusk noun
QUOTE (ClazZeal @ Apr 18 2009, 11:52 PM) *
Heya, I'm new to the forums but I had made a script for mode 7, you have the same errors I did, the tiles are replaced. Exaple blue roofs are green roofs. I myself dont know how to fix it but hopefuly it will be fixed soon, I need it for my MMORPG.


It's interesting that, can you send me thye project to see on my own eyes?
Midnight Assassin
Uhrm... can you please put the script in code tags? There are smileys in the script.
reijubv
Is it compatible with KGC-Tileset Extension?
Or any other script that modifies tileset?
1a42
The demo 1.5 download doesn't work.
I replaced the smilys with the code and now it says that it can't find Graphics/Pictures/m7

Where can I find it? I can't get the demo as stated above.
reijubv
@1a42
as Dusk noun has said, if the demo can't be downloaded, PM him so he can reupload it...
As for m7 graphic, it is in the demo, so you have to download the demo to use this script...
Dusk noun
Hello, i thought this script was seen by anyone when it ended on 3rd page but it wasn't.

OK, i've checked the 1.5 demo and it works properly.
And for the tiles replaced, i need a project to see it and correct it myself, have you used any KGC Tileset script?
The m7 graphic is within the demo, so as the script without emoticons. I'll upload them soon but untill you can take them from there.
reijubv
Yes I used KGC tileset extension script,
I'll make a demo with both your script and KGC's and tell you again tomorrow,
the bug is, autotiles will looks really messed up when moving the actor with mode7 activated...

EDIT:
Sorry, Im really sorry, but the one that doesn't compatible with mode7 IS NOT KGC TILESET EXTENSION SCRIPT!!
It is a 8 direction movement script THAT IS THE ONE WICH IS NOT COMPATIBLE!

I've tried KGC 8 direction movement and another one, and both didn't compatible with mode7,

Again, I'm sorry for this... sad.gif
Dragon-boy
hey i try this script and it looks really cool but when i get on the airship and when i move the doors and people fly with the airship help plz
Garlyle
Pay attention. Only FLOOR layers are displayed in Mode 7. All the rest, such as the airship/etc, display as normal.
Dragon-boy
QUOTE (Garlyle @ May 20 2009, 07:33 PM) *
Pay attention. Only FLOOR layers are displayed in Mode 7. All the rest, such as the airship/etc, display as normal.


oh k but is there a way to fix that
SuperMega
QUOTE (Dragon-boy @ May 21 2009, 04:00 PM) *
QUOTE (Garlyle @ May 20 2009, 07:33 PM) *
Pay attention. Only FLOOR layers are displayed in Mode 7. All the rest, such as the airship/etc, display as normal.


oh k but is there a way to fix that

Mode 7 never makes the sprites and what not in "3D." Mode 7 is only used for the tiles. Its basically just a way of teasing the playing, making them think that the game is really being played in 3D.
JEHINC.
Hello peeps, I have a little problem with this script. When I go to the menu, the white "fader" covers up the top part of the menu right where my main character's HP and MP bars are. Is there any way to fix this. I tried to use the Script Call Event, but that only slows down the game's system and everything gets all jerky and glitchy. Help? huh.gif
JEHINC.
bump

Anyone know how to fix this? It is really getting aggravating! rolleyes.gif
Octople Threat
QUOTE (JEHINC. @ Jun 8 2009, 05:12 PM) *
bump

Anyone know how to fix this? It is really getting aggravating! rolleyes.gif


You're supposed to wait 72 hours before bumping... and I hate to tell you, but I had the exact same problem, and nobody has helped me yet. But who knows, maybe you'll get lucky and find someone to help.
SuperMega
QUOTE (JEHINC. @ Jun 8 2009, 05:56 PM) *
Hello peeps, I have a little problem with this script. When I go to the menu, the white "fader" covers up the top part of the menu right where my main character's HP and MP bars are. Is there any way to fix this. I tried to use the Script Call Event, but that only slows down the game's system and everything gets all jerky and glitchy. Help? huh.gif

Well, I would advise not to use a fader. It tends to cause problems. If you can, try using the script minus the fader.
JEHINC.
But if I don't use the fader, the events that I have set up on the map tend to "float" away or move to the sky. huh.gif The instructions that are in the script said to use the fader to hide the moving events or something like that.

WAIT! I just fixed it! I went into the Picture Folder and renamed "fader" as "sky" Then back to my game's map and deleted the event that called the "fader" and made a parallel event to show the "fader"(sky) as a picture. I did a test play and entered the menu and BOOM! The fader did not Interfere with the menu! Problem solved! thumbsup.gif
Dusk noun
QUOTE
But if I don't use the fader, the events that I have set up on the map tend to "float" away or move to the sky. huh.gif The instructions that are in the script said to use the fader to hide the moving events or something like that.

WAIT! I just fixed it! I went into the Picture Folder and renamed "fader" as "sky" Then back to my game's map and deleted the event that called the "fader" and made a parallel event to show the "fader"(sky) as a picture. I did a test play and entered the menu and BOOM! The fader did not Interfere with the menu! Problem solved! thumbsup.gif


Man, i thought i've been out for so long... Anyways you've solved that problem yourself. It's just a question of a parameter. The image has an x, y and z. The x and y set the position, and the z sets it's priority in the view, just reduce the z variable of the image and your problem will be solved. The default RM images has less z than the windows, that's why it worked, but i'll make a patch to reduce the z of the fader and make it useful with the HUDs menu scripts.

And one thing:

QUOTE
Well, I would advise not to use a fader. It tends to cause problems. If you can, try using the script minus the fader.


Sorry but if you get rid of the fader, the 3-Dness disappears with it. You need to use the script with the fader, anyways i'll try to solve those problems. Is my script after all.
Ravi
how to conic perspective ?
In rpgmaker XP you must delete [X][Y] from name of map..
but in VX i cant do..please help me sad.gif
Locke
Whoa nice demo cause it,s cool with me happy.gif
Dusk noun
QUOTE (Ravi @ Oct 12 2009, 01:24 AM) *
how to conic perspective ?
In rpgmaker XP you must delete [X][Y] from name of map..
but in VX i cant do..please help me sad.gif


I don't understand what's the problem, meybe i need a screenshot. It's been so long i don't remember but supposedly you must have mode 7 on when the game opens.

Ravi
QUOTE (Dusk noun @ Oct 12 2009, 12:59 PM) *
QUOTE (Ravi @ Oct 12 2009, 01:24 AM) *
how to conic perspective ?
In rpgmaker XP you must delete [X][Y] from name of map..
but in VX i cant do..please help me sad.gif


I don't understand what's the problem, meybe i need a screenshot. It's been so long i don't remember but supposedly you must have mode 7 on when the game opens.


Sorry for my bad english..
In mode7 XP script i delete the X and Y

like conic perspective (conic perspective for map and CHARSET)
[Show/Hide] Immage 1

[Show/Hide] Immage 2

[Show/Hide] Immage 3

how to do the conic perspective in your mode7 VX script?
In a TOPIC of old version of your script you post it:
[Show/Hide] Always Conic perspective Code
class TileSprite < Sprite
def initialize(width, height, tilemap, viewport)
super(viewport)
self.bitmap = Bitmap.new(Game::DISPLAY_WIDTH, Game::DISPLAY_HEIGHT)
self.x = 0
self.y = 0
self.ox = 0
self.oy = 0
self.z = 0
@backbuffer = TileBitmap.new(width, height, tilemap)
@bg = Sprite.new(viewport)
@bg.z = 1
@bg.blend_type = 1
@bg.bitmap = Cache.picture('bg')

@mapx = -999
@mapy = -999

@x_plus = (width - Game::DISPLAY_WIDTH) / 2
@y_plus = 128 #(height - Game::DISPLAY_HEIGHT) / 2

@draw_count = false

@x_table = Table.new(416)
@y_table = Table.new(416)
set_render_table(45)
end

def dispose
@bg.dispose if @bg
@backbuffer.dispose if @backbuffer
self.bitmap.dispose if self.bitmap
super
end

def hide
self.visible = false
@bg.visible = false
end

def show
self.visible = true
@bg.visible = true
end


def set_render_table(angle)
return false if angle == @angle
@angle = angle
d = 400.0
rad = angle * Math:tongue.gifI / 180
sina = Math.sin(rad)
cosa = Math.cos(rad)

x_zoom = 272 * 1.5
for i in 0...416

sy = 208 - i

unless angle == 90
aaa = sy == 0 ? 0: (90 - angle) / 208.0 * sy
aaa = sy < 0 ? 90 + aaa : 90 - aaa
rad = aaa * Math:tongue.gifI / 180
sy = (sy / Math.sin(rad)) * (d + (sy * Math.cos(rad))) / d
end


to_y = sina.zero? ? -256: ((sy / sina) * (d + (sy * cosa)) / d).round
#to_y = sina.zero? ? -256: ((sy / sina) * (d + (sy * cosa)) / d).round
@y_table[i] = 208 - to_y

#y=1のときのx
to_x = (-x_zoom * (d + (sy * -cosa)) / d) + x_zoom
@x_table[i] = - (272 * to_x / (272 - to_x )).round
end

#一応bgのサイズもかえとく
#90が0で45が100
case @angle
when 45
@bg.zoom_y = 1.0
when 90
@bg.zoom_y = 0.0
else
@bg.zoom_y = (1.0 / 45) * (90 - @angle)
end
@bg.opacity = 255 * @bg.zoom_y
return true
end



#マップ上の座標で設定
def update_map(ox, oy)
return unless self.visible

aox = ($game_map.display_x >> 3 & 31) + @x_plus
aoy = ($game_map.display_y >> 3 & 31) + @y_plus

ud = set_render_table($game_map.get_angle)
sd = @backbuffer.set_map(ox, oy)
return if !sd && !ud && aox == @mapx && aoy == @mapy
update_bitmap(aox, aoy)
end

def update_bitmap(aox, aoy)
@mapx = aox
@mapy = aoy

unless aox == @x_plus && aoy == @y_plus
@draw_count = !@draw_count
return if @draw_count
end

bmp = self.bitmap
bmp.clear

bmph = bmp.height
bmpw = bmp.width

yt = @y_table
xt = @x_table
bb = @backbuffer
from_r = Rect.new(0, 0, 1 , 1)
to_r = Rect.new(0, 0, bmpw, 1)
i = 0
while i < bmph
to_y = yt[i]
if to_y < -@y_plus
i += 1
next
end

to_x = xt[i]
to_r.y = i

ww = 0
while i < bmph
ww += 1
i += 1
break unless to_x == xt[i] && to_y + ww == yt[i]
end


to_r.height = ww
from_r.set(to_x + aox, to_y + aoy, bmpw - to_x - to_x, ww)
bmp.stretch_blt(to_r, bb, from_r)
end
end


end

class Game_Map
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :mode3D

#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias a9_003_initialize initialize
def initialize
a9_003_initialize
@mode3D = true
@angle3D = 45
end

#--------------------------------------------------------------------------
def set_angle(v)
@angle3D = v
end

#--------------------------------------------------------------------------
def get_angle
@angle3D
end

end

class Spriteset_Map

#--------------------------------------------------------------------------
# ● ビューポートの作成
#--------------------------------------------------------------------------
alias a9_003_create_viewports create_viewports
def create_viewports
a9_003_create_viewports
@viewport_invisible = Viewport.new(0, 0, 1, 1)
@viewport_invisible.visible = false
end

#--------------------------------------------------------------------------
# ● ビューポートの解放
#--------------------------------------------------------------------------
alias a9_003_dispose_viewports dispose_viewports
def dispose_viewports
a9_003_dispose_viewports

@viewport_invisible.dispose
end
#--------------------------------------------------------------------------
# ● タイルマップの作成
#--------------------------------------------------------------------------
alias a9_003_create_tilemap create_tilemap
def create_tilemap
a9_003_create_tilemap
@tilemap.visible = false
@tile_sprite = TileSprite.new(544+448, 416+128, @tilemap, @viewport1)
end_3d
end

#--------------------------------------------------------------------------
def begin_3d
@tilemap.viewport = @viewport_invisible
@mode3d = true
@tile_sprite.show
end

#--------------------------------------------------------------------------
def end_3d
@tilemap.viewport = @viewport1
@mode3d = false
@tile_sprite.hide
end


#--------------------------------------------------------------------------
# ● タイルマップの解放
#--------------------------------------------------------------------------
alias a9_003_dispose_tilemap dispose_tilemap
def dispose_tilemap
a9_003_dispose_tilemap
@tile_sprite.dispose
end


#--------------------------------------------------------------------------
# ● タイルマップの更新
#--------------------------------------------------------------------------
alias a9_003update_tilemap update_tilemap
def update_tilemap
g = $game_map
unless g.mode3D == @mode3d
@mode3d ? end_3d: begin_3d
end
unless @mode3d
a9_003update_tilemap
else
@tile_sprite.update_map((g.display_x >> 8) - 7, (g.display_y >> 8) - 4)
end
end
end

#==============================================================================
# ■ Game_Vehicle
#------------------------------------------------------------------------------
#  乗り物を扱うクラスです。このクラスは Game_Map クラスの内部で使用されます。
# 現在のマップに乗り物がないときは、マップ座標 (-1,-1) に設定されます。
#==============================================================================

class Game_Vehicle < Game_Character

#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias a9_003_update update
def update
a = @altitude
a9_003_update
update_angle(a)
end

def update_angle(alti)
def set_angle
$game_map.set_angle(90 - (45 / 8 * (@altitude / 4 + 1)))
end




end
end

But he dont work..and in your new 1.5 script this is not applicable..
How to do it?
Ravi
I think your script work only map and not work on the charset and event...
True?
Locke
Hey why it,s lags a little?
Dusk noun
QUOTE (Locke @ Oct 17 2009, 07:31 PM) *
Hey why it,s lags a little?


Well, it depends also on the CPU, maybe you've got too loaded the pc. But i know this script sometimes causes some lag. Ruby isn't a compiled language so it's very slow, maybe reduce some statements could help, i'll see if i can but nowadays i'm pretty busy so it's gonna take it's time.

QUOTE
I think your script work only map and not work on the charset and event...
True?


About your english. Sorry but i don't understand italian so i can't speak to you that way. But i've seen you have the idea that this script is like the XP one. It's very different, it doesn't have even the half of the features but it's very tough to make it on VX, this is just a map on perspective leaving actor and events normally and a fader, so, an optic illusion appears, Mode 7. The floor is the map, to make objects over the floor (including houses or walls) use events. You son't need to put anything on mapname, and even if you do it, it won't change anything.
Skeith Avatar
Srry if this has been posted, but how do i change the position of the maps?
mxland
this scripts is so good
martyjr2008
QUOTE (Dragon-boy @ May 16 2009, 05:46 PM) *
hey i try this script and it looks really cool but when i get on the airship and when i move the doors and people fly with the airship help plz


hey where is your game I like to test your game. I like to be your tester. I can find the problems in games and I am good at finding them. Just leave me a message. Or a link to find the beta game.
Xearoth93x
in line 413, do you replace Math:tongue.gifI / 180 with Math:XPI / 180 because I keep getting this error:
Script 'Mode7' line 413: SyntaxError occurred.
Night5h4d3
No, you replace it with
CODE
:P
TLUniverse
The demo helped and I was able to get the thing working. But I was wondering - how can I make it so that the event sprites are not moving towards me as I walk? The charsets flow to the sides as they should, but events seem to do the opposite.
KisarethStudios
QUOTE (TLUniverse @ Nov 12 2010, 06:29 AM) *
The demo helped and I was able to get the thing working. But I was wondering - how can I make it so that the event sprites are not moving towards me as I walk? The charsets flow to the sides as they should, but events seem to do the opposite.


The 'event bug' as I call it is still very present in Mode 7 for VX, though I figured out ways around it. There are three things you can do when it comes to events while Mode 7 is on. The first is that you can create the specific event, and place it on the map but keep it invisible..meaning no sprite attached to it. Ergo no one will see the event moving, and it'll work as it is supposed to. The second thing you can do is if you want to use an "event-only" sprite (say a vehicle) you can take out that specific sprite that you need, and place it somewhere within Tiles B - E. Now you can 'map' the sprite you want, and it'll stay in a fixed position (though it won't be animated). Attach an invisible event to that sprite, and you should be good to go.

The third method is tricky. You can put the event in question on the map, put no sprite associated with it (make it invisible), and when the player reaches a certain point on the map (you would have to continually test this) where the event in question is where you want it to be, then trigger a switch where the event's sprite is seen. It's not hard to event out, though you'd have to continuously playtest to see just where the event is corresponding to where the player is walking, and so on. I hope this has helped some. smile.gif
CRAZYASIANHOBO
it works... HO SHIT IT WORKS! 8O
oh man oh man, thanks for this so much! ive been searching for a working mode 7 file ALL DAY, and i finally found one! 8'D *crying happily*
Kread-EX
Please don't post in old script topics unless you have a question or a bug report.
Mishimo
I know this post is already old but I was hoping I could get some help with an error I'm getting every time I try to activate mode7.
I'm getting this error:
Script 'Mode 7' line 413: NoMethodError occurred.
undefines methos '*' for nil:NilClass

Dunno if it's a compatibility issue or something else. If anyone knows how to fix this please answer, help is appreciated!
ave369
Is there a way for this script to display mountains and trees upright, not flat? I tried to do this with event sprites, but it resulted in a hell of a lot of events and very slow loading.
Kread-EX
No you can't. Neo Mode 7 for XP could do it and MGC made a tool to import those maps in VX.
http://www.rpgrevolution.com/forums/index....showtopic=46275
This is your best chance, I'm afraid.
ave369
I think I found a workaround, but it requires some bug fixing. In a nutshell, it involves using this script in conjunction with the Anti-Lag script which ceases processing of events far enough from the player, and making the trees, mountains, towns, towers etc event sprites. But I found the funniest bug ever: events that are not processed due to being far from player start moving with the player around him, like a box, when in Mode7. If this bug is fixed, it'll be possible to create some cool-looking Mode7 maps for VX.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.