Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411656 Posts in 69395 Topics- by 58451 Members - Latest Member: Monkey Nuts

May 15, 2024, 05:00:55 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Trying to design an item system in Game maker.
Pages: [1]
Print
Author Topic: Trying to design an item system in Game maker.  (Read 2555 times)
PureQuestion
Level 4
****



View Profile
« on: June 07, 2010, 11:49:19 AM »

So. I'm trying to design a type of Roguelike.

The problem is that it's very complex, and I've never made one before. So if anyone has any suggestions, it has to do all the following:

Items can be stored in inventories of individual beings.
Items need to have individual stats.


All I can think of at the moment. Anyone have any good systems for it?
Logged

AlexMdle
Level 0
***


Keep Your Dignity


View Profile WWW
« Reply #1 on: June 07, 2010, 11:58:58 AM »

Well, to specify, think Diablo 2 item generation. Weapons may have suffixes and prefixes and in general have their stats slightly randomized, so even if you find another "Long Sword" it may well differ from the one you picked before.

Required is some way to track those stats for each piece of armor and weapon and probably some kind of array to store ID of each weapon in, which then contains the attributes.
Logged
st33d
Guest
« Reply #2 on: June 07, 2010, 12:24:22 PM »

Try using an existing library.

http://roguebasin.roguelikedevelopment.org/index.php?title=Doryen_library

I'm sure there's more on roguebasin. Plus Python is quite a nice easy language to get your head around.
Logged
PureQuestion
Level 4
****



View Profile
« Reply #3 on: June 07, 2010, 01:07:44 PM »

Thanks, but again, doing this in Game Maker. Doesn't seem to be compatible.
Logged

oahda
Level 10
*****



View Profile
« Reply #4 on: June 07, 2010, 11:56:09 PM »

Game Maker is object-oriented. Take advantage of this fact.
In general, two main classes (in Game Maker called objects) should be enough; Inventory and Item.
Inventory will be a class actually containing items, and Item will be a superclass to derive any individual types of items from.

The Inventory class should contain functionality for drawing the inventory and manipulating it in any way the user should be allowed to.
This might include deleting items or putting them in a different order, and hovering over them to see a description.

The Item class could be pretty simple to begin with.
Assign it a few variables; title, description, attack, defense and level, for example, depending on what you want.
Another handy property would be a variable containing the allowed amount of items of a certain kind to stack in one inventory slot.
The sprite of each item should be the icon to display in the inventory. The base class Item needs no sprite.

As you want to create new types of items, derive them from the original Item class, setting it as its parent, and assign a sprite.
Then set the proper values for the variables you previously declared in the base class; you even have the opportunity of randomisation, as previously suggested.

Now, move back to the Inventory class. This class should contain an array, in which items are to be put.
When drawing the inventory, loop through the elements of this array, and properly place them into the inventory grid, retrieving the sprite member variable from each item.
If you have decided for item stacking to be present, also print out the amount of items in the current stack in the loop; this should also be handled by an array in the Inventory class.

Now check the position of the mouse. If it's hovering over one of the icons (do a simple rectangle check), draw a box displaying the title, description, required level and anything else you want in there, also retrieved from the member variables of the instance in the current index of the array in your iteration.
If you've discovered that the mouse is hovering over the icon, you also want to check for clicks for interaction; a left click might do one thing with the item, and a right click might do another thing. If the icons should be able to be moved around, holding down the mouse should obviously allow you to drag this icon around until the mouse is released, and something else should happen depending on where the player decided to let go of the mouse button.

I hope this can point you in the right direction and shed some light upon your confusion.
Logged

PureQuestion
Level 4
****



View Profile
« Reply #5 on: June 08, 2010, 01:18:45 PM »

That's really helpful, actually.
Logged

oahda
Level 10
*****



View Profile
« Reply #6 on: June 08, 2010, 10:27:08 PM »

I'm glad to be able to help.
How's it working out for you? Have you tried anything yet?
Logged

PureQuestion
Level 4
****



View Profile
« Reply #7 on: June 09, 2010, 03:01:09 PM »

Nope. Been kind of busy. I'll probably work on implementing come the weekend.
Logged

oahda
Level 10
*****



View Profile
« Reply #8 on: June 10, 2010, 06:45:53 AM »

Be sure to let us know how it goes. Good luck!
Logged

lasttea999
Level 2
**


View Profile
« Reply #9 on: June 10, 2010, 09:43:37 AM »

Do you know how to use arrays and data structures? They're really useful for that kind of thing.

Note: for anything that has to be saved in an external file, you'll probably want to use data structures instead of arrays.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic