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 / a few basic noob questions i cant seem to find the answers to.

Author
Message
Diablos
18
Years of Service
User Offline
Joined: 15th Oct 2005
Location: meh?
Posted: 4th Jan 2006 20:49
1. how do i paste pictures onto the screen? and how do i set the size and place?

2. how do i resize the text? and how do i change the text colour?

3. how do i use the 'if, else' function properly?

4. and finally, how do i set music to play and loop?

thanks. im almost able to program my own text adventures!! a good start i think.

wooop

-Pain is temporary, pride is forever.
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 4th Jan 2006 21:28 Edited at: 4th Jan 2006 21:36
Okay okay, i guess you will need a good grounding on these topics so here we go.

Functions : Load Image, Paste Image.
Now to paste a picture onto the screen darkbasic must 'get' the picture. In a program you must first have darkbasic aknowladge the pictures existance before you can actually tell darkbasic to put it on the screen. Thats where load image comes in.
--Load Image Image,Number----
Image - This is where you image is, you have to use a string (the things with " at the front and at the back), an example : "C:Myimage.jpg"
-Number - once you have told darkbasic where the image is, you have to give that image a number. This is how darkbasic remembers the image. So to put the image on the screen you have to give darkbasic the number you assigned the image to. You can choose any number (ex. 1,2,3)
There are more options with the command Load image, i have just covered the nessceities.

Now once we have loaded the image, we have to paste it on the screen, this is done by the command 'Paste Image'
--Paste Image Number,X,Y---
Image Number - The number that darkbasic has referanced the image by (when you did load image)
-X - X position to put the image
Y- Y position to put the image

EXAMPLE CODE--
sync on
sync rate 30
Input "Choose an Image to Load",Image$
Load Image Image$,1
do
Paste Image 1,(Screen Width()/2)-I,Screen Height()/2
loop
---End Code--
I have used a few tricks in the example code,
first of all i let the user pick the image and stored it in Image$ variable. Now if the user inputted "DAIMAGE", then you would get an error because you are missing the tag at the end (jpg, bmp, etc), also if the user inputted (DAIMAGE.JPG), the image HAS to be in the same folder as the exe for DBP to find it. You can use (dir) to move around folders, try figuring out how to do that. A simple (but boring) way to do it is to tell the computer where exactly it is (C:\daimage.jpg).
Now when i do load image, I have it load the Image$ that contains where the users image is. (You can use file exist to make sure that the image really exists).

In paste image, i have the computer paste our loaded image right in the ceneter of the screen, the only problem with this is that darkbasic "holds" the image by the edges, so if darkbasic were to paste the image, it would paste the top left corner of the image at the center of the screen (use sprite and offset image to make a work around)



I hope it helps


around here.. normal's just a setting on a hair dryer
Big Man
19
Years of Service
User Offline
Joined: 4th Feb 2005
Location: BEHIND YOU!!!! (but I live in England)
Posted: 4th Jan 2006 21:35 Edited at: 4th Jan 2006 21:36
Hi
answers

1)


2)

to set the colour first you have to set the colour variable
then


3)


4) first load the music



hope this helped.
Anything you dont understand tell me.

BM

Our aim is to keep the loo's clean, your aim can help.
crighton
18
Years of Service
User Offline
Joined: 5th Nov 2005
Location: In your soup.
Posted: 5th Jan 2006 02:32
Quote: "how do i paste pictures onto the screen? and how do i set the size and place?"


resizing i use sprites.



2. how do i resize the text? and how do i change the text colour?




3. how do i use the 'if, else' function properly?
as Big Man said


4. and finally, how do i set music to play and loop?


and/or






aye!
Diablos
18
Years of Service
User Offline
Joined: 15th Oct 2005
Location: meh?
Posted: 5th Jan 2006 18:18 Edited at: 5th Jan 2006 20:43
thanks

oh one more thing... how do you change the size of the picture? do you have to save both a big size and a small size if you want to put both in? or is there a way to resize the pictures within dark basic?

-Pain is temporary, pride is forever.
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 5th Jan 2006 23:30 Edited at: 5th Jan 2006 23:32
EDITOPS, just realized crighton used sprites above to explain re-sizing, oh well if you didnt understand it, read this...


Re-sizing is there, but it will get a bit pixilated. To do this you must first make the picture a sprite (ooh new word)

Sprites ---

Sprites are basically a more powerfull form of images. Once a picture is attached to a sprite, you can do allot more stuff (notice there is a whole section on sprites?). Once you have your image loaded (you dont have to paste it on the screen), you can make it a sprite, with the command (sprite).
--Sprite NUM,X,Y,IMG
NUM - Just like image numbers, sprites need a number to. Once you have made a sprite, to do anything with this sprite, you have to use the sprite number. (The Same image can be used in multiple sprites)
X- The X position to display your sprite
Y- The Y position to display your sprite
IMG- The number of the image that the sprite uses. (SEE my first post)
---
Once you have sprited an image you can use (SCALE Sprite) to make it bigger or smaller.
--Scale Sprite NUM,Scale
NUM - The sprite number that you want to scale (assigned with the sprite command)
Scale - The amount of scaling you want to do (100 keeps it at the same size, 50, decreases it by 50 %,150 makes it 50% larger)
---

There are many more uses of sprites (offset sprite), but i will leave you do discover those on your own

hope it helps
Zedane

P.S. dont you just love how this stuff builds on each other.


around here.. normal's just a setting on a hair dryer
Diablos
18
Years of Service
User Offline
Joined: 15th Oct 2005
Location: meh?
Posted: 6th Jan 2006 17:13 Edited at: 7th Jan 2006 01:21
ahh thanks i appreciate it

EDIT: sorry while i have the topic going, how do you print text in a specific chosen area on the screen?

i think thats the last of my questions.

-Pain is temporary, pride is forever.
Hippie Dude
19
Years of Service
User Offline
Joined: 6th Feb 2005
Location: California, United States
Posted: 7th Jan 2006 01:34
you can do this:


Mysteries Surround You
Diablos
18
Years of Service
User Offline
Joined: 15th Oct 2005
Location: meh?
Posted: 7th Jan 2006 01:46
thanks

-Pain is temporary, pride is forever.
crighton
18
Years of Service
User Offline
Joined: 5th Nov 2005
Location: In your soup.
Posted: 7th Jan 2006 04:08
or, my favourite


aye!
TKsFox
18
Years of Service
User Offline
Joined: 25th Nov 2005
Location: No no no - Its not the Cyberspace
Posted: 8th Jan 2006 11:33
For text use the d3d dll

It's me...
Diablos
18
Years of Service
User Offline
Joined: 15th Oct 2005
Location: meh?
Posted: 10th Jan 2006 13:36
thanks for everyones help so far, but i need another question answered and i should be ok. sorry!

i have no idea how to word this but hopefully you will catch my drift...
how do i change the value in a stored item?

for example if i typed in 'value=20' how would i change that to 'value=100' within the code without bringing up an error message?

-Pain is temporary, pride is forever.
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 10th Jan 2006 13:44
value = 100

Why doesn't this work?


Hippopotomonstrosesquippedaliophobia-Fear of long words
Diablos
18
Years of Service
User Offline
Joined: 15th Oct 2005
Location: meh?
Posted: 10th Jan 2006 13:58
i kind of assumed it wouldnt, as you had already assigned a value to it. of course i never thought to try it out.

ignore that question lmao.

-Pain is temporary, pride is forever.
Diablos
18
Years of Service
User Offline
Joined: 15th Oct 2005
Location: meh?
Posted: 10th Jan 2006 15:21
ok now i have a problem. whenever i put in an image the screen resolution goes down. i have a column of text on the left hand side and i want a picture on the right, but whenever i insert a picture everything messes up.

any ideas?

-Pain is temporary, pride is forever.

Login to post a reply

Server time is: 2024-09-24 13:23:08
Your offset time is: 2024-09-24 13:23:08