Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scrolling fog/cloud image for moving background
#8
Yeah, 1 image, just stretched out on two of the layers.  I added the witch code to see how slow it would play.  pretty slow, on my laptop at least.   I _PUTIMAGE'd the witch first so she would seem to be in the clouds.

- Dav

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

witch& = BASIMAGE2&

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

    '===================================================

    'Here's the witch code....
    'if pressed space, move witch up& forward
    IF INP(&H60) = 57 THEN
        witchflyy = witchflyy - 8
        witchflyx = witchflyx + 6
        spos = spos - 4 '<-- scroll fog faster too (remove it wanted)
    ELSE
        ' else wich drifts down
        witchflyy = witchflyy + 3
        witchflyx = witchflyx - 2
    END IF

    'keep witch in screen bounds
    IF witchflyx < 5 THEN witchflyx = 5
    IF witchflyx > _WIDTH - 100 THEN witchflyx = _WIDTH - 100
    IF witchflyy < 5 THEN witchflyy = 5
    IF witchflyy > _HEIGHT - 100 THEN witchflyy = _HEIGHT - 100

    _PUTIMAGE (witchflyx, witchflyy), witch&

    LOCATE 1, 1: PRINT "Press SPACE to fly...";

    '===========================================================

    _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 + 400, _HEIGHT + 400), fog1&
    _PUTIMAGE (spos + _WIDTH + 400, 0)-(spos + ((_WIDTH + 400) * 2), _HEIGHT + 400), fog2&
    spos = spos - 6: IF spos <= -_WIDTH - 400 THEN spos = 0

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

    _DISPLAY
    _LIMIT 30
LOOP

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



FUNCTION BASIMAGE2& 'witch.png
    v& = _NEWIMAGE(100, 96, 32)
    DIM m AS _MEM: m = _MEMIMAGE(v&)
    A$ = ""
    A$ = A$ + "haIkMV\Bc4447?7mP??NcCRGl5#?XRXX8j11AAa=R8^P;h2^S2^7#Aa3NaK2"
    A$ = A$ + "nDhIO7lJomm_CjhT9Cb<IVNjZ<CMh767UTdeoYk^ZZ[^WLiEib98888THFMe"
    A$ = A$ + "EEGNiUZc>k<=hehJK^iVJXnkGF0H_Q]OQ5FhoG8GMIWMfA]hR;:jB:aXS>JX"
    A$ = A$ + "J#md5Y?Sm0S557]`?mfK_R^`8m``<c<SFC`HOH<#ZKOo5a<?]OVJZYDOla79"
    A$ = A$ + "BOFNiUEgOomR^H9Nla7EaMn53_mfKJ=9OnlR^H9#o5<7Q=VWQjfBc4f#C`k3"
    A$ = A$ + "6;TjfBc2FAC:Y;[_njR^H1#\7fbW\a6K<eMgMWFGfMgM3dgR`0nbMk]gVIeF"
    A$ = A$ + "MliFd?iK^iVRfb4nn0o\Yffd<d7aJ`0k2UPh;8G3:Qnk23\9T3QJ`:[\RF3T"
    A$ = A$ + "HKXG?THIZV17L#WZ18G1VeRQjf>gX[^jbij0e]I^BBcYEDY]fJ;C7GADHXQ6"
    A$ = A$ + "b9JaLc=WJ_mfCd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NmeG9g6J;dkm32e2#DggNX?<F?7<fZYV=P"
    A$ = A$ + "?j`ghFJY5b]UF1Re2_JBLcI[I>8XA8W27Ola>]NN\5IQj#YZJ8WahMMUJfQk"
    A$ = A$ + "JBFX_QG#mfT6k1CKY5Q]W4J61[A3gdT\ni_7b5`;_l2ijPX5o27jW8e7GUX["
    A$ = A$ + "A3Rd2i<c=HXh\lAjGDK#><ek;77Y5MgMgRFD7POV^B?j[_n4]84LAm]PaWbj"
    A$ = A$ + "W[HLA?Ti:J<B[jSDNFN6O\MN]THlB>fhl>6aG:?_^\3je;91JQllOdn4ga]T"
    A$ = A$ + "cc]dS6Jo6V_dI9>3nNg\BDmoEVcf=4Vo_bc75gBmZc59f>gC#?_7oj[_Zj\#"
    A$ = A$ + "F`Qh[?1GfO`IA#MLIfoMbIjVPPPPPPPP#S`o0XLK%%h1"
    btemp$ = ""
    FOR i& = 1 TO LEN(A$) STEP 4: B$ = MID$(A$, i&, 4)
        IF INSTR(1, B$, "%") THEN
            FOR C% = 1 TO LEN(B$): F$ = MID$(B$, C%, 1)
                IF F$ <> "%" THEN C$ = C$ + F$
            NEXT: B$ = C$: END IF: FOR j = 1 TO LEN(B$)
            IF MID$(B$, j, 1) = "#" THEN
        MID$(B$, j) = "@": END IF: NEXT
        FOR t% = LEN(B$) TO 1 STEP -1
            B& = B& * 64 + ASC(MID$(B$, t%)) - 48
            NEXT: X$ = "": FOR t% = 1 TO LEN(B$) - 1
            X$ = X$ + CHR$(B& AND 255): B& = B& \ 256
    NEXT: btemp$ = btemp$ + X$: NEXT
    btemp$ = _INFLATE$(btemp$, m.SIZE)
    _MEMPUT m, m.OFFSET, btemp$: _MEMFREE m
    BASIMAGE2& = _COPYIMAGE(v&): _FREEIMAGE v&
END FUNCTION

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-23-2022, 12:37 AM



Users browsing this thread: 4 Guest(s)