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 / How do I set the text font?

Author
Message
Yodaman Jer
User Banned
Posted: 18th Oct 2007 23:17
I tried setting the text font this way



And this way



But it didn't work either way. Is there a different order or different way to type this up?
Sorry for my noobish post.
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 18th Oct 2007 23:21
Don't worry, this is an easy mistake to make.
Set text font only works in conjunction with the text command, not the print cammand.
You code should read:
Set Text Font 'Courier'
TEXT 0,0,"Hello World!"
do
loop


the rabi and Nancy DrewG

Yodaman Jer
User Banned
Posted: 18th Oct 2007 23:22 Edited at: 18th Oct 2007 23:30
That still doesn't seem to work. It's still giving me "Unknown Command" message at the bottom of the screen. I just got DB today, so I don't expect to be making games anytime soon, but I would like to create a 3D maze game as my first game. But I need to learn the basics first, and when I can't even get the text to work it's a little annoying. Maybe someone could give me a whole example of text?
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 18th Oct 2007 23:26 Edited at: 19th Oct 2007 19:04
Ooops, missed that one.

the rabi and Nancy DrewG

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Oct 2007 23:35
Ah, I think I made this mistake when I first started
I was gonna flame until I saw "PRINT" haha
Just a reminder: you always set general things (text etc) before you use them; when setting a specific entity (object/sprite etc), the entity must already exist.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Oct 2007 00:05 Edited at: 19th Oct 2007 00:05
Quote: "That still doesn't seem to work. It's still giving me "Unknown Command" message at the bottom of the screen."


INH accidentally put the font name in single quotes instead of double quotes. It should have said:



TDK_Man

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Oct 2007 02:44
Quote: "I would like to create a 3D maze game as my first game. But I need to learn the basics first, and when I can't even get the text to work it's a little annoying. Maybe someone could give me a whole example of text?"

make little games using the basics
Otherwise you'll get bored quickly

@INH
why the loop?
if you want to wait for the user to end the program, type WAIT KEY.
BUt the back of my mind is telling me that there is some sync problem with wait key if you minimise the program. meh

Yodaman Jer
User Banned
Posted: 19th Oct 2007 17:46 Edited at: 19th Oct 2007 17:47
Quote: "make little games using the basics "


It's only going to be one level, I just basically want to learn how to make backgrounds, collision detection, and control input.
Thank you all for your help!!
Yodaman Jer
User Banned
Posted: 19th Oct 2007 17:49 Edited at: 19th Oct 2007 17:56
TDK, thank you. I now can have simple text in the font I want...and I also discovered that changing the 0,0 to something like 50,50 re-positions the text. It saved me a lot of forum searching to the answer of that!
Thanks!

EDIT: New question.
How do I change the SIZE of the text?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Oct 2007 18:30
Believe it or not...

Set Text Size x



(Where x is the required size).

Don't forget you can press the F1 key at any time to get categorised help and a full index of commands.

TDK_Man

Yodaman Jer
User Banned
Posted: 19th Oct 2007 18:39
Ok. That simple? Thanks!
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Oct 2007 19:13
Quote: "I also discovered that changing the 0,0 to something like 50,50 re-positions the text."

You understand that this is a co-ordinate?
You are specifying the position of your text along the x and y axis of the screen (TEXT x,y,"hello"). 0,0 is the top left; X axis increases across and Y axis increases down.

Yodaman Jer
User Banned
Posted: 19th Oct 2007 19:26 Edited at: 19th Oct 2007 19:27
Yes, I know this from modeling in 3D a lot. I thought that maybe positioning text would be difficult, but I was wrong. Turned out that specifying things like that are pretty dang easy, compared to other codes that I've seen. I typed in some more code and was able to create a small text program, where it just was flashing and text was in front of it. I tried adding the wait key function, but can't figure out how to make it go to another area after that key is pressed. I'm thinking I use the GoTo Command and specify where to go to? Like the main menu? Right now I'm just messing around, not creating anything serious.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 19th Oct 2007 19:32
oooh don't mention goto again. TDK will be down on you like a tonne of bricks

What exactly do you want to do?

http://jamesmason01.googlepages.com/index.htm
Yodaman Jer
User Banned
Posted: 19th Oct 2007 19:57 Edited at: 19th Oct 2007 20:09
Really not that much. I was wondering if that was just the correct function to use.
Right now though, I want to know how to set the text color. I searched in the help and couldn't find anything that told me how to do that.
Here's my code:




Where in the text part would 'color' go, and how do I set it? I really cannot find anything on the subject.

REMEMBER: I understand that I can't make a big game, I'm just experimenting with code. So far, all I have is that displaying with an annoying flashing background, I will soon replace that with a picture of some sort after I learn about that.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 19th Oct 2007 20:27 Edited at: 19th Oct 2007 20:27
it's the ink command

that will change the ink color for anything you draw to the screen



The "rgb(255,0,0)" is a red-green-blue colour value. Here it changes the foreground colour.

The "0" after the comma is the background colour. I haven't found anything to use this for apart from with cls.

either value here could be an rgb value or just a numerical value. I only use numerical values for 0 (black) because I can't remember any of the others, but RGB is quite easy to use.

For RGB, you have a value between 0 and 255 for the amount of red, green and blue in the colour.

Here are some examples of how you could draw certain colours

RED: rgb(255,0,0)
YELLOW: rgb(255,255,0)
GREEN: rgb(0,255,0)
CYAN: rgb(0,255,255)
BLUE: rgb(0,0,255)
PURPLE: rgb(255,0,255)
WHITE: rgb(255,255,255)
PINK: rgb(255,180,180)
BLACK: rgb(0,0,0)





oh and if you want to get rid of that annoying flashing background, put CLS at the beginning. It's a glitch with some versions of DarkBASIC with some computers. It does it on mine.

http://jamesmason01.googlepages.com/index.htm
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Oct 2007 20:34 Edited at: 19th Oct 2007 20:47
The flashing screen is because you are setting the screen update to manual (SYNC ON) but you never tell DB when to update the screen (SYNC), this doesn't make sense to me as I would expect a blank screen but meh, that's how you fix it.

Help File: When you open the help file, go to the main menu and select COMMANDS MENU, this has categories for common command types, and TEXT is one of them, the command menu doesn't have every DBC command but a lot of useful ones.

Quote: "Where in the text part would 'color' go, and how do I set it?"

Like I said before: You always set general things (text etc) before you use them; when setting a specific entity (object/sprite etc), the entity must already exist. Think of it as readying your pen to write, you have to get the right colour ink and the right sized nib etc before you can write.
The command is INK [foreground color],[background color]
DB uses integers to describe colours, you can use the RGB([red],[green],[blue]) command to specify how much of rgb you want. What this command does is red*65536 + green*256 + blue
this may look strange but it is because DB sorts colours from 0 to 255 in each colour, the first 0-255 counts up only blue and 255 is equivalent to RGB(0,0,255), once it reaches 256 this is carried over to green and blue returns to 0: 256 = RGB(0,1,0), as the integer increases the carrying continues much in the same way as hundreds, tens and units in the decimal system.
White, the very brightest colour is equal to 65536*255 + 256*255 + 255 or RGB(255,255,255).
The background colour is only used if text is set to opaque, although it is also used as the colour for clearing the screen (CLS) unless you specify a colour when doing so.

I feel like I am rambling and being confusing so just ask if you have any questions.
Right, I'm off to play Star Wars Episode III

[edit]
@Demon ha you beat me

Another thing, RGB performs calculations to find a colour value, so using it repeatedly will slow down your program. A good idea is to specify colours before-hand, then you can just type in the variable name; it makes your code much easier to read too. eg


Yodaman Jer
User Banned
Posted: 20th Oct 2007 01:47 Edited at: 20th Oct 2007 01:50
Quote: "I feel like I am rambling and being confusing..."


Yes, just a tad confusing. I really can't figure out how to load a image or just get that flashing screen gone! Any ideas? I assume I do something like:





And then I'm at a loss on how to get it to be the background image..I tried looking in help but could only find how to load it.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Oct 2007 02:23 Edited at: 20th Oct 2007 02:24
Quote: "Load Image "Example". bmp"


Should be

Load Image "Example.bmp",1

where 1 is the image number you want to use. You can then use Paste Image to place it on the screen in a similar fashion to using the Text command.

You should do all your Load Image commands before you enter your main loop or it will be trying to load the image around 60 times a second!

If you haven't already seen them, take an hour or so to read tutorials 1 to 4 (and any others you feel are relevant) here:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Number 2 should answer your questions about your program jumping to other sections (without having to use the Goto command).

TDK_Man

Yodaman Jer
User Banned
Posted: 20th Oct 2007 04:05
Thanks TDK. YOU ROCK!!
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Oct 2007 17:32
@Yoda
Sorry dude, I was trying to explain that the RGB command is just a formula; colours are integers. It took me ages to understand that and I think it has helped.

Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 20th Oct 2007 20:26
Quote: "Thanks TDK. YOU ROCK!!"

Nothing new there, then.

the rabi, Nancy DrewG and Sudoku Arts.

Yodaman Jer
User Banned
Posted: 20th Oct 2007 20:49 Edited at: 20th Oct 2007 20:50
Quote: "Sorry dude, I was trying to explain that the RGB command is just a formula; colours are integers. It took me ages to understand that and I think it has helped."


I appreciate your help, Obese87. You helped explain a lot about that, and I did understand it a little, it was just a lot of numbers with * in the middle, which can be a little scary to a new programmer.
I've been flipping through the help files to try and figure out about the flashing screen, but still haven't a clue on how to get rid of it. You said it had something to do with SYNC: can you give me a little more information, or point me to a tutorial that will tell me what that means?
I apologize for my newbish posts, everybody.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Oct 2007 01:03 Edited at: 21st Oct 2007 01:30
You use SYNC to update the screen with whatever you have displayed since the previous SYNC (or the SYNC ON command).
Manual synchronisation is useful when there is a lot happening on screen: without it DB would try to update the screen after every action which slows down the program. By telling DB when "everything has been done" it can "relax" and just update all of it in one go.

Setting the SYNC RATE adjusts the refresh speed of your program. I still don't totally understand how SYNC RATE works because if you are setting the SYNC RATE why do you need to tell DB when to refresh? TDK can correct me on this but I think it acts as a cap to stop the program refreshing too quickly.
SYNC RATE speed goes from 1-1000 but 0 will set DB to refresh as fast as possible! It isn't good practice to use a rate of 0 though as your program would run at different speeds on different computers. The default rate is 30 (you don't have to set it).


___________________________________________________
RGB Values
A much simpler way of putting what I was trying to explain earlier is that red, green and blue are mixed together to make all colours in DB. To tell the colours apart when bundled into the same integer, DB uses a ratio.

The colour ratio is 65536:256:1 (red:green:blue), each colour unit is worth 256 units of the colour below: this is because colour brightness ranges from 0 to 255, and so just as with decimal numbers where the number after 9 is worth 1 of the value above (ten), with colours the number after 255 is worth 1 of the colour above (green).

All you really need to remember (and you don't really need to remember this ) is
65536 = 1 Red
256 = 1 Green
1 = 1 Blue

It can be useful to know how colour works when you are using it intensely in a program. Maybe you are creating a gradient from red to blue; so making DB calculate the green value every time when it is always 0 would be wasteful.

Here is my own RGB function so you can see the inner workings of colours for yourself


Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 21st Oct 2007 04:23
You don't need a function to convert RGB codes to variables, DB automatically does it for you. So your function could be like this insteaad:



how do you make a sig?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Oct 2007 09:28
The phrase "flashing screen" can mean a number of things in DBC...

Is the whole screen flashing on/off in black and white, or just the text?

Earlier versions of DBC had a bug which caused the screen to flash in XP, but was fixed in version 1.10. Unfortunately, the bug re-appeared in the new 2007 version and all my old programs started flashing again!

The new version 1.20 that Ron has been working on has been 're-fixed' and now doesn't flash again:

http://darkbasic.thegamecreators.com/?f=upgrades

If you haven't already, I recommend that you download and install that. Note that this will only work if you have the full version as the upgrades don't work with demo or trial versions.

If the problem is with flashing text, then post back as the solution is different depending on exactly what is causing it - we would need more info to help you.

TDK_Man

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st Oct 2007 15:41 Edited at: 21st Oct 2007 15:44
Quote: "You don't need a function to convert RGB codes to variables, DB automatically does it for you."

@Sinani
Yes, my function is exactly the same as the built-in RGB command, I was just using it to show what happens to the numbers.
DB doesn't "automatically" convert RGB values: it has to calculate them. I assume you knew this but I didn't like the word "automatically"

Yodaman Jer
User Banned
Posted: 21st Oct 2007 21:00 Edited at: 21st Oct 2007 21:12
Quote: " The phrase "flashing screen" can mean a number of things in DBC...Is the whole screen flashing on/off in black and white..."

Yep, it's only the background. The text is fine. I will try all of these things everyone has told me about--thanks all!!

EDIT--

Ok, the flashing screen is gone, thanks to the rgb function, but now the text doesn't appear...here's the code.




Again, sorry for my noobish questions, everyone.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 21st Oct 2007 21:14
That end there finishes the programme.

Therefore the code stops before it gets to the "Set Text Font" line

Use End at the end of the programme, and functions after that.

The reason the flashing screen goes is that the glitch in some versions of DarkBASIC requires you to clear the screen

And you know you can just do



http://jamesmason01.googlepages.com/index.htm
Yodaman Jer
User Banned
Posted: 21st Oct 2007 21:18 Edited at: 22nd Oct 2007 00:48
Oh...whoops. Thanks!


EDIT: Perfect! It works, thank you everyone. Now, I will learn about building menus from TDKs tutorial...and download that update just to avoid more posts in the future.

EDIT EDIT: I just built a menu..without building a menu.
I just did a bunch of text-based things, like this. Anyone who's curious can copy/paste into their editor.
WARNING: The sphere is uncontrollable as of now. I'm Looking into storing the object angle and getting everything moving however. BTW, the sphere is not the actual character, I just used it because I don't know how to do that yet. Here's the code:



This is not the final game code...all that is secret. I just thought I'd give this to you as a preview of what I will do, with everyones help and advice.
I've only known you all for about a week, but you guys already feel
like family. Thanks!
Yodaman Jer
User Banned
Posted: 22nd Oct 2007 02:21


I can't seem to get the matrix height to work. I've read the part in the help file about this so many times, trying to figure out what's wrong, all to no avail. What am I doing wrong?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Oct 2007 07:14
You appear to be missing one thing - Update Matrix!

Anything else you need to know about them, it's tutorial number 9...

TDK_Man

Yodaman Jer
User Banned
Posted: 22nd Oct 2007 18:01
Ok..thanks!
But now I have a Collision detection problem. I tried out your tutorial, but couldn't get it to work. Here's my code, I modified it so it didn't change colors, however:


What's wrong?

Login to post a reply

Server time is: 2025-05-31 20:50:56
Your offset time is: 2025-05-31 20:50:56