2nd Retry, really sorry: Since everyone else is asking, optimization advice needed! :-) ignore other message sorry

My finger slipped :slight_smile:

After spending a greuling weekend of coding on my Raider’s Saga RPG
project I’ve come to the point where I actually need to optimize
something (because for the most part it actually works :wink: ). But I’m
wondering if the strategy I’ve choosen is the best one for my app.
The app that needs the optimization is my map editor (which a
screenshot is available at members.xoom.com/kokido/screenshots.html),
the code will be available as soon as I finish the optimizations (and
remove some non critical bugs). Basically the inner loop is doing the
following (psuedocode) :

do {
get_keys_and_update_mouse_position_and_buttons();
do_stuff_with_key_presses();
see_if_gui_buttons_were clicked();
if(current_tile_was_changed) {
redraw_tiles();
}
redraw_special_tiles();
redraw_grid();
draw_mouse_cursor();
update_the_whole_screen();
} while it’s_still_running;

redraw_tiles() {
redraws tiles in a 9x9 grid accounting for offset, and draws
current tile only redraw when neccessary because there is no animation
in regular floor tiles.4
}

redraw_special_tiles() {
sames as redraw_tiles, but redraws everyframe due to animation
}

redraw_grid() {
redraws the 8x8 grid, accounting for offsets into the 30x30 world
and redraws everyframe to account for animation
}

my blit function is basically a wrapper for the sdl ones, but is
horribly inefficient. My world is stored in two arrays, one for the
floor tiles, and one for the special tiles, because a special tile may
also be in the same location as a floor tile.

My optimization strategy is to use a list of rectangles and make a
single call to sdl_update_rects, and to double buffer the whole thing
so I can blit as much of the existing screen as possible. I’ll also
keep track of the tiles that change. I don’t use threads, and the
program is locked to 16 frames a second with the wait_frame function
from the sdl_demos. Does my optimization plan seem sound or does
anyone have a better suggestion?

Phoenix Kokido
members.xoom.com/kokido
@Wes_Poole