- Joined
- Sep 12, 2013
- Messages
- 14
- Reaction score
- 3
- First Language
- English
- Primarily Uses
I've not been using Ruby long enough to know good ways to optimise it yet, but personally I'd not want to have to install any dll to use a script - the way data is stored might be slowing it down slightly, but I've not played with things enough to find out yet... Maybe get a rectangle swap event on a 500x500 map and time it, then find out what can be done to speed things up ;-)
I like the idea of a custom class for one reason - you could have different maps for both the source and dest. The downside is that object creation is just as bad in Ruby as Java - so having nested arrays would be significantly faster in some places... I'm reading up on things right now, but already finding some things that might speed it up slightly (I'll have a fiddle with things overnight
)
Passing in an array with arbitrary points actually makes sense for strange shapes - it's the extra processing that it would entail that would slow things. How about having a Shape class, with effective aliases for Rectangle and Triangle - but the methods can have a shorthand for passing an array, and something quick (point, line or rectangle) would bypass shape creation entirely - so...
pos_swap_from(Point.new(10,10), Rectangle.new(20,10,5,5))...would be semantically almost identical to...
pos_swap_from([10,10], [20,10,5,5])...but use code shortcuts in the second on to save the overhead of object creation... Thinking about it, can even have a single method that just checks for arg type and then the tile id can be numerical, shorthand, positional, or shaped.
Having shapes would be good for things such as replacing the look of a building with another that takes the same space, but you don't want to use regions...
Speaking of regions - might be nice if there was a setting/flag that let you also copy the region data from the dest (if using shapes), and possibly even a mask that let you copy a shape but skip any tiles matching xyz (linked to copying regions etc).
Edit: Have one major speed boost for Game_Map at least - reduces the update to once per frame, so having a lot of updates is almost instant - next need to streamline the replacement code a little...
I like the idea of a custom class for one reason - you could have different maps for both the source and dest. The downside is that object creation is just as bad in Ruby as Java - so having nested arrays would be significantly faster in some places... I'm reading up on things right now, but already finding some things that might speed it up slightly (I'll have a fiddle with things overnight
Passing in an array with arbitrary points actually makes sense for strange shapes - it's the extra processing that it would entail that would slow things. How about having a Shape class, with effective aliases for Rectangle and Triangle - but the methods can have a shorthand for passing an array, and something quick (point, line or rectangle) would bypass shape creation entirely - so...
pos_swap_from(Point.new(10,10), Rectangle.new(20,10,5,5))...would be semantically almost identical to...
pos_swap_from([10,10], [20,10,5,5])...but use code shortcuts in the second on to save the overhead of object creation... Thinking about it, can even have a single method that just checks for arg type and then the tile id can be numerical, shorthand, positional, or shaped.
Having shapes would be good for things such as replacing the look of a building with another that takes the same space, but you don't want to use regions...
Speaking of regions - might be nice if there was a setting/flag that let you also copy the region data from the dest (if using shapes), and possibly even a mask that let you copy a shape but skip any tiles matching xyz (linked to copying regions etc).
Edit: Have one major speed boost for Game_Map at least - reduces the update to once per frame, so having a lot of updates is almost instant - next need to streamline the replacement code a little...
Code:
#----------------------------------------------------------------------------- # New. Load custom map data on top of our map #----------------------------------------------------------------------------- def load_new_map_data @need_load_new_map_data = true end #----------------------------------------------------------------------------- # Aliased. Refresh the map if we've got pending changes #----------------------------------------------------------------------------- alias :tsuki_tile_swap_update_map :update def update(main = false) if @need_load_new_map_data @need_load_new_map_data = false @updated_tiles = {} swap_tile_id swap_tile_region swap_tile_pos expand_updated_tiles update_all_autotiles end tsuki_tile_swap_update_map(main) end
Last edited by a moderator:




