Home > Development Diary, Game Design, Game Maker 8 > The Spire – Game Dev Diary 2

The Spire – Game Dev Diary 2

Figured almost a month has gone by and I’ve had the chance to work on this project a bit in between class work and job hunting, so here we go.

theSpire_2013_04_10

I’ve actually made a decent amount of progress, both in visuals and mechanics.

  • Added Chomper (big guy)
  • Special destruction effects (wood splinters, bloods)
  • Added two weapons (wooden sword, whip)
  • Added pickups (potion)

Melee

Added some simple graphics for the weapons that flip based on the direction the player’s facing.  I’ve also got work done on enemies getting hit by attacks.  Each enemy has a set amount of health before they die (explode) and they also have a stunned effect after taking a hit.

Inventory System

I figure I’ll post some code on this one.  I’m planning on utilizing a multidimensional array to handle the inventory list and counting how many of each you have.

//The Setup

The first step is creating the array at game start.  Game Maker doesn’t have much in terms of array functionality so I’ve had to put together a couple of scripts for basic features.  And so, to start we have to set up the array with a set number of items.

//Player Inventory
 globalvar inventory;
 //Set up 25 inventory slots
 for(var i = 0; i < 25; i++)
 {
 global.inventory[i,0] = "";
 global.inventory[i,1] = 0;
 }

Basically the first element [0,0] will be the name of the object and the second element [0,1] will be how many of that object you have in your inventory.  I looped it here to create 25 empty item slots.

//Counting the Inventory

Added a script called InventoryCount

var i = 0;
 while(global.inventory[i,0] != "")
 {
 i++;
 }
 //Return the count
 return i;

//Adding an Inventory item

Added a script called InventoryAdd

//argument0 should be new item
 var invCount = InventoryCount();
 var invTrue = false;
 for(var i = 0; i <= invCount; i++)
 {
 if(global.inventory[i,0] == argument0)
 {
 //Item already in inventory
 global.inventory[i,1] += 1;
 invTrue = true;
 }
 else if(global.inventory[i,0] == "")
 {
 //Empty inventory
 global.inventory[i,0] = argument0;
 global.inventory[i,1] += 1;
 invTrue = true;
 }
 }
if(invTrue == false)
 {
 //Add item to end of array
 global.inventory[invCount+1,0] = argument0;
 global.inventory[invCount+1,1] = 1;
 }

//Removing items from Inventory

Added a script called InventoryRemove

//Remove argument0 from inventory
 var invCount = InventoryCount();
 var invTrue = false;
for(var i = 0; i <= invCount; i++)
 {
 if(global.inventory[i,0] == argument0)
 {
 //Item already in inventory
 global.inventory[i,1] -= 1;
 if(global.inventory[i,1] <= 0)
 {
 global.inventory[i,0] = "";
 }
 invTrue = true;
 }
 }
 if(invTrue = false)
 {
 //Error occured
 show_debug_message("Error Will Robinson, cant remove what isnt there");
 }

//Adding a potion to my Inventory

In my potion pickup object, I have a simple script that has InventoryAdd(“Potion”);

And that’s all for this update.  The inventory framework was probably the most time consuming and will probably see more iterations as I add more functionality like item stats and sorting.  As it is right now, it’s a pretty good foundation to build off of.  Any questions on it, feel free to ask.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: