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 / can you help with scrolling inventory

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 25th Apr 2010 14:16 Edited at: 25th Apr 2010 14:50
Ok here's my thing, i have a setup wherein i can press a key to bring up an "inventory screen" now, on said screen there are 3 "slots" for item images, what i want to be able to do is put images (probably sprites) into those boxes but when you scroll to the first or last of the boxes the icons scroll left or right by one... does that make sense?
eg.

then you press right 3 times and it ends up like


*edit*
I just realised i posted this in the wrong place >.< sorry

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2010 15:18
Quote: "I just realised i posted this in the wrong place"


Where did you mean it to go? I can move it if you like.

As for your problem, it's quite simple - I had to do the same in Dark Sprites on the organizer screen. It displays a grid of 7x5 sprite frames but if you have say 50 frames, transport buttons scroll left and right through them one at a time.

What you do is have an ItemOffset variable which at first is set to 0 (zero).

When you place your sprite items (say they are sprites 100-200) 100 goes into the first slot, 101 into the second and so on.

What you do is use Sprite Number + ItemOffset.

When you cursor right, on the last slot, instead of moving further, you increase the value of ItemOffset until ItemOffset+6 is greater than the number of items you have to display.

When you cursor left, on the first slot, instead of moving further left, you decrease the value of ItemOffset until it's back to zero.

So, your item display would look something like:



TDK

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 25th Apr 2010 15:20
I meant to put it into DBpro Newcomers corner, Thanks though i'll try what you suggested

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2010 15:21
OK - moving it for you now.

TDK

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 25th Apr 2010 16:19
Right, OK maybe i'm not understanding how this thing works but i just can't get it to work for me properly, all my sprites just end up stacked on top of each other

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2010 19:40 Edited at: 25th Apr 2010 20:41
OK, you have a piece of code which puts the sprites in the six slots right?

If your item sprites are 100, 101, 102 and so on the loop placing the sprites would start by putting Sprite 100 in the first box, 102 in the second and so on.

All I'm suggesting is that with an offset variable, you would paste sprite 100+Offset and increment the offset when you scroll.

What code are you using for placing the (up to) six item sprites?

In the meantime, I'll knock together an example for you...

[Edit] Just noticed you only have 3 slots - I saw the two images in your first post and got it in my head you had 6 item slots!

[Edit 2] OK, here's an example for you. I've used the image you pasted above and modified it (attached to this post below).



It creates a number of dummy alphabet sprites as defined with NumItems = 26. Change this to a different number to match the number of items you have in the inventory.

ItemPanelX and ItemPanelY are the X and Y positions on the screen your item inventory panel needs to be positioned. Change these values to put the panel wherever you want on the screen.

Hope this points you in the right direction...

TDK

Attachments

Login to view attachments
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 25th Apr 2010 21:45 Edited at: 25th Apr 2010 22:10
this is the best i have managed so far but i hate the way it works, it's not as smooth as i'd like and one i get the cursor to the end of the 3 slots you have to HOLD right or left just to make it move to the next icon

Here is the code, and i'm hoping the other media is attached as a rar file... that is IF anyone wants to look at it



i know my coding is a mess but i am getting more and more annoyed and thus far this is the ONLY way i have managed to get roughlt what i am after

*Edit**
Ok thats perfect, that is exactly what i was after thank you, now my poor scalp may still have hair attached.

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.

Attachments

Login to view attachments
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 26th Apr 2010 10:47 Edited at: 26th Apr 2010 10:55
Ok so that Code you gave me was awesome! exactly what i needed it to do, but i can't seem to get it to work using my own images...
i figured that you'd replace

Ink RGB(Rnd(155)+100,Rnd(155)+100,Rnd(155)+100),0
Box 0,0,82,82
Ink 0,0: Text 22,10,Chr$(65+N)

with the images you wanted to use instead? given that i Understand that these lines create that "alphabet squares"

but when i load my own images eveythiung bunches up in the top left of the screen and does nothing, i'm a little confused

*Edit*
Nevermind I think I got it

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD

I can see from your smile, you're not here for the sunset.

Login to post a reply

Server time is: 2024-09-28 16:27:43
Your offset time is: 2024-09-28 16:27:43