Posts: 42
Threads: 7
Joined: Mar 2025
Reputation:
3
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.
blue1.bmp (Size: 12.05 KB / Downloads: 212)
blue2.bmp (Size: 12.05 KB / Downloads: 201)
blue3.bmp (Size: 12.05 KB / Downloads: 195)
Posts: 3,446
Threads: 376
Joined: Apr 2022
Reputation:
345
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&())
Posts: 42
Threads: 7
Joined: Mar 2025
Reputation:
3
Well that was dumb. Thanks. Now I just have to get my dumb sub to work.
Posts: 4,702
Threads: 222
Joined: Apr 2022
Reputation:
322
@CMR Dumber not to ask. Welcome!
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 2,910
Threads: 305
Joined: Apr 2022
Reputation:
167
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...
Kidding aside, if you need any help getting it working from this point forward, just post the code.
Pete
Posts: 42
Threads: 7
Joined: Mar 2025
Reputation:
3
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.
Posts: 796
Threads: 139
Joined: Apr 2022
Reputation:
33
04-09-2025, 11:21 PM
(This post was last modified: 04-09-2025, 11:23 PM by PhilOfPerth.)
(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.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) 
Please visit my Website at: http://oldendayskids.blogspot.com/
Posts: 3,446
Threads: 376
Joined: Apr 2022
Reputation:
345
(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.
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.
Posts: 4,702
Threads: 222
Joined: Apr 2022
Reputation:
322
04-09-2025, 11:55 PM
(This post was last modified: 04-09-2025, 11:57 PM by bplus.)
(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
Posts: 42
Threads: 7
Joined: Mar 2025
Reputation:
3
04-10-2025, 02:56 AM
(This post was last modified: 04-10-2025, 02:59 AM by CMR.)
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.
|