11-16-2022, 08:16 AM
(11-16-2022, 07:14 AM)megamarc Wrote: I see, good examples. For warping effect I'd use two sprites, one on each side of the viewport, each one being clipped on its own side. I guess that's what original SMB3 did. I'd keep both sprites synchronised all the time with the same animation frame, but put one inside the viewport and the other completely outside. Only when the character gets warped at the edges, I'd relocate the "hidden" sprite to be on the opposite side. Do you get the idea?
Yeah, I think it's quite simple to do that, thanks for your suggestion!
I'll try this, I'm messing up with the Bitmap mode now, and you can do really funny things!, I made functions for drawing rectangles and lines, trying to figure out how to draw a circle.
Code:
proc drawRectWH(bitmap: TLN_Bitmap, x: int, y: int, w: int, h: int, stroke: uint = 0, strokeColor: uint8 = 1, color: uint8 = 1): void =
# Drawing stroke
if stroke > 0:
# Top and bottom
for i in x-(stroke.int div 2)..x+w+(stroke.int div 2)-1:
for j in y-(stroke.int div 2)..(y+(stroke.int div 2)-1):
if (i >= 0 and i < bitmap.getBitmapWidth()-1) and (j >= 0 and j < bitmap.getBitmapHeight()-1):
bitmap.getBitmapPtr(i, j)[] = strokeColor
for i in x-(stroke.int div 2)..x+w+(stroke.int div 2)-1:
for j in y-(stroke.int div 2)+h..(h+y+(stroke.int div 2)-1):
if (i >= 0 and i < bitmap.getBitmapWidth()-1) and (j >= 0 and j < bitmap.getBitmapHeight()-1):
bitmap.getBitmapPtr(i, j)[] = strokeColor
# Sides
for i in x-(stroke.int div 2)..x-(stroke.int div 2)+stroke.int-1:
for j in y+(stroke.int div 2)..y+h-(stroke.int div 2):
if (i >= 0 and i < bitmap.getBitmapWidth()-1) and (j >= 0 and j < bitmap.getBitmapHeight()-1):
bitmap.getBitmapPtr(i, j)[] = strokeColor
for i in x-(stroke.int div 2)+w..x+w+(stroke.int div 2)-1:
for j in y+(stroke.int div 2)..y+h-(stroke.int div 2):
if (i >= 0 and i < bitmap.getBitmapWidth()-1) and (j >= 0 and j < bitmap.getBitmapHeight()-1):
bitmap.getBitmapPtr(i, j)[] = strokeColor
# Drawing Inside
for i in x+(stroke.int div 2)..x+w.int-(stroke.int div 2)-1:
for j in y+(stroke.int div 2)..y+(h.int-stroke.int div 2)-1:
if (i >= 0 and i < bitmap.getBitmapWidth()-1) and (j >= 0 and j < bitmap.getBitmapHeight()-1):
bitmap.getBitmapPtr(i, j)[] = color
return
proc drawLine(bitmap: TLN_Bitmap, x: int, y: int, x2: int, y2: int): void =
let lineLength = sqrt(pow(x2.float - x.float, 2) + pow(y2.float - y.float, 2))
for i in 0..round(lineLength * sqrt(2.float64)).int:
var myX = round(x.float + (i.float / lineLength) * (x2.float - x.float))
var myY = round(y.float + (i.float / lineLength) * (y2.float - y.float))
bitmap.getBitmapPtr(myX.int, myY.int)[] = 1
return
Here is some of my works!
![[Image: image.png]](https://media.discordapp.net/attachments/803944031285280778/1042201183491735643/image.png)