QB64 Phoenix Edition
Can anyone tell me why this won't compile? - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Can anyone tell me why this won't compile? (/showthread.php?tid=3601)

Pages: 1 2


Can anyone tell me why this won't compile? - CMR - 04-09-2025

Code: (Select All)

''animate a sprite array
''load the sprite
Dim  frames&(1 to 3)
frames&(1) = _LoadImage("blue1.bmp")
frames&(2) = _LoadImage("blue2.bmp")
frames&(3) = _LoadImage("blue3.bmp")

Screen _NewImage(640, 480, 32)
_ClearColor _RGB(255,0,255)

Do
    start_time# = Timer(.001)
    cls
    ''---------do work here-------------
    Animate(frames&())
   
    ''---------------------------------
    ''fps
    Print (1 / (Timer(.001) - start_time#))
    _Display    ''flip automatic page buffer manually
    _Limit(60)
Loop Until Inkey$ <> ""


Sub Animate(anim() as Long)
    Static count&
    Static frame&
   
    count& = 0
    frame& = 1
   
    If count& > 10 Then frame& = frame& + 1
    If frame& > LBound(anim) Then frame& = 1 
   
    ''_ClearColor _RGB(255,0,255)
    _PutImage (10, 10), anim(frame&)
   
End Sub

I have no idea why this won't compile.  I don't get any error codes or anything.  Maybe a linker issue?  I running this on Linux Mint 64bit.  Just testing some quick and dirty animation.


.bmp   blue1.bmp (Size: 12.05 KB / Downloads: 212)

.bmp   blue2.bmp (Size: 12.05 KB / Downloads: 201)

.bmp   blue3.bmp (Size: 12.05 KB / Downloads: 195)


RE: Can anyone tell me why this won't compile? - SMcNeill - 04-09-2025

Line 16 is the issue.

    Animate(frames&())

You can't pass an array to a sub via parenthesis like that. Change the line to:

    Animate frames&()

OR change it to:

CALL Animate(frames&())


RE: Can anyone tell me why this won't compile? - CMR - 04-09-2025

Well that was dumb.  Thanks.  Now I just have to get my dumb sub to work. Tongue


RE: Can anyone tell me why this won't compile? - bplus - 04-09-2025

@CMR Dumber not to ask. Welcome!


RE: Can anyone tell me why this won't compile? - Pete - 04-09-2025

Oh, you mean the saying that goes... There are no such things as dumb questions, only dumb people who ask them?

Oops, I meant the mean saying that goes... Big Grin

Kidding aside, if you need any help getting it working from this point forward, just post the code.

Pete


RE: Can anyone tell me why this won't compile? - CMR - 04-09-2025

Thanks everyone.  I appreciate the welcome.  Be prepared.  I'm sure I'll have plenty more dumb questions.  Did you know you can't set the _ClearColor  _RGB() for an image before you setup your screen?  I just found that one out today!  It works when you grab a point from the background like the examples show, though.  I'm guessing it has something to do with the screens default bit depth before Screen _NewImage is called.


RE: Can anyone tell me why this won't compile? - PhilOfPerth - 04-09-2025

(04-09-2025, 09:55 PM)CMR Wrote: Thanks everyone.  I appreciate the welcome.  Be prepared.  I'm sure I'll have plenty more dumb questions.  Did you know you can't set the _ClearColor  _RGB() for an image before you setup your screen?  I just found that one out today!  It works when you grab a point from the background like the examples show, though.  I'm guessing it has something to do with the screens default bit depth before Screen _NewImage is called.

You're trespassing!
The "dumb questions" domain is mine!
Luckily, it wasn't that dumb, so I'll let it ride... this time.   Dodgy  Big Grin


RE: Can anyone tell me why this won't compile? - SMcNeill - 04-09-2025

(04-09-2025, 09:55 PM)CMR Wrote: Thanks everyone.  I appreciate the welcome.  Be prepared.  I'm sure I'll have plenty more dumb questions.  Did you know you can't set the _ClearColor  _RGB() for an image before you setup your screen?  I just found that one out today!  It works when you grab a point from the background like the examples show, though.  I'm guessing it has something to do with the screens default bit depth before Screen _NewImage is called.

From the way this sounds to me, you were trying to do something like:

_CLEARCOLOR _RGB(r, g, b)
SCREEN _NEWIMAGE(x, y, 32)

The problem here is that you were clearing the color for the default, start up screen, SCREEN 0.  THEN you were swapping to a different SCREEN with the _NEWIMAGE.   

You can't clear colors on a screen that doesn't even exist yet.  Big Grin

What you could do is something like:

MyScreen = _NewImage(x, y, 32)
_ClearColor _RGB(r, g, b), MyScreen
Screen MyScreen

With the above, you make the screen, clear the color, then swap to that screen after it's all the way the you need it to be.  Wink


RE: Can anyone tell me why this won't compile? - bplus - 04-09-2025

(04-09-2025, 09:55 PM)CMR Wrote: Thanks everyone.  I appreciate the welcome.  Be prepared.  I'm sure I'll have plenty more dumb questions.  Did you know you can't set the _ClearColor  _RGB() for an image before you setup your screen?  I just found that one out today!  It works when you grab a point from the background like the examples show, though.  I'm guessing it has something to do with the screens default bit depth before Screen _NewImage is called.

Yes graphics don't work without the screen up. Do you know about setup with Sceeen _Newimage(workWidth, workHeight, 32) ? 32 for _rgb stuff including alpha transparency.

Dang Steve did is again, sneeks his post in before I get mine typed.


RE: Can anyone tell me why this won't compile? - CMR - 04-10-2025

I figured everyone else already knew that.  I had just spent a good half hour trying to figure out why my images transparent color wasn't working.  The thing that confused me was that I somehow got it working that way by setting _Source, and reading a point off the image instead of using _RGB().  I managed to recreate it.  I'm storing the images in an array because that's how I did it last time. Don't know if that matters.

Code: (Select All)

''load iamges
Dim image&(1 to 2)
image&(1) = _LoadImage("blue1.png")
image&(2) = _LoadImage("blue1.bmp")

''get bg colors of images
Dim clr_png~&, clr_bmp~&
_Source image&(1)
clr_png~& = Point(0,0)
_Source image&(1)
clr_bmp~& = Point(0,0)
''clear color
_ClearColor clr_png~&, image&(1)
_ClearColor clr_bmp~&, image&(2)

Screen _NewImage(640, 480, 32)

''
Print "Reference color: ", _RGB(255,0,255)
Print "png BG color  : ", clr_png~&
Print "bmp BG color  : ", clr_bmp~&

''show the images with clear color set
'_ClearColor _RGB(255, 0, 255), image&(1)
'_ClearColor _RGB(255, 0, 255), image&(2)

_PutImage(10, 100), image&(1)
_PutImage(10, 200), image&(2)

''release images
_FreeImage image&(1)
_FreeImage image&(2)

It even shows the BG colors as being different, but they still work in a 32bit screen.  Of course, this would be a non issue if I had just setup my Screen first like  a normal human being.

I feel like I should apologize for this rabbit hole I'm dragging you all down.  Big Grin