MyTetra Share
Делитесь знаниями!
О, смотри-ка какое хорошее место. Дайте два!
Zelda scrolling
07.12.2016
13:12
Автор: DeadElf79
Текстовые метки: mapping, manual
Раздел: Ruby - RGSS3

# de79 zelda scrolling

# version 1.3


module De79Zelda

REGEXP_MAP_NOTE = /zelda/i

SCROLL_SPEED = 6

WAIT_FOR_SCROLL = true

def self.wait_processing

@wait_processing |= false

end

def self.wait_processing=(value)

@wait_processing = value

end

end


class Game_Map

alias de79setup setup

def setup(map_id)

de79setup(map_id)

@zelda = is_zelda?

end

def is_zelda?

@map.note.each_line("\n") { |line|

return true unless (line =~ De79Zelda::REGEXP_MAP_NOTE).nil?

}

false

end

def zelda_map?

@zelda

end

def modw(x)

return (x.to_f / ($game_map.screen_tile_x)).to_i

end

def modh(y)

return (y.to_f / ($game_map.screen_tile_y)).to_i

end

end

class Game_Player

def update

last_real_x = @real_x

last_real_y = @real_y

last_moving = moving?

if De79Zelda.wait_processing

unless $game_map.scrolling?

De79Zelda.wait_processing = false

end

else

move_by_input

end

super

if $game_map.zelda_map?

update_zelda_scroll(last_real_x,last_real_y)

else

update_scroll( last_real_x, last_real_y )

end

update_vehicle

update_nonmoving( last_moving ) unless moving?

@followers.update

end

def center(x, y)

if $game_map.zelda_map?

new_x = modw(x)*$game_map.screen_tile_x

new_y = modh(y)*$game_map.screen_tile_y

$game_map.set_display_pos( new_x, new_y )

else

$game_map.set_display_pos(x - center_x, y - center_y)

end

end

def update_zelda_scroll( last_x, last_y )

ax1 = modw( last_x )

ay1 = modh( last_y )

ax2 = modw( @real_x )

ay2 = modh( @real_y )

direction = 0

direction = 2 if ay2 > ay1

direction = 4 if ax2 < ax1

direction = 6 if ax2 > ax1

direction = 8 if ay2 < ay1

distance = case direction

when 2,8

$game_map.screen_tile_y

when 4,6

$game_map.screen_tile_x

else

0

end

if direction > 0

$game_map.start_scroll( direction, distance, De79Zelda::SCROLL_SPEED )

De79Zelda.wait_processing = true if De79Zelda::WAIT_FOR_SCROLL

end

end

def modw(x)

return (x.to_f / ($game_map.screen_tile_x)).to_i

end

def modh(y)

return (y.to_f / ($game_map.screen_tile_y)).to_i

end

end

← Содержание ...
 
MyTetra Share v.0.35
Яндекс индекс цитирования