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.

2D All the way! / Text Question and another question :)

Author
Message
Snafu
21
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 6th Jul 2004 02:46
Hello,

1. I'd like to write a little routine in which I can grab images from a set of letters that I've drawn myself and write this text on to the screen. Does anyone have any pointers on how I can go about doing this? If you could just point me in the direction of the right commands it would be appreciated, oh knowing ones

2. Is there a command to include source code from multiple .dba files? it'd be nice if i could stick all my sprite handling business in one file, all the sound stuff in another

3. Has pixel perfect sprite collision been implemented now? I can't find a change log

- Steve
Snafu
21
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 6th Jul 2004 07:56
answered question 2 on my own

it's #include

I see pixel perfect collision isn't in either

- Steve
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 6th Jul 2004 10:07 Edited at: 6th Jul 2004 10:08
#1 The easiest way is to place each individual letter into a grid say 16*16 or whatever size will allow you to fit all letters.
makes sure that the transparent color corresponds to whatever you choose to set in your program. by default it's black r,g,b 0,0,0. I prefer to use a bright pink rgb 255,0,255. You can set transparencey in your application by using:

set image colorkey 255,0,255
make sure this command is executed before any load image command


The commands you would then need is:
load image"text.bmp",imgnum,1
paste image imgnum,0,0,1


Now will need to get each individual letter and cut it out of the larger image, in a loop making sure to increment the proper spacing each loop.

pretend your image grid looked like this
tex.bmp
-----------------------------
| A | B | C | D | E | F | G |
-----------------------------
| H | I | J | K | L | M | N |
-----------------------------

You would need to but the get image in a loop:

for y=0 to 1
for x=0 to 6
get image newimgnum, (x*16)+1, (Y*16)+1, (x*16)+15, (y*16)+15
next x
next y


Note: you need to adjust the multiple depending on the size of your grid. the + 1 is to makesure you skip the gridline if you choose to include them (it helps to make sure the spacing is equal the + 15 alos needs to be adjusted accordingly).

It's up to you whether or not the images of the letters will be sprites or images. Also, you may decide to store them in a font array.

I don't want to give the entire thing away. But let me know if you need help in how to display the text by using an array.

Last tip. For certain words that are static and you know will be in the game like say "SCORE" it's easier to grab the entire text as an image and then display it using either the paste image command or sprite command.

Hope it helps.

~zen


zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 6th Jul 2004 10:16
Here's a Font image you can use to test with. It's not in a visible grid but it's equally spaced



~Zen


Snafu
21
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 6th Jul 2004 11:33
yeah, perhaps I should've been a little bit more specific with what I was asking. Sorry about that. most of the stuff you've said I'd already thought of - however, storing them in an array was something I'd not thought of and what a good idea that is.

I should really have added these questions:

1. Can someone point me at a command I can use to look at a particular part of a string? e.g something like the "inStr" comand in VB. Does that not exist? Is there code available that I can examine to figure out how to do it? I want to create my own functions so that actually writing the final product is pretty much like writing in QuakeC or something - that way I'll have created a framework for 2d games that I can just keep bolting things on to. so in this case I'll just do gametext("all your base",x,y).

2. This is probably really obvious, but I can't get my head around doing it in darkbasic... How the bloody hell do you convert an integer to a string? (yes, it is necessary)

Cheers,
- Steve
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 6th Jul 2004 12:07
Oops Sorry!
I'm still not exactly sure what you need but I'll try.

First of all there is the text "string",x,y
though that wouldn't be your own drawn fonts unless you actually install them to the windows system.

I'll read your reply again. To see if I can get my head around what it is you need to do.


as far as integer to string and other conversions we have:
ASC : Return Integer=ASC(String)
BIN$ : Return String=BIN$(Value)
CHR$ : Return String=CHR$(Value)
HEX$ : Return String=HEX$(Value)
LEFT$ : Return String=LEFT$(String,Value)
LEN : Return Integer=LEN(String)
LOWER$ : Return String=LOWER$(String)
MID$ : Return String=MID$(String,Value)
RIGHT$ : Return String=RIGHT$(String,Value)
STR$ : Return String=STR$(Value)
UPPER$ : Return String=UPPER$(String)
VAL : Return Float=VAL(String)
SPACE$ : Return String=SPACE$(Number of

other text commands include:
TEXT : TEXT X,Y,String
CENTER TEXT : CENTER TEXT X,Y,String
SET TEXT FONT : SET TEXT FONT Fontname
SET TEXT SIZE : SET TEXT SIZE Point size
SET TEXT OPAQUE : SET TEXT OPAQUE
SET TEXT TRANSPARENT : SET TEXT TRANSPARENT
SET TEXT TO NORMAL : SET TEXT TO NORMAL
SET TEXT TO ITALIC : SET TEXT TO ITALIC
SET TEXT TO BOLD : SET TEXT TO BOLD
SET TEXT TO BOLDITALIC : SET TEXT TO BOLDITALIC
PERFORM CHECKLIST FOR FONTS : PERFORM CHECKLIST FOR FONTS
TEXT BACKGROUND TYPE : Return Integer=TEXT BACKGROUND TYPE()
TEXT FONT$ : Return String=TEXT FONT$()
TEXT SIZE : Return Integer=TEXT SIZE()
TEXT STYLE : Return Integer=TEXT STYLE()
TEXT WIDTH : Return Integer=TEXT WIDTH(String)
TEXT HEIGHT : Return Integer=TEXT HEIGHT(String)

I'll have to check with IanM or RobK to see waht plugins they have.

You do want your own hand-drawn fonts as well?

Sorry if I'm not getting what you are asking, my mindis kind of hopped of on caffeine today...





Snafu
21
Years of Service
User Offline
Joined: 25th Jun 2003
Location:
Posted: 6th Jul 2004 12:12
hehehe, no - it's probably the fact that I'm not hopped off on caffeine and am extremely tired and stressed out today

here's what I mean. I've decided to make up my own commands too, which is sure to help your confused state!

string = "abcdefg"
result = lookat(string,5)

now, lookat(string,5) in this case will return what's in the string at position number 5.

then what I want to be able to do is find that character in a file and put the appropriate image/sprite on the screen.

I'm just not familiar with DB given that it keeps going wrong on me. (functions causing programs to bomb out?!)

- Steve
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 6th Jul 2004 12:29
I believ IanM or RobK has a function that does just that. But we still need to figure out why functions are bombing.

It's not happening on my system.


zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 6th Jul 2004 12:38 Edited at: 6th Jul 2004 22:29
OK, I was mistaken the .dll plugin for text was made by "The Coding Area" TCA
here is the link
http://www.codingarea.co.uk/html/dll_s___plug-ins.html
It's listed under string(2.0.0.0). I believe he coded in exactly what you are looking for.

<EDIT>
Quote: ""Only problem is, it seems his site is misdirecting downloads. I'll pose the question to him to see what's up?""


Actualy the only problem I was a moron. On TCA'site you have to right-click the link and save target as...
<End Edit>



Did you try toxics snippet yet?

Can't figure out why functions are bombing for you.

~Zen


Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 6th Jul 2004 17:10
You use Mid$ to check each letter in the string, and then put the sprite on the screen.

SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 8th Jul 2004 03:49
Basically, you pull each letter out at a time;

for x = 1 to len(a$)
V = asc(mid$(a$,x))
paste image letters(v), x*char_width, y
next x

This assumes you have grabbed the images of the letters into the array letters() and they match their ascii codes and char_width is the image size and Y is the line to print on. A$ is the string to print (of course.)

This help?
S.

Any truly great code should be indisguishable from magic.

Login to post a reply

Server time is: 2025-05-15 19:54:29
Your offset time is: 2025-05-15 19:54:29