update
method which each enemy has one, but since those enemies shared the same attribute, I think there's another thing that may degrade the performance of the game itself.
def initialize
# #create all your dynamic sprites normally, so Chingu manages them for you.
# Create your tiles using #new (NOT #create) and put them into @tiles
# If Chingu creates them for you, then take them out of @game_objects and put them into
# @tiles manually, so they won't be individually drawn.
end
def draw
# Draw the static tilemap all at once and ONLY once.
@recorded_tilemap ||= $window.record 1, 1 do
@tiles.each &:draw
end
@recorded_tilemap.draw 0, 0, 0
# Get Chingu to draw all your dynamic sprites normally.
super
end
load_game_objects
method will #create
everything listed in the file instead of #new
.#initialize
or #setup
(whichever you use load_game_objects in), you need to pull the tiles out before you do anything else:
# do your #load_game_objects normally
# Then pull the tiles out of the game objects list (drawn individually
# every frame => SLOW) and put them into the @tiles list (which
# will be recorded so they can be drawn as one later => FAST).
@tiles = @game_objects.grep Tile
@game_objects -= @tiles
#update
will not bother to update the Tiles (which are static) nor will #draw draw them individually.Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill