Inventory system

Non-platform specific questions.

Inventory system

Postby MrJolteon » Sat Sep 22, 2012 7:11 pm

I need an inventory system in my game, and I want it to be similar to, if not the same as, the one in Submachine 6.
However, I don't know how to do that. I'd appreciate it if anyone could help me.

If you need any more information, like what items I'm going to add, send me a PM.
And also, I know that I need to use arrays. I just have no idea how.

Thanks in advance.
-Jolt
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Inventory system

Postby MrJolteon » Sat Sep 29, 2012 6:03 pm

Bump.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Inventory system

Postby skydereign » Sat Sep 29, 2012 6:07 pm

If you detail the actual mechanics that you want, I can help setup the inventory.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Inventory system

Postby MrJolteon » Sat Sep 29, 2012 6:24 pm

1: Inventory is shown at the bottom of the screen (I can probably do that myself)
Image
2: When mouse is hovered over inventory, show item name. (Don't need them floating up. Shouldn't be too hard, even for me.)
Image
3: When clicked, make item follow the mouse, and leave a transparent image behind. When this is clicked, place item back in inventory.
Image
4: When used in correct place, remove item and transparent image from inventory, and move the other items towards the center of the inventory (Optional).
Image
5: Pickups are shown in game environment.
Image
6: When pickup is clicked, add item to inventory, remove pickup.
Image
7: I also want an item to be in the inventory when the game starts.
(No screenshot available.)

Take your time.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Inventory system

Postby Fojam » Sun Sep 30, 2012 3:47 pm

probably using an array for that would be best. And nice graphics btw
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: Inventory system

Postby MrJolteon » Sun Sep 30, 2012 4:09 pm

Fojam wrote:probably using an array for that would be best.

That's exactly what I said in the original post.
And nice graphics btw

Those are screenshots from Submachine 6, by Mateusz Skutnik.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Inventory system

Postby schnellboot » Tue Oct 02, 2012 9:44 pm

how do you drop the picked up item back into the inv?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Inventory system

Postby skydereign » Tue Oct 02, 2012 10:02 pm

By clicking the transparent item left behind when you choose the item in your inventory. Are you making a demo for MrJolteon? If so I won't bother making one.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Inventory system

Postby schnellboot » Tue Oct 02, 2012 10:06 pm

I didn't start yet, but I think yours will be more efficient anyway so I will let you make one.
If you're busy I make it.
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Inventory system

Postby skydereign » Tue Oct 02, 2012 11:11 pm

Well, here's a quick version I made in class. It has plenty of room for improvement though. It currently is rather messy, since it only uses one actor to handle all items and item displays, and I hadn't worked out a uniform system beforehand. But this was just the proof of concept. And since schnellboot was offering to make one, I thought I'd post it, perhaps for some inspiration. I won't be able to fix this ged up for a couple of days, so if you want to schnellboot, go ahead and make your own, or work from this one.
Attachments
inv.zip
(6.96 KiB) Downloaded 116 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Inventory system

Postby MrJolteon » Tue Oct 09, 2012 10:50 am

Bump.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Inventory system

Postby MrJolteon » Sun Oct 28, 2012 4:58 pm

I'll just use the one Sky made.
I just have a question about it; How do I make the items not line up in a 3x[y] grid? I want them lined up horizontally.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Inventory system

Postby skydereign » Sun Oct 28, 2012 9:21 pm

Replace the global code with this. The changes were just the positioning on lines 35, 40, and 41. Before it was using division and modulus to break it into rows of three, now it doesn't.
Code: Select all
#define MAX_INV 9
int inv[MAX_INV] = {0};
int cur_item = -1;
int cur_type = -1;

void
inv_clear ()
{
    int i;
 
    for(i=0;i<MAX_INV;i++)
    {
        inv[i]=-1;
    }
}

#define ITEM_CREATE 0
#define ITEM_MOVE 1

int
inv_add (int type, int action)
{
    int i;
 
    for(i=0;i<MAX_INV;i++)
    {
        if(inv[i]==-1) // empty
        {
            inv[i] = type;
            cur_type = type;
            switch(action)
            {
                case ITEM_CREATE:
                CreateActor("item", "ricon", "view", "(none)",
                        view.width/2-60+i*60, view.height*2/3, true)->inv_pos = i;
                break;
 
                case ITEM_MOVE:
                ChangeParent("Event Actor", "view");
                xscreen = view.width/2-60+i*60;
                yscreen = view.height*2/3;
                inv_pos = i;
                break;
            }
            cur_type = -1;
            return 1;
        }
    }
    return 0;
}

void
inv_remove (int idx)
{
    inv[idx] = -1;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Inventory system

Postby MrJolteon » Mon Oct 29, 2012 6:15 am

Alright, thanks.
+1
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Inventory system

Postby MrJolteon » Mon Oct 29, 2012 6:35 am

One more question,
I added the script to my game, but now items won't move anywhere at all. How do I fix this?
My game's screen resolution is 480x640, in case that's needed.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron