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 / i need help on this one.....

Author
Message
kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 20th Aug 2005 16:11
hi

with help from sven B i have put togather a RPG scroll box for items c/f final fantasy series style. but im not sure how the best way to select an item from it would be. any ideas or suggestions would be great

thanks

kR



kR
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 20th Aug 2005 17:44
Instead of using
text posx + 5, posy + texty, string$(data)
use a function:


the function:


Immunity and Annihalation makes Immunihalation...
kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 20th Aug 2005 20:24
i cant get those commands to print the words onto the screen, just wipes everything apart from the box. here is how ive compiled it




kR
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Aug 2005 21:54
You can't actually fill string arrays with a For..Next loop in the way that you are attempting. It doesn't work like that.

All you are doing is manually filling the array, but 5 times!

To actually use a For Next loop, you need to use the loop variable somewhere. Eg:



The problem is getting the correct thing into a$ - otherwise each element of the array would contain the same thing.

This is where Data statements come in. Using:

Data "Potion", "H-Potion", "S-Potion", "Pheonix Tear", "Elixer"

you can read each item in for a$ ready to feed into the array as follows:



When you increase the number of data items, you increase the variable items to match.

Your code needs a bit more study before suggesting a fix for your main problem, so I'll take a look and get back.

TDK_Man

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Aug 2005 22:15
OK - here's what to do to solve your item select problem...



When you move the mouse over the box, the item under the mouse is displayed top left corner of the screen.

Click and hold the mouse and the selected item is displayed just below the box.

TDK_Man

kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 20th Aug 2005 22:16
this is what i have now, but i am clueless as to why nothing is being printed to the screen. the text command is calling the data but its not happening and i cannot work out y this is happening



kR
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Aug 2005 23:53
Doh!

I've given you the code to do that - why didn't you use it!??

And also, don't use reserved words for variables. Data is a reserved word - that's why I changed it in my code. You don't seem to have looked at what I posted at all.

I suggest that you look at the code I supplied and figure out what it's doing. If you don't follow anything just ask!

If you just copy and paste without understanding what you have been shown, then you aren't learning anything and you will be no better off.

TDK_Man

kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 21st Aug 2005 00:37 Edited at: 21st Aug 2005 01:14
i thionk we posted at the same time as ur post wasnt originall ythere lol

sorry ill check ur code

edit:

OverItem = (My-posy)/18+1

if this line why is it dived by 18? i dont really understand how the overitem part works. if u could explain that that would be great

thanks a lot for helpin

kR
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 21st Aug 2005 01:39
NP!

When your mouse is over the box containing the items, you deduct the Y position of the top of the box, which results in the Y position *within* the box (rather than from the top left corner of the screen). This means that if you place the box somewhere else on the screen, the code will still work OK!

Each line of text takes up 18 vertical pixels, so if you divide the Y mouse position within the box by 18 it will return the number of text lines down the box you are. It's a zero-based result and as your array is 1-based we have to add 1 onto the result to compensate.

This is a quick and easy way to locate what item in a text list has been clicked on.

I guess it worked for you then?

TDK_Man

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Aug 2005 10:54 Edited at: 21st Aug 2005 10:57
Or this way:



Also a quick way to test what item is clicked on...

or this is just an idea I got. (Nothing special though)



Immunity and Annihalation makes Immunihalation...
kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 21st Aug 2005 17:15 Edited at: 21st Aug 2005 17:17
LOL very nice i like the flashing words, how did u get them to do that?? im rubbish and cant make it out. very nice bit fo code there

edit:

hoorah i know understand how that all works now exept the flashy part

thanks a lot guys

kR
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Aug 2005 20:49 Edited at: 21st Aug 2005 20:50
My code:


ZOOM IN:



ZOOM IN:



3 lines that make that flashy thingy

Immunity and Annihalation makes Immunihalation...
kRx
20
Years of Service
User Offline
Joined: 2nd Apr 2005
Location: Canterbury, Kent, UK
Posted: 21st Aug 2005 20:57
o right i understand it now thanks

kR

kR
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Aug 2005 21:04
Keep it up!
Good luck with your RPG...

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2025-05-22 13:18:56
Your offset time is: 2025-05-22 13:18:56