Filling

Published July 07, 2006
Advertisement


I chucked some simple filling in to the engine as a test. It scans along the top and bottom edges of the shape, then fills columns. This is rather inefficient (filling scanlines is much faster - the screen is shorter than it is wide, so tracing Ys for the boundaries is faster than scanning Xs, and when filling by scanline you can write 8 pixels - a byte - in a single shot) but it served the purpose of a quick demo. It's rather broken, and doesn't match the lines correctly (so there are slight gaps and overflows). It's only temporary.

I'd like to extend the filling to support different dithered fills - white, 25%, 50%, 75% and black walls would look nice.

There is no sorting as yet, I just arranged the walls in back-to-front order in the level file.

@philipptr: I don't know if you ever completed your triangle filling, but the way I've done it in the past is to split the triangle into two halves (y0->y1 and y1->y2, where y012). I would then trace down the sides of the triangle, calcuating the X bounds for the top and bottom halves (Bresenham), then filling in the horizontal lines using these values. Only uses integer arithmetic, so nice and fast.

Whether this will be turned into a game or not depends on whether I can get it to scale sensibly with decent-sized levels; especially with the addition of scaled sprites. If I can get a nice sized level that you can walk around nicely, then I'll try and add a game - pointless planning a game around an engine that isn't up to par!
0 likes 2 comments

Comments

Sir Sapo
Quote:pointless planning a game around an engine that isn't up to par!


Pointless? Hell, I do it all the time![grin]
July 07, 2006 01:43 PM
........................................
looks great again, would love to see it with dithered fills (and scrolling bg ;) ).

Quote:Original post by benryves
@philipptr: I don't know if you ever completed your triangle filling, but the way I've done it in the past is to split the triangle into two halves (y0→y1 and y1→y2, where y0<y1<y2). I would then trace down the sides of the triangle, calcuating the X bounds for the top and bottom halves (Bresenham), then filling in the horizontal lines using these values. Only uses integer arithmetic, so nice and fast.


yes I already had the sorting working and the calculating of the x bounds, but I never found out how to decide which line is on which side (in which of the two buffers).after thinking a bit about it yesterday I came up with the solution:

if ((((middleY-topY)/(bottomY-topY))*(bottomX-topX)+(topX))>middleX)
{ 2 lines on the left side, one on the right }
else
{ 2 lines on the right side, 1 on the left }

and now it works :)
July 11, 2006 11:44 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement