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 / changing texture hlep

Author
Message
emlyn
17
Years of Service
User Offline
Joined: 22nd Oct 2007
Location:
Posted: 22nd Oct 2007 22:42
I'm in a class using Dark Basic. I'm editing the Carbonade game with the cirriculum. I'm trying to change the texture on a object when the score increases. Here is the code I've written.


for t = 1 to NumberOfFruits : rem If I hit one of the little fruits
if Object collision(1,t + NumberOfFruits)>0
play sound 4
delete object t + NumberOfFruits
MyScore = MyScore + 100 : rem How many points each little fruit is worth
if MyScore = 300*tex#
texture object 1,num#
tex#= text#+1
num#= num#+1
endif
endIf
next t
num# is the ID of the textures.
This will load the first textures but not the rest. Please help.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Oct 2007 04:11
Looks like you have a typo:

tex#= text#+1
should it be tex#=tex#+1 ?

Currently it would prevent

if MyScore = 300*tex#
from behaving as you expect.

Enjoy your day.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Oct 2007 18:52 Edited at: 23rd Oct 2007 18:56
How come I didn't get to use DB when I was at school?
when you post code can you please put it in a code box using the tags
Quote: "

Oops! didn't know you could do that use [co de] [/co de] without the space. Only use code boxes when it will ACTUALLY SAVE SPACE though, Latch hasn't used one as his snippets were only 1 line long."


You can increment a variable by using INC.
inc tex,1
tex can be an integer (adding # to the end makes it a float and takes up more memory)


Are you aware that this will delete the object after the max number of fruits ie


emlyn
17
Years of Service
User Offline
Joined: 22nd Oct 2007
Location:
Posted: 26th Oct 2007 21:55
Thank you for noticing the typo. Sorry about the code, this is the first time I've used something like that. You were right, once I changed to tex# and num# to tex and num it worked. Thank you for your help.

Login to post a reply

Server time is: 2025-05-31 20:46:10
Your offset time is: 2025-05-31 20:46:10