Serafim |
Администратор |
|
|
Зарегистрирован: 08.03.2012 |
Сообщения: 238 |
Откуда: ЛНР |
|
|
|
|
|
|
Поддерживает стабильность игру, даже на многих событиях
Код: |
#==============================================================================
# hellMinor's "Just Anti-Lag"
# Version : beta v0.6
# Created by : hellMinor
# Do NOT redistribute without my permission
#==============================================================================
# To update an event always, call it - "update" - and it will be
# updated permanently. (event name)
#==============================================================================
ADJUST = 10 # How many tiles should be updated around the screen?
FRAMESKIP = 2 # How many frames should be skipped before drawing new sprites?
ALLOW_SCROLL_UPDATE_SWITCH_ID = 20 # The scroll will be updated always.
#==============================================================================
class Game_Map
#==============================================================================
def update_events
obere_schranke = @display_y/256 - $game_system.adjust
untere_schranke = @display_y/256 + 13 + $game_system.adjust
linke_schranke = @display_x/256 - $game_system.adjust
rechte_schranke = @display_x/256 + 17 + $game_system.adjust
for event in @events.values
event_x = event.x
event_y = event.y
if event.name == "update"
event.update
next
end
event.update if event_x >= linke_schranke and event_x <= rechte_schranke and event_y >= obere_schranke and event_y <= untere_schranke
end
for common_event in @common_events.values
common_event.update
end
end
end
#==============================================================================
class Spriteset_Map
#==============================================================================
alias create_viewports_just_antilag create_viewports
alias update_old_update update unless $@
def create_viewports
@skip = 0
create_viewports_just_antilag
end
def update
if @skip <= 0
@skip = FRAMESKIP
update_old_update
else
if $game_switches[ALLOW_SCROLL_UPDATE_SWITCH_ID]
update_tilemap
end
screen_x = $game_map.display_x/256
screen_y = $game_map.display_y/256
for sprite in @character_sprites
sprite_x = sprite.character.x
sprite_y = sprite.character.y
if sprite_x > (screen_x - $game_system.adjust) and sprite_x < (screen_x + 17 + $game_system.adjust) and sprite_y > (screen_y - $game_system.adjust) and sprite_y < (screen_y + 13 + $game_system.adjust) && sprite.animation?
sprite.update
end
end
end
@skip -= 1
end
def update_characters
screen_x = $game_map.display_x/256
screen_y = $game_map.display_y/256
for sprite in @character_sprites
sprite_x = sprite.character.x
sprite_y = sprite.character.y
if sprite_x > (screen_x - $game_system.adjust) and sprite_x < (screen_x + 17 + $game_system.adjust) and sprite_y > (screen_y - $game_system.adjust) and sprite_y < (screen_y + 13 + $game_system.adjust)
sprite.update
end
end
for ally in @allies_sprites.compact
if ally.character.destroy and !ally.disposed?
ally.dispose
$game_allies.delete(ally.character)
@allies_sprites.delete(ally)
elsif !ally.disposed?
ally.update if $game_map.in_range?(ally.character)
end
end
for monster in @monsters_sprites.compact
if monster.character.destroy and !monster.character.respawn and !monster.disposed?
monster.dispose
$game_monsters.delete(monster.character)
@monsters_sprites.delete(monster)
elsif !monster.disposed?
monster.update if $game_map.in_range?(monster.character)
end
end
for range in @range_sprites.compact
if range.character.destroy and !range.disposed?
range.dispose
$game_range.delete(range.character)
@range_sprites.delete(range)
elsif !range.disposed?
range.update if $game_map.in_range?(range.character)
end
end
for drop in @drop_sprites.compact
if drop.character.destroy and !drop.disposed?
drop.update
drop.character.character_name = ""
unless drop.animation?
drop.dispose
$game_drop.delete(drop.character)
$game_bomb.delete(drop.character)
@drop_sprites.delete(drop)
end
elsif !drop.disposed?
drop.update if $game_map.in_range?(drop.character)
end
end
for ally in $game_allies.compact
next if ally.draw
@allies_sprites.push(Sprite_Character.new(@viewport1, ally))
@weapon_sprites.push(Sprite_Weapon.new(@viewport1, ally))
@shield_sprites.push(Sprite_Shield.new(@viewport1 ,ally))
ally.draw = true
end
for range in $game_range.compact
next unless $game_map.in_range?(range)
next if range.draw
@range_sprites.push(Sprite_Character.new(@viewport1, range))
range.draw = true
end
for drop in $game_drop.compact
next unless $game_map.in_range?(drop)
next if drop.draw
@drop_sprites.push(Sprite_Drop.new(@viewport1, drop))
drop.draw = true
end
for bomb in $game_bomb.compact
next unless $game_map.in_range?(bomb)
next if bomb.draw
@drop_sprites.push(Sprite_Drop.new(@viewport1, bomb))
bomb.draw = true
end
for weapon in @weapon_sprites.compact
next unless $game_map.in_range?(weapon.character)
weapon.update
end
for shield in @shield_sprites.compact
next unless $game_map.in_range?(shield.character)
shield.update
end
for shadow in @shadow_floor.compact
next unless $game_map.in_range?(shadow.character)
shadow.update
end
end
end
#==============================================================================
class Game_Event < Game_Character
attr_reader :name
alias initialize_just_antilag initialize
def initialize(map_id, event)
initialize_just_antilag(map_id, event)
@name = @event.name
end
end
#============================================
class Game_System
attr_accessor :adjust
alias initialize_adjust initialize unless $@
def initialize
initialize_adjust
@adjust = ADJUST
end
end |
|
|