Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can anyone tell me why this won't compile?
#1
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)
Reply
#2
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&())
Reply
#3
Well that was dumb.  Thanks.  Now I just have to get my dumb sub to work. Tongue
Reply
#4
@CMR Dumber not to ask. Welcome!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#5
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
Reply
#6
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.
Reply
#7
(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
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#8
(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
Reply
#9
(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.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#10
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using gcc to compile C file aurel 22 4,233 04-22-2024, 03:48 PM
Last Post: aurel
  Can't compile .bas files PhilOfPerth 11 2,009 01-03-2023, 02:21 AM
Last Post: PhilOfPerth

Forum Jump:


Users browsing this thread: 1 Guest(s)