Page 1 of 1

c++ item tutorial

Posted: Fri Nov 27, 2009 5:48 pm
by ZeroComp
simple c++ item tutorial for those new to this

item properties code

Code: Select all

struct item_data
{
   std::string   name;
   std::string   description;
   unsigned long value;
   unsigned long weight;

item class

Code: Select all

class item
{
public;
  typedef unsigned long key
   item(key_type() const;
   const item_data& properties() const;
   static void define(key_type, const item_data&);
};
I will ad more later I will add things like how to program packages of items like i.e armor sets weapon sets how to include certain weapons in it and much more hope you like it and I hope it works!

Re: c++ item tutorial

Posted: Fri Nov 27, 2009 8:22 pm
by Perry
You forgot to close your struct with }; .

Re: c++ item tutorial

Posted: Sat Nov 28, 2009 1:53 am
by ZeroComp
oh stupid mistake I apologize. :oops:

Re: c++ item tutorial

Posted: Sat Nov 28, 2009 1:59 am
by Perry
Its cool everybody makes mistakes. Just telling you because it can cause some freaky errors that will make you stay up til 4 am trying to fix... not that I would know or anything. :oops:

Re: c++ item tutorial

Posted: Sat Nov 28, 2009 2:21 am
by ZeroComp
:lol: thanks

Re: c++ item tutorial

Posted: Sat Sep 25, 2010 11:43 pm
by pvtlink
instead of just writing code, can you explain it so i actually know how to use it. thanks :)

Re: c++ item tutorial

Posted: Sun Sep 26, 2010 12:30 am
by Jackolantern
I think this was maybe meant to be a small part of an on-going tutorial, as there is not really much there. It just creates a struct (a value-type data structure) and a class. It doesn't do anything.

Re: c++ item tutorial

Posted: Sun Oct 03, 2010 5:43 pm
by ZeroComp
I never continued :oops: I completely forgot but yeah in C++ just use this and fill in the fields with the item info and insert it in your code and you have an item which you can manipulate with your game source code