Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sprite warping (or wraping?)
#5
(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]
Reply


Messages In This Thread
Sprite warping (or wraping?) - by System64 - 11-15-2022, 11:55 PM
RE: Sprite warping (or wraping?) - by megamarc - 11-16-2022, 12:36 AM
RE: Sprite warping (or wraping?) - by System64 - 11-16-2022, 12:52 AM
RE: Sprite warping (or wraping?) - by megamarc - 11-16-2022, 07:14 AM
RE: Sprite warping (or wraping?) - by System64 - 11-16-2022, 08:16 AM
RE: Sprite warping (or wraping?) - by megamarc - 11-16-2022, 08:25 AM
RE: Sprite warping (or wraping?) - by megamarc - 11-16-2022, 08:34 AM
RE: Sprite warping (or wraping?) - by System64 - 11-16-2022, 08:42 AM
RE: Sprite warping (or wraping?) - by megamarc - 11-17-2022, 03:00 AM
RE: Sprite warping (or wraping?) - by System64 - 11-21-2022, 09:05 PM
RE: Sprite warping (or wraping?) - by megamarc - 11-23-2022, 08:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)