My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
CreatingNewItems  
This page describes how to implement new items in Snookiepoof
Phase-Implementation
Updated Jun 27, 2009 by torbjorn...@gmail.com

Introduction

Items represent a central concept in Snookiepoof. You can extend the game engine by adding new items. This page describes the normal steps you go through to create a new item.

Remember to start by creating tests first. Tests for items are created in project Test.Snookiepoof.Core.

Adding a new item class

New items are created in the Items folder in the Snookiepoof.Core project.

  • Create a class that inherits from AbstractItem.
  • Add the ItemNameAttribute to the class. By convention the name should be the name of the item as it would appear in the middle of a sentence (lower case). The name must be unique, and will be used by the engine to locate and represent the item.
  • Run all tests to ensure that the item complies with all conventions.

Sample item (with no behavior:

[ItemName("table")]
public class Table : AbstractItem
{
}

Item types

In the ItemClassifications folder in Snookiepoof.Core you will find interfaces that should be inherited to give your new item specific behaviors.

  • If you want the player to be able to pick up and carry the item, you inherit from ICanBeCarried.
  • If you want the player to be able to use the item, you inherit from the ICanBeUsed interface.
  • ..and so on..

Sample item that can be carried:

    [ItemName("knife")]
    public class Knife : AbstractItem, ICanBeCarried
    {
        public Knife()
        {
            Weight = 500;
        }

        public int Weight { get; private set; }
    }

Add item to a game

In order to use the item in a game it must be added to a game level. See creating new game levels.


Sign in to add a comment
Powered by Google Project Hosting