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 / load image use in function error

Author
Message
HomerS
16
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 11th May 2014 01:20
Hello,

Simple question.

At the beginning of the program i use 'load image "tree",100'.

At the bottom i have the function:



Now the error comes that the image does not exists.

When i put the load image in the function it works perfect.

How can i do it, without loading the image every time (like 10000 trees, one time seems to be enough?). Is this possible?

greetings!

Toedeledoki
HomerS
16
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 11th May 2014 01:23
Its a direct link, i used the notice in the mail with the link.

Tnx for the help and greetings!


Toedeledoki
HomerS
16
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 11th May 2014 01:24
Can someone delete my last answer? i put it wrong sorry...

Toedeledoki
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 11th May 2014 03:53
I see you did not put the filename extension in your command when you load the image. You would need to include that or it won't work. Since you are hard-coding the image number as 100, it should work fine within the function. I wrote up some quick sample code just to test this and it works fine. Take a look at this:



Also, in your function call, you do not list the required size of the plain (sic). In my example, I simply chose a width of 5 and height of 10. By the way, I spent like 15 seconds making the tree, it is only for an example and I really am not a 3 year old with crayons

I have included the .dba code and the image I made in the attached file.

So many games to code.....so little time.

Attachments

Login to view attachments
HomerS
16
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 12th May 2014 23:49
Yes i used .bmp in the tree.bmp file load.


Your code worked well here.

Here is my (error) code...


This code does not work.

If I put load image from the top of the code into Function make_a_tree(id,x,y,px,pz) etc
it will load and work well (i removed "rem" it then from the beginning).

I don't know what is wrong.

Toedeledoki
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 13th May 2014 02:45
In your code, you call the make_a_tree function before you define image 100. If you move the "load image "tree.bmp",100" code to the line before the make_a_tree function call, it should run okay.

So many games to code.....so little time.
HomerS
16
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 13th May 2014 20:01
Tnx!

That is logic, lol.

Stupid of me that I didn't see that.

Now it works fine.

I think I take a rest. hehe

Toedeledoki

Login to post a reply

Server time is: 2024-03-29 11:04:44
Your offset time is: 2024-03-29 11:04:44