123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|645|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Shadows Loop Performance

Sat, 13 Aug 2022, 20:27
therevillsgames

Shadows Loop Performance


Hey All,

I'm STILL working on my "little" jigsaw game, taken way too long :o Nearly finished but having some performance issues.

When I cut up an image (1920x1280) into the 1008 jigsaw pieces, I have the drawing logic of:

1. Loop thru all the tiles
1a. Draw the tile
2. Loop thru all the tiles
2a. If the tile shadow is on
2b. Draw the shadow (as it is now "flying")
2c. Draw the tile (draw the tile again so it is above the other tiles)

Is there a better way? I want it so that the shadow is drawn on top of the other tiles when moving them about.



Would saving the images to a texture atlas help?

Cheers,
Steve
Sat, 13 Aug 2022, 22:41
HoboBen
Do you have the full source code (even if you don;t want to post it publicly, you can DM me privately)

An extremely long time ago (12 years ago!) I did a Jigsaw game that had a major failing, that jigsaw pieces appeared behind other pieces, that I could have fixed in ~10 lines of code, but never got round to

I'm very happy to help, but would need a full program. I don't mind at all if this involves signing a non-disclosure or whatever

-=-=-
blog | work | code | more code
Sun, 14 Aug 2022, 01:53
Jayenkai
Is the bottleneck the drawing, or the fact that you're looping through everything twice?
(As in, if you strip out the drawing commands but leave everything else intact, is it still just as slow?)

-=-=-
''Load, Next List!''
Sun, 14 Aug 2022, 15:57
therevillsgames
Hmm, the more I looked at this yesterday the more I thought it wasn't the rendering, although the render time does increase by 3x. I'm now investigating my recursive functions...
Sun, 14 Aug 2022, 17:33
Jayenkai
It's honestly been a long time since I properly used a Blitz, so I don't know for sure, but you're doing an awful lot of SetAlpha'ing..
Might it be a good idea to..
Loop 1, draw tiles on the table.
Setalpha 0.5
Loop 2. Draw shadows for lifted tiles.
SetAlpha 1
Loop 3. Draw lifted tiles.

Honestly can't remember if that'd be better or not. (And this is one of those things that RemoteDesktop based Blitz would probably lie about!!)

-=-=-
''Load, Next List!''
Wed, 17 Aug 2022, 04:10
therevillsgames
Thanks Jay, that might give an extra frame or two... I run my monitor at 120hz, so most of the games in Windows mode run at 120 FPS, when I select all the tiles, and move them, shadowOn becomes 1, showing the shadows....

But I now think the issue is within my logic code and not the rendering... but I am getting inconsistent results which is confusing me.


View on YouTube
Wed, 17 Aug 2022, 04:38
Jayenkai
Curious.. The highlighting's causing slowdown, too. Be sure to disable the highlight when lifted, since the shadow's doing the same job.

What's "Draw Outline" doing, btw?
Is it a vector thing, or are you just reusing the image and redrawing that?

-=-=-
''Load, Next List!''
Thu, 18 Aug 2022, 04:35
therevillsgames
Draw Outline - "Just" draws another image (previously generated).

When I multi select, I am doing it a pretty lazy way:




So as I am selecting I'm clearing the list, and adding all the pieces again and again...
Thu, 18 Aug 2022, 04:56
Jayenkai
Right, hang on...

Your main "Draw all the pieces" loop goes through ALL the pieces twice.. Once to draw the ones on the floor, then the ones lifted..
But you also have a second list of all the selected tiles?

Should you not..

1. Go through ALL tiles, but only drawing those not selected.
2. Go through the SELECTED list, drawing them with highlight/shadow.

That saves you going through the complete list twice.

In fact, if you could make another list of Not Selected, you could reduce that first one a little further..

(Disclaimer : I can't remember how lists worked in BB!!)

-=-=-
''Load, Next List!''