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 / 2D box behind text?

Author
Message
Yodaman Jer
User Banned
Posted: 25th May 2009 22:32
Hi guys, I'm having trouble getting the Box command to work in a subroutine of my program. Basically what I want to do is draw a box behind text, for a signpost that the player can interact with. Here's some pseudo code (I deleted the original because it got too messy):



The problem I'm having is with the size variables, and placing the box. I've centered the text at 500,100, and I need to figure out how to draw the 2D box behind that and big enough so that the text is 'contained' inside of it. How do I get the box there?

Also, I wanted to ask if anybody has advice for controlling the camera in this subroutine, and if they have some pseudo code? Thanks for any help/advice guys!


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th May 2009 22:44
TEXT HEIGHT() and TEXT WIDTH() ought to do it.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Yodaman Jer
User Banned
Posted: 25th May 2009 22:49 Edited at: 25th May 2009 23:17
Do you mean I draw the box using those commands? Like so:

Box Text Height(), Text Width()

Would that go before or in the loop?

EDIT:

Never mind, I got it too work. I realized what I was doing wrong.
I thought all the variables had to be equal, but then I realized that they had to identify the top, bottom, left and right corners of the box. So I wrote them like so in the following subroutine:




"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Yodaman Jer
User Banned
Posted: 26th May 2009 01:32
I've encountered a really weird problem (the strangest I've seen yet!) with my program. I've made it so that when you lose all of your lives, it deletes all of the objects and resets the level. It deletes the objects perfectly fine, but when it resets it crashes the program! There's no bugs, it just says "Dark Basic Programming Tool has encountered a problem and needs to close. We're sorry for the inconvenience.". I checked everything; I'm deleting everything that exists, and I know that it all works. I've attached an .EXE to this post for others to test out. Maybe it's just my computer giving me a problem?

Here's the code, I know it works fine and isn't the problem (I think).



Has anyone ever had this problem before?


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 26th May 2009 02:00
the text height() and width() commands return the height and width of a string, so if x,y is the center of the text and string$ is the text then heres the code for a box behind it:

halfheight=.5*(text height(string$))
halfwidth=.5*(text width(string$))

box x-halfwidth,y-halfheight,x+halfwidth,y+halfheight

thats option 1, the better option is the set text opaque and set text transparent commands

there turn on and off the text backgrounds, which is essentially a colored box behind text (exactly what you need!)

the ink commands asks for two parameters, and ink color and a background color

the background color is the color of the box behind the text

set text opaque turns on the box, set text transparent turns it off

so, ink rgb(0,255,0),rgb(255,0,0) would be green text on a red background

There are only 10 kinds of people in the world, those who understand binary and those who dont
Yodaman Jer
User Banned
Posted: 26th May 2009 02:10
Thanks for the description on those commands Smartguy, but I solved that issue a few hours ago. I'm having a really weird problem that involves the DB engine crashing now...my previous post covers it. I really wish I could figure out what's causing it.


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 26th May 2009 02:59
i know you solved it, im just explaining some alternate methods to solve it

also im getting an error at line 27 because you havent created that object yet

There are only 10 kinds of people in the world, those who understand binary and those who dont
Yodaman Jer
User Banned
Posted: 26th May 2009 05:02
Line 27 is the line that sets the Collision for the sky box, which is object number 900. I'm loading it alright, and the .exe contains all of the media. This is one weird glitch!

It used to reset itself just fine. Something just doesn't want to work anymore, I'm going to get to the bottom of this.

Has anyone else ever encountered this type of problem?


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Yodaman Jer
User Banned
Posted: 26th May 2009 05:47 Edited at: 26th May 2009 05:48
[Double Post]

Sorry for a new post everyone, but this is what I have done. I first restarted my computer to see if maybe the problem would go away. It didn't, so I started messing with setup.ini files to see if I had accidentally modified anything in them when I was learning how to uncap the 60fps lock. Everything was fine. So, out of curiosity I downloaded the DarkBASIC Professional trial and opened the source code into its editor. A weird glitch aside (everything was positioned in weird areas and the collision was off by a mile), the level rest itself perfectly when I purposely died!!

I had to have messed something up in the DarkBASIC Classic files or something. I think I'll try re-installing DBC to see what happens, although maybe it's just time to buy DBPro. Maybe this is a sign from the programming god (aka 'Lee') to just spend an extra $70 to get the better package! lol


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 26th May 2009 06:02
problem may not be DBC, there are many differences between DBC and pro syntax and stuff, one major difference is how they treat local variables in functions

DBC has 2 variable catagories, global and local, meaning ALL functions have the same variable set, so if you have the same variable in two functions and you call one in the other then it could overwrite the 1st function value with the 2nd, causing problems

Pro has many catagories, global and a local set for EACH function, meaning you can have the same variable in two functions its not a problem

There are only 10 kinds of people in the world, those who understand binary and those who dont
Yodaman Jer
User Banned
Posted: 26th May 2009 06:16 Edited at: 26th May 2009 06:16
Well, I'm not using any variables in my functions at all. This problem is extremely unique because I've done this programming technique before without any problems, and the variables are all fine and in working order. This program was working fine yesterday, it's just been today that it keeps crashing (until I run it in DBPro).

And now that I've got the demo on my computer, I quite like what it's capable of doing. So maybe it's just time to upgrade.


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 26th May 2009 08:08
You could try DEconstructing your code, that is, begin remming out lines and see when the error stops occuring, then UNrem everything but that last line and work your way backwards until you finally figure out which sections are causing it.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 27th May 2009 01:28
What is up with people and remming out stuff!? just use breaks, it's so much easier. lol

New Site! Check it out \/
Yodaman Jer
User Banned
Posted: 27th May 2009 02:05
This problem isn't something that can be solved with remming stuff out or by setting breaks. The DarkBASIC editor simply crashes when the level is told to reset. I've scanned the code, I've remmed some things out (just the things I had modified after I had tested the level reset process, which worked before I added a few more jewels into my game), and for some reason nothing I try works. I've been thinking about upgrading to DB Pro anyway, so I see this as sort of a sign to do so. The fact that the level resets itself decently in DarkBASIC Pro is really weird, but attractive. It not only worked, but the speed was so much faster and the graphics were better. The only thing that was odd was that the objects were WAY off and rotate weird ways, and collision was off by a mile. But those are things I can easily fix once I upgrade.


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 27th May 2009 07:43
AAAHHH!!!! we are losing people to pro!

Well i hope you either get pro to work with it or get it to work in dbc

New Site! Check it out \/
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th May 2009 05:00
Quote: " Maybe this is a sign from the programming god (aka 'Lee') to just spend an extra $70 to get the better package! lol"

Yeah after 2 years it stops working and says "error! error! out of date software, you must upgrade to DBPro or risk losing all your files!"

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 28th May 2009 05:05
rofl, ya pro is much betr, I usually use DBC simply because I dont want to run the risk of something working in pro but not in DBC and having to change it to post it here

There are only 10 kinds of people in the world, those who understand binary and those who dont
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 28th May 2009 06:59
Well fine. am i the only one staying with classic, just because i plainly like it????? I love dbc, i have stated this before, it's fun to get around it's... well.... um... loser qualities.... hahaha thats what i love.

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 28th May 2009 07:00
like I said, I usually use dbc, in fact I cant remember the last time I used pro, but I have both and eventually do plan to go to pro

There are only 10 kinds of people in the world, those who understand binary and those who dont
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th May 2009 11:46
@Yodaman Jer
Quote: ""Dark Basic Programming Tool has encountered a problem and needs to close. We're sorry for the inconvenience.""

This is a windows message. So something is happening that windows doesn't like. That means memory, or the stack, something is causing DB to throw some bad numbers at windows. If you were using memblocks you might be writing out side the bounds of the memblock. In terms of files you could be trying to read or right to a folder or drive that doesn't exist or you don't have permission to access.

You are loading x models and such. If the models aren't formatted correctly, i.e. if they are missing important parts, are tied to jpgs instead of bmps, have '.' in the names of templates they can cause DB to crash. Test this by using internal media, creating a cube instead of loading a model.

You could have badly formatted images. If you save a bitmap in photoshop, load it into MS Paint and resave it. Sometimes photoshop bitmaps can have a slightly different format that DBC won't like.

Quote: "Well fine. am i the only one staying with classic, just because i plainly like it????? I love dbc, i have stated this before, it's fun to get around it's... well.... um... loser qualities.... hahaha thats what i love."

I still find DBC quite challenging. And when I figure out how to do stuff that's "reserved" for more powerful languages, I feel a sense of accomplishment.

Enjoy your day.
Libervurto
19
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th May 2009 13:04
Quote: "In terms of files you could be trying to read or right to a folder or drive that doesn't exist or you don't have permission to access."

Wrong write latch

Sorry to point that out like some grammar nerd when you are trying to give sound advice.
but uuuuh don't you know the difference between "right" and "write"! lol

I still like DBC, I'm planning to move onto GDK soon but I'll still use DBC all the time because it's so quick and fun and I still have a lot to learn, I've never used a DLL for instance!

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th May 2009 13:26
Look at this:
Quote: "writing outside of the bounds of the memblock. In terms of files you could be trying to read or right to a folder "

Guess I can't get write right even when I'm writing write in the same paragraph!

Enjoy your day.
Yodaman Jer
User Banned
Posted: 28th May 2009 19:39 Edited at: 28th May 2009 21:42
@Latch:

Thanks for the tips! I'm not using memblocks or attempting to read/write files, however I AM running the program from my external hard drive. All the media is on it, and I am using x files (they're properly formatted though...I think). The .bmp's were created with GIMP, but I've been using that for a year now without any problems. The only things I can think of that could be causing the crash are;

1)-Windows doesn't like me programming something on an external drive

2)-The x files are screwy and I should temporarily replace them with built-in primitives.

Both sounds pretty likely to me, actually. Thanks for pointing those things out, I'll definitely check them out and report back to you!

@Everyone:

I may still go with Pro after this. However, if I can write this game in its entirety in DBC I'll be sure to do so. I'm thinking about trying to use Sparky's dll later on, as I'm getting really tired of DBC's inaccurate (and weirdly glitched-out) native commands for collision. If all goes well, I could have this game done by the end of summer. I hope that's the case!

[EDIT]

I did what Latch suggested (replaced the x files with the built-in DBC primitives), and the level now resets itself perfectly! It's the Jewel model that I'm using that's giving me a hard time. I must have set something wrong when I exported it! No matter, I was thinking about replacing it with a different one anyway.

Thanks Latch!

[EDIT 2]

Upon further testing, I've found it's actually the imported platform models that are causing the crash. The Jewels aren't the culprit. I guess I'll just use other file types (.3DS) for loading models.


"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 28th May 2009 22:40
Quote: "I've never used a DLL for instance!
"


Really? you should they are very helpfull lol

look at some of the dbp plugins, as long as they don't use dbp stuff then they work in dbc.

Quote: "You could have badly formatted images. If you save a bitmap in photoshop, load it into MS Paint and resave it. Sometimes photoshop bitmaps can have a slightly different format that DBC won't like."


hm didn't know that! that could have run me into problems later. although if you have photoshop why would you use ms paint? hmmmm

New Site! Check it out \/
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th May 2009 00:04
Quote: "although if you have photoshop why would you use ms paint? hmmmm"

Simple, right to the point program, easy editing, text, shapes, transparency, and it will save to bmp format that is compatible with dbc 100% of the time. If you are doing any regular graphics manipulation, it's definately a tool to have in your arsenal. For the complex stuff use a more complex program. For simple editing, adding some text, filling in some color, resizing, it's small, fast, and perfect.

Enjoy your day.
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 29th May 2009 03:12
Ya i geuss that makes sense lol

New Site! Check it out \/

Login to post a reply

Server time is: 2025-08-08 20:33:37
Your offset time is: 2025-08-08 20:33:37