Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Let's make a game, /prog/

Name: Anonymous 2011-12-30 8:36

In C++ of course. I'll start with a class definition for our character.


#include <string>
#include "GIANT_LIST_OF_STL_HEADERS.hh"
#include "Typedefs_For_Shit_Liek_u8.hh"

namespace RPG {
        class Character {
        protected:
                u8 Str;
                u8 Dex;
                u8 Con;
                u8 Int;
                u8 Wis;
                u8 Cha;
                // Rest of class and RPG left intentionally undefined
                // Because Sepples is not Ruby and can't define the same class twice

Name: Anonymous 2011-12-30 10:08

# progventure.rb

class Character
  attr_accessor :str, :dex, :con, :int, :wis, :cha
  attr_accessor :hp, :max_hp, :mp, :max_mp
  def initialize(name, str, dex, con, int, wis, cha,
                   hp, mp, items = [], spells = [])
    @name = name
    @str, @dex, @con = str, dex, con
    @int, @wis, @cha = int, wis, cha
    @hp = @max_hp = hp
    @mp = @max_mp = mp
    @items = items
    @spells = spells
  end
  def get(item);     @items << item; end
  def drop(item);    @items.delete(item); end
  def has?(item);    @items.include?(item); end
  def learn(spell);  @spells << item; end
  def forget(spell); @spells.delete(spell); end
  def knows?(spell); @spells.include?(spell); end
end

$party = []
$party << Character.new(
    name = 'Xarn',
    str = 8,  dex = 9,  con = 10,
    int = 12, wis = 11, cha = 10,
    hp  = 90, mp  = 100
)
$party << Character.new(
    name = 'Leah',
    str = 8,  dex = 11,  con = 9,
    int = 10, wis = 9,   cha = 13,
    hp  = 80, mp  = 110
)
$party << Character.new(
    name = 'The Sussman',
    str = 11, dex = 9,  con = 8,
    int = 13, wis = 10, cha = 9,
    hp  = 80, mp  = 120
)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List