View Single Post
30 November 2015, 23:27   #102
Codetapper
2 contact me: email only!

Join Date: May 2001
Location: Auckland / New Zealand
Posts: 3,139
Quote:
 Originally Posted by Mrs Beanbag It is exactly a third less in terms of total blitted area. I think you are overestimating the complexity of the process, there are no "extra checks on every object", all there is is a function that can redraw the map in a rectangular area. There is obviously some extra CPU overhead involved, but it's hardly reams of code.
You're simplifying things here. How many games use 16x16 bobs? And how many restrict the enemies to 2 or 4 pixel horizontal movement?

Since you've been talking about Chuck Rock, most of those are 32, 48 or even 64 pixels wide. There's a few 16 pixel wide bobs, but most are larger. The enemies such as the bird follow a smooth sine wave when lifting Chuck up over the gap. The large dinosaur you move on also moves around smoothly. The coconuts that get thrown from the tree take up the full 16x16 pixels and can move to any pixel (sine waves again, plus bouncing). There's many more examples through the game.

Maybe Mr Beanbag is an overly simplified game engine compared to Chuck Rock and you're thinking about that specific case of horizontal/vertical only movement in only 2 or 4 pixel chunks but not considering a more general game? One game I'm working on has the main character moving 3 pixels per frame for example.

Quote:
 But these calculations are trivial. For a 16-pixel wide bob, knowing when not to blit one extra word wide is just a case of checking if the bit shift is zero. For other widths it's just a comparison against (16 minus (pixel width & \$f)).
And my point is if you have 50 objects to check, that's 50 series of calculations you're doing to work out if the bob can save one extra word (after retrieving exact pixel dimensions, so that's even more CPU usage) and if only 1/16 bobs happen to be on that boundary, you're saving 1 word of blitting x the height of 3 bobs for the cost of all those calculations. And if the blits are small (only a few pixels high) the blitter will be finished and wasting time waiting for all your extra calculations to take place.

Maybe in your simple restricted-to-up-down-left-right game it's worth it, I don't know. For a general game it sounds like the 6.25% of the time on average the bob would be exactly on a word boundary isn't worth the complexity added with the code.

Page generated in 0.03948 seconds with 10 queries