(11-17-2022, 03:00 AM)megamarc Wrote: Hi,
You don't need 4 sprites to warp in both directions, just 2 sprites. Here is the simplified source.
Beware that you cannot warp in both axis at the same time, that is, trying to warp in a corner breaks the logic rules. You should restrict your gameplay to avoid reaching a corner!
Hi
Effectively, you only need 2 sprites if you are not taking corners in consideration. I considered the case with the corners but I didn't precised about that, I am sorry. For this specific case, you need 4 sprites.
About the circle algorithm, I made a varient that let you make a filled circle, it works very well.
Code:
proc drawCircleFill(bitmap: TLN_Bitmap, centerX: int, centerY: int, radius: int): void =
var
x = 0
y = radius
m = 5 - 4 * radius
while (x <= y):
bitmap.drawLine(centerX - x, centerY - y, centerX + x, centerY - y)
bitmap.drawLine(centerX - y, centerY - x, centerX + y, centerY - x)
bitmap.drawLine(centerX - y, centerY + x, centerX + y, centerY + x)
bitmap.drawLine(centerX - x, centerY + y, centerX + x, centerY + y)
if (m > 0):
dec y
m -= 8 * y;
inc x
m += 8 * x + 4
proc drawLine(bitmap: TLN_Bitmap, x: int, y: int, x2: int, y2: int): void =
var
dy = y2 - y
dx = x2 - x
err = 2 * dy - dx
myY = y
for myX in x..x2:
bitmap.getBitmapPtr(myX, myY)[] = 1
if err >= 0:
myY += 1
err -= 2 * dx
err += 2 * dy
I also have a suggestion for tiles. I noticed there is still 5 unused bits in the tile struct, so you maybe can add a blending flag for individual tiles, so you can enable or disable transparency for individual tiles, unless you planned something else with thoses bits? What do you think about this idea?