Login
Back to forumSee the full topicGo to last reply

Posted By

Chicken
on 2013-01-07
15:10:50
 Re: Speed up Routine for Placing A Bitmap

If you really need the crosshairs to be moved (in pixel steps) there's no way around a proper sprite routine. However, if you can live with the fact that the crosshairs "jump" from position to position, then I would suggest this:

For every position (6x6 chars) you need 4 different bitmap parts.

1: just background
2: background + crosshairs
3: background + enemy
4: background + enemy + crosshairs

(Maybe even a fifth one: background + dying enenmy + crosshairs)

Obviously, this is very memory consuming. (Maybe you don't even need 6x6 areas but can do with smaller areas?) Furthermore, it's always the same enemy for each position. But it would keep the code very simple happy

Example:

crosshairs in center position, no enemies:
1 1 1
1 2 1
1 1 1

crosshairs in center position, enemy appears in upper left corner:
3 1 1
1 2 1
1 1 1

crosshairs move to upper left corner, aimed at enemy:
4 1 1
1 1 1
1 1 1

crosshairs in upper left corner, enemy appears in the right lower corner:
2 1 1
1 1 1
1 1 3

Just keep track of which positions changed and only update the areas that did. So depending on the action (number of enemies), it's just a few updates each loop.

A more elegant approach would be routines that place crosshairs and enemies at any given position (P1-P9) and restore the background underneath if moved/status changed. This would be far more flexible because different enemies could be placed anywhere (and less memory consuming). Even if this involves masking it would be simple (due to the fixed positions) in comparision to a real sprite routine which can handle "soft" movement.



Back to top


Copyright © Plus/4 World Team, 2001-2024