Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scrolling fog/cloud image for moving background
#6
That's pretty, bplus.  Would be great for a game.

Hey James, I like the transparency idea.  Will play around with that.  trhanks!

I thought to do some layering of two images, one closer, so here's that.  Used balls instead of lines.

- Dav

EDIT: I added a 3rd layer for more realism, but it would be too slow to _PUTIMAGE all this in a running game probably.

Code: (Select All)
SCREEN _NEWIMAGE(1000, 600, 32)

fog& = _NEWIMAGE(300, 300, 32)
_DEST fog&
FOR i = 1 TO 10000
    c = RND * 200 + 50
    ball RND * _WIDTH, RND * _HEIGHT, RND * 15, c, c, c + 50, RND * 2
NEXT


fog1& = _COPYIMAGE(fog&)
_PUTIMAGE (_WIDTH, 0)-(0, _HEIGHT), fog1&
fog2& = _COPYIMAGE(fog1&)

_DEST 0

DO

    _PUTIMAGE (spos2, 0)-(spos2 + _WIDTH, _HEIGHT), fog1&
    _PUTIMAGE (spos2 + _WIDTH, 0)-(spos2 + (_WIDTH * 2), _HEIGHT), fog2&
    spos2 = spos2 - 3: IF spos2 <= -_WIDTH THEN spos2 = 0

    _PUTIMAGE (spos, 0)-(spos + _WIDTH + 300, _HEIGHT + 300), fog1&
    _PUTIMAGE (spos + _WIDTH + 300, 0)-(spos + ((_WIDTH + 300) * 2), _HEIGHT + 300), fog2&
    spos = spos - 6: IF spos <= -_WIDTH - 300 THEN spos = 0

    _PUTIMAGE (spos3, 0)-(spos3 + _WIDTH + 600, _HEIGHT + 600), fog1&
    _PUTIMAGE (spos3 + _WIDTH + 600, 0)-(spos3 + ((_WIDTH + 600) * 2), _HEIGHT + 600), fog2&
    spos3 = spos3 - 12: IF spos3 <= -_WIDTH - 600 THEN spos3 = 0

    _DISPLAY
    _LIMIT 30
LOOP

SUB ball (BallX, BallY, size, r&, g&, b&, a&)
    FOR s = 1 TO size STEP .4
        CIRCLE (BallX, BallY), s, _RGBA(r&, g&, b&, a&)
        r& = r& - 1: g& = g& - 1: b& = b& - 1
    NEXT
END SUB

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
RE: Scrolling fog/cloud image for moving background - by Dav - 05-22-2022, 10:54 PM



Users browsing this thread: 5 Guest(s)