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 / Simple Variable Question.

Author
Message
Brent_Seraphim
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: United States
Posted: 11th Feb 2003 03:57
Ok, I've currently gotten stuck on a part of my inventory system. Ok lets say I have 50 variables:

Item1 = 1
Item2 = 2
Item3 = 3
Item4 = 6
Item5 = 7
Item6 = O
.... on to Item50 = 0 The values don't really matter.


Ok now lets say each one is assigned a sprite that corispondes to its number. Like:

Rem == Sprite for Item1
Sprite 1 , Item1x, Item1y, 1

Ok Once I put my cursor over the sprite I search for collisions like this:


MX = MouseX()
MY = MouseY()
MouseInput = MouseClick()
Temp_Number = 1

If MouseInput = 1

FOR Temp_Number =1 TO 54 STEP 1
SpriteCollision = SPRITE COLLISION( 95, Temp_Number)
If SpriteCollision = 1
Item_Activated_n_ = Temp_Number
Goto ItemSelected
EndIf
Next Temp_Number

EndIF

Were Item_Activated_n_ equals the number of the item I clicked. Because the Sprite number and the Item(Number) are the same. Ok after I've moved the sprite where I want it,
how could I Change the value of the activated Item(what ever it may be) without have to do something of this sort:

If Item_Activated_n_ = 1
Item1= "Whatever"
EndIF

If Item_Activated_n_ = 2
Item2= "Whatever"
Endif

If Item_Activated_N_ = 3
Item3 = "Whatever"
Endif


on and on to ...

If Item_Activated_n_ = 50
Item50 = "Whatever"

? Is there a shortway than the way I have write above? I know DBP is full of wonderfully powerful code, however I'm not that familiar with the language(not programming...the language). Could someone help? Sorry if this wasnt clear enough.
"Laugh to scorn the power of man..."
Hockey07
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: United States
Posted: 11th Feb 2003 04:31
Yes. You can do something like this. Trust me, this code is just a little example and it wont work if you use this one that I'm typing now:

For n = 1 to 50
if n = whatever then next n

And it will go a little like that, I think. Ask others who have used this in their games. But I am just trying to help ya out! cya!

Current Project: Dark Wars
166 lines of code so far
http://hometown.aol.com/Hockeycow07/rebel.html - The official ReBel Games website!
Brent_Seraphim
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: United States
Posted: 11th Feb 2003 04:51
Ok no offense, and I thank you for your quick respones...but how exactly does that help me? That puts me in the same boat...checking every value of N... However I think I may have figured it out...

Thanks Again...u made me reconsider my code, thanks.

"Laugh to scorn the power of man..."
Hockey07
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: United States
Posted: 11th Feb 2003 04:58
Your welcome.. See, I can be useful even in my information is invalid!

Current Project: Dark Wars
166 lines of code so far
http://hometown.aol.com/Hockeycow07/rebel.html - The official ReBel Games website!
Hockey07
21
Years of Service
User Offline
Joined: 18th Dec 2002
Location: United States
Posted: 11th Feb 2003 04:59
I hate having no editing button.. Same with a search button..

What I meant was

"See, I can be useful even IF my information is invalid! "

Current Project: Dark Wars
166 lines of code so far
http://hometown.aol.com/Hockeycow07/rebel.html - The official ReBel Games website!

Login to post a reply

Server time is: 2024-09-19 03:12:32
Your offset time is: 2024-09-19 03:12:32