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 Professional Discussion / Word wrap function but how do i include sprites?

Author
Message
Battoad
AGK Developer
19
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 1st Jul 2012 20:22 Edited at: 1st Jul 2012 22:04
Hi,I am trying out basjaks/IanMs Text Wrapping Function




but with long text passages, i.e lots of lines. As such, I am unable to place the wrapped text, which will vary, within a loop so that text can be seen and sprites used elsewhere.

I know i can use bitmaps or images simply to display, but i need sprite movement.

Anyone got any ideas how i can display both text wrap and sprites simultaneously?

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Jul 2012 21:01
By the looks of that you should replace Line_Length to to match your sprite_width_total. Then you would use Mid$ to replace the string with sprites. Now this Sprite_Width_Total will vary with a letter i, and a letter H. You can either have equally spaced sprites, or you will have to tally up all of the letters to get the correct Sprite_Width_Total. If the sprites are equally spaced then Line_Length can be just set to match the number of sprites that will fit on a line.

Battoad
AGK Developer
19
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 1st Jul 2012 21:44
Hi Pincho, thanks for your reply, but I don't think I have explained myself properly.

I don't want to replace text with sprites, I want to display text in one part of the window, and add separate sprites to a different part of the window, both being displayed simultaneously.

The problem displaying text and sprites on a screen simultaneously is that as the page syncs, the text will disappear unless it is placed in a loop. Using the word wrap function does not enable the text to be placed in a loop, hence when the screen redraws, the sprites remain but the text vanishes.

If I use e.g bitmaps for the images then i can display text and images simultaneously, but I require the images to be copied into sprites. This is my dilema ! Hope that makes it clearer. Thanks.

basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 1st Jul 2012 23:23 Edited at: 1st Jul 2012 23:25
so you're trying to wrap a text to physically goes within borders.

I use this function in my software multicomps. you can place it instead of the print token$ line.

If you couldn't, I'll make example for you but later. as am not at home at the moment.



Battoad
AGK Developer
19
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 1st Jul 2012 23:54
hmm, thanks basjak but i don't think it helps. Correct me if i'm wrong though.
Its the common problem of displaying text and sprites at the same time. As far as i'm aware when sprites are used, text will only display if it is placed within a do...loop for example.
I can't work out how to put the word wrap function text/print output into a loop when i have lots and lots of string$ to wrap whilst sprites are on the screen.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 2nd Jul 2012 00:04 Edited at: 2nd Jul 2012 02:16
Well, I'm not sure if the Text command works the same as the print command. You could try the text command, I have a feeling that it syncs differently. I can remember using it for certain situations, and I think it was to fix a sync problem. But that was so long ago, that it might have been DB Classic.

EDIT: I have just tested Print"" with sprites, and I got them both on the screen at the same time. The print is before the Do Loop which contains a Sync. So the print isn't syncing with the sprites, but works anyway.



basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 2nd Jul 2012 03:45 Edited at: 2nd Jul 2012 04:55
The key factor in the problem is to create a bitmap and print the text onto it. then copy the bitmap to the screen.

download the full program. it display 101 sprites on the screen while the FPS is still as set by Sync rate 60.

control the arrow sprite with arrow keys.



Battoad
AGK Developer
19
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 2nd Jul 2012 11:11
Thank you so much basjak. That works superbly.
My earlier attempts using bitmaps showed that I didn't fully understand the concept because although I had tried using bmp images as bitmaps, I didn't think of using a bitmap for printing the text on to. Lesson learned, thanks again.

Login to post a reply

Server time is: 2026-07-07 20:17:46
Your offset time is: 2026-07-07 20:17:46