Preparing our items system
If you’ve been keeping track of our design document from earlier at all, you may have noticed that we are starting to come close to finishing our game. There are still a few features left to refine and tweak, and a few more left to implement – but we’re getting closer. Today, we’ll be laying the groundwork for our items and inventory system – and on monday, we’ll dig into actually implementing it.
Because we want to be able to perform whatever actions we want on a player, we’re going to need a way to flag our items – to say “this is a healing potion”, “this item teleports the user”, and so on. To that end, we’ll add another stat to our stats table:
INSERT INTO stats(display_name,short_name) VALUES ('Item Use Token','token');
We will be using the value of the ‘token’ stat on our items to determine what exactly we should be doing with our items when we use them.
We will also need to add another table to our database – to keep track of the items in the player’s inventory. We’ll create user_items like so:
CREATE TABLE user_items ( id int NOT NULL AUTO_INCREMENT, user_id int NOT NULL, item_id int NOT NULL, quantity int NOT NULL DEFAULT 0, PRIMARY KEY(id) );
And with that finished, we’re all set! All we’ve got to do is write the code, now – which we’ll do on monday. See you then!
Luke is the primary editor of Building Browsergames, and has written a large portion of the articles that you read here. He generally has no idea what to say when asked to write about himself in the third person.
-
Devin
-
Luke
-
spatlabor
-
Luke
-
Dan Alex

