Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Displaying Text Graphics over a JPG Image background ??

Author
Message
Zaxtor99
12
Years of Service
User Offline
Joined: 27th Jul 2011
Location: Boise, Idaho, USA
Posted: 3rd Aug 2011 23:57
Hey, what's the best way to put a JPG image as the background and use text CHR$ graphics on top of that image background and move graphics using the INK 0,1 command without damaging or writing over the JPG background?

..or is it not possible? Is there a better way to achieve this, or do you need to use sprites or objects to prevent damaging the JPG background?

- Zaxx
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 4th Aug 2011 01:19 Edited at: 4th Aug 2011 01:22
Try using Draw Sprites First just before your program loop starts, and using the sprite commands instead of Image commands.

Sync On
Sync Rate 60

Load Image "MyImage", 1, 1
Sprite 1, 0, 0, 1

Draw Sprites First

Do
Text 10, 10, "My Text HERE! Yay!"
Sync
Loop
End

In reguards to "damaging the background" keep control of your program with the sync commandset. That way you're drawing and redrawing sprites each cycle. If you're doing some construction with the images, then it's best to handle all this in memory, which memblocks are very useful for. Remember with sprites, you can work on images directly as native images then just assign them to sprites.
Zaxtor99
12
Years of Service
User Offline
Joined: 27th Jul 2011
Location: Boise, Idaho, USA
Posted: 4th Aug 2011 01:52
Thanks for the help Daniel/

But is "Draw Sprites First" a DBC command or a DBP command?

I get a error when using that code.


- Zaxx
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Aug 2011 09:08
@Zaxtor99
I think it's DBPro.

Sprites are possible to use in DBC as well - but performance wise they aren't as good as DBPro. A simple solution for your background image question is to load your jpg onto a memory or offscreen bitmap and then copy that to the main display. In Commodore 64 lingo, I believe that was called page flipping.

So load your image to a bitmap directly. In this case we'll use bitmap 1



An alternative to this is loading your picture in as an image and pasting that to the main screen:



Using offscreen bitmaps can be very useful. Here is a scrolling screen demo where bitmap 1 is used to create a scrolling background and the FPS are shown on the main display on top of that scrolling background. Because I keep copying the offscreen bitmap to bitmap 0, I don't have to manage the clearing of the screen because it is always refreshed with the new background image. This allows me to put whatever additional graphics I have on top without them getting messed up (smeared).



Enjoy your day.
Zaxtor99
12
Years of Service
User Offline
Joined: 27th Jul 2011
Location: Boise, Idaho, USA
Posted: 4th Aug 2011 10:59 Edited at: 4th Aug 2011 11:00
Thanks Latch!

just what I was looking for..

Yep, I vaguely remember the good ol' "page flipping" hehe.

I'm gonna try that and see if the performance and game speed stays relatively the same, if it doesn't then it might not be worth it. Game play always trounces eye candy in my book at least.


- Zaxx

Login to post a reply

Server time is: 2024-04-23 16:15:21
Your offset time is: 2024-04-23 16:15:21