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.

Newcomers DBPro Corner / 2d background with text, help

Author
Message
Rahil45
16
Years of Service
User Offline
Joined: 31st Jul 2008
Location:
Posted: 3rd Aug 2008 11:21
what is the comand to texture the background in 2d? i tried making a sprite, and it worked, except i cant see the text i put, like scores. what is the proper way to make the background textured?
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 3rd Aug 2008 13:44
Have you tried paste sprite as thats the only way using sprites that will let you put text on it.

Dark Physics makes any hot drink go cold.
Rahil45
16
Years of Service
User Offline
Joined: 31st Jul 2008
Location:
Posted: 4th Aug 2008 00:31
it doesnt matter if its sprite or not, i just want to know the proper way to put a 2d background, but ill try that
Rahil45
16
Years of Service
User Offline
Joined: 31st Jul 2008
Location:
Posted: 4th Aug 2008 07:32
it didnt work, does anyone know how to set the background texture for a 2d game?
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 7th Aug 2008 00:34 Edited at: 7th Aug 2008 00:35
Rahil45,

Sprites in DBPRO are essentially 3d objects. And when any 3d object is created the 3d backdrop is turned on. When the 3d backdrop is turned on, any 2d(non sprite)command's results(like pasting text to the screen, or pasting an image to the screen) will only display for the loop that it is pasted. It will be erased from the screen on the next loop.

So, in order to counter this(when the 3d backdrop is turned on), you must repaste the text or image each loop. However, this can have a tremendous performace hit, which you don't want.

So, you would be better off turning the background image or text into a sprite(if other sprites exist) and positioning the sprite.

If you need help understanding this, let me know, and I'll try to clarify a bit better. If you need help converting text to sprite let me know, and I'll help you with it.

Hope this helps.
Rahil45
16
Years of Service
User Offline
Joined: 31st Jul 2008
Location:
Posted: 7th Aug 2008 02:27
so there is no easy way to make a 2d background? i got it to work a while ago by positioning the sprite to the very bottom of my screen so i couldnt see it, then i pasted the sprite to 0,0. i was just hoping someone cound tell me how to make a 2d background for a 2d game. does everyone here have to make the a sprite for the background like i did?
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 7th Aug 2008 06:30 Edited at: 7th Aug 2008 06:45
Don't paste the sprite. Position it at 0,0 (sprite bgsprite,0,0,bgimage), and that's all. Pasting it will probably cause lag.

Any sprites with a higher z priority(any sprites created after the bg sprite, or any sprites set to a higher z priority) will display on top of the bg sprite.

For text, it is real simple to make sprites out of them so that they too will display on top of the bg sprite.

Basic Text to Sprite Function:


I did not make this sample function dynamic at all, so to keep it simple just to get to the point. But you should allow it a few perimeters to make it work:

1. the string to use
2. the bitmap to draw to(or you could use an inside function call to a free bitmap locater function)
3. the image to use(or you could use an inside function call to a free image locater function)
4. the sprite to use(or you could use an inside function call to a free sprite locater function)

Optional:

4. text font
5. text color
6. text bg color(rgb(0,0,0) for transparet text)

Lastly, you would want this function to return the sprite that was created.

I believe that you are trying to make this too difficult...which I fully understand, having been new to the language before too.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Aug 2008 11:04
Quote: "Pasting it will probably cause lag. "


Sprites always run faster for me when I paste them.


Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 9th Aug 2008 23:44
Windowskiller,

It really depends on what he's going for. Sprites would be much easier to use if say a 2d object will be moving around the screen(thus the need for that object to redraw the bg). You see? If it's just going to be a static scene, which displays scores or something, then no sprite is necessary.
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 12th Aug 2008 01:20
If the bg isn't moving then there is no need to paste it each loop. If something in the foreground is moving, and it's not a sprite, you'll have to repaste the bg and then the foreground object each loop. Which would be slow. But once again, there would be no need for a sprite if there is no foreground moving object on top of a pasted bg.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 12th Aug 2008 04:21
If I may interject, would his game be much of a game if there were no moving foreground?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th Aug 2008 05:00
Why not use a 3D plain for a background? You can do things with it that you cannot do with other methods. Here is an example. Use the arrow keys to move/rotate it.



Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 12th Aug 2008 20:32
60[]s,

Well, if he were displaying a highscore screen or so, this would be a case of a nonmoving foreground.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 12th Aug 2008 20:52
@Nano brain: Good point. I assumed that when he wrote "scores" he meant an in-game score being displayed during gameplay. I had not considered that he could have meant high scores as well. But in that case he'd need to turn the backdrop off .

Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 12th Aug 2008 21:23
Si, si senior.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 13th Aug 2008 15:09 Edited at: 13th Aug 2008 15:09
@Rahil45: Anyway, try LBFN's method of having a 3D plain as your backdrop.

Login to post a reply

Server time is: 2024-09-27 18:18:34
Your offset time is: 2024-09-27 18:18:34