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 / (DBC) object texture number

Author
Message
Sonic 91 Software
20
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 2nd Apr 2007 11:57 Edited at: 2nd Apr 2007 12:00
OK, this is probably simple. But I am having an off-day. (I know the answer is a simple one, otherwise I wouldn't be posting in this forum!) How can I check to see what texture number a certain object is using? I am making a very simple 2d game, in which blocks are textured randomly (using [rnd]) and each block does something to the player object, depending on what texture it has.

(i'm only making this game as a small side-project, I am taking a break from my other major projects)

"Fight the good fight of faith,
Lay hold on eternal life"
-1 Timothy 6:12
Comrade Robski
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 2nd Apr 2007 13:44
I'm not sure it is possible to obtain the texture number directly in DBC.

You could make an array and use it to store the texture number of each object at the point where it is textured, e.g.

Sonic 91 Software
20
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 2nd Apr 2007 16:33
thanks for that, that seems the way to go, however, how can i put that in a collision loop? I have tried this:




but that doesn't seem to work. neither does this:



do i need to "call" the array in any way?

"Fight the good fight of faith,
Lay hold on eternal life"
-1 Timothy 6:12
Crit
19
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 2nd Apr 2007 21:08
instead of and texture(a)=1 it should be and texture(o)=1
Sonic 91 Software
20
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 2nd Apr 2007 23:30
ok, changed it to "and texture(o)=1", now it says array accessed is out of bounds

"Fight the good fight of faith,
Lay hold on eternal life"
-1 Timothy 6:12
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 3rd Apr 2007 04:41 Edited at: 3rd Apr 2007 04:41
Quote: "ok, changed it to "and texture(o)=1", now it says array accessed is out of bounds"


That means that the For..Next loop counts to a number higher than the one used when you Dimensioned the array texture().

For example, if the loop counts to 9999 and you've used:

Dim texture(999)

then that's the error you will get. Maybe a tutorial on arrays might help?...

TDK_Man

Sonic 91 Software
20
Years of Service
User Offline
Joined: 19th Mar 2005
Location: In a Cryptic Crossworld!
Posted: 3rd Apr 2007 12:17
ok, i'm still slightly confused. i will check out the tutorial on arrays, but here is the problem i'm having (simplified):

i am making a small game where you have to collect different coloured blocks.

the number of blocks increases each level by 15.

i need the blocks to be textured randomly from a set of 13 textures, as each different coloured block reacts in a different way when collided with.

Quote: "OK, this is probably simple. But I am having an off-day. (I know the answer is a simple one, otherwise I wouldn't be posting in this forum!)"


either i was wrong, or i am right and completely stupid!

"Fight the good fight of faith,
Lay hold on eternal life"
-1 Timothy 6:12
Comrade Robski
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location:
Posted: 3rd Apr 2007 12:51
The problem is that you are asking for the value of texture(a) for values of a that are too large. If you use

DIM texture(10)

and then ask for the value of texture(11) then you will get an error.

In your code, you are asking for values of texture(a) from a=1 to 9999, and you haven't dimensioned the texture array to be that big.

Do you have 9999 objects? I'm guessing not. If your blocks are objects with numbers 1-100 (for example) then the following should work

Login to post a reply

Server time is: 2025-05-27 18:56:06
Your offset time is: 2025-05-27 18:56:06