• entries
    222
  • comments
    607
  • views
    587895

Filling

Sign in to follow this  
benryves

706 views



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!
Sign in to follow this  


2 Comments


Recommended Comments

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


Pointless? Hell, I do it all the time![grin]

Share this comment


Link to comment
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 :)

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now