Random irrelevance that just didn't fit into other forums. Talk about anything.
Moderator: Talkative People
K-Bal
ES Beta Backer
Posts: 701 Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:
Post
by K-Bal » Sun Dec 06, 2009 8:59 pm
Anyone who wants to use XML should consider a short look at YAML with libyaml-cpp. It's extremely easy to use (from my game):
rats.yaml wrote:
-
name: "Small Rat"
model: "hueteotl"
texture: "rat.png"
scale: 2.0
maxhealth: 15.0
maxmana: 0.0
maxvelocity: 20.0
-
name: "Big Rat"
model: "hueteotl"
texture: "rat.png"
scale: 3.0
maxhealth: 25.0
maxmana: 0.0
maxvelocity: 20.0
Factory method:
Code: Select all
KMEntity* EntityFactory::CreateEnemy(const std::string& script, const std::string& type, const ggut::Vector2f& pos)
{
//TODO: KMEnemy
KMEntity* temp = new KMEntity();
std::ifstream fin(script.c_str());
YAML::Parser parser(fin);
YAML::Node doc;
parser.GetNextDocument(doc);
try
{
for(std::size_t num = 0; num < doc.size(); ++num)
{
if(doc[num]["name"] == type)
{
temp->SetName(type);
temp->SetMaxHealth(doc[num]["maxhealth"]);
temp->SetHealth(doc[num]["maxhealth"]);
temp->SetMaxMana(doc[num]["maxmana"]);
temp->SetMana(doc[num]["maxmana"]);
temp->SetModel(doc[num]["model"]);
temp->SetPosition(pos);
temp->SetScale(doc[num]["scale"]);
temp->SetMaxVelocity(doc[num]["maxvelocity"]);
}
}
}
catch( ... )
{
std::cerr << "Failed to load Enemy from YAML file!" << std::endl;
}
return temp;
}
Use:
Code: Select all
myRat = myEntityFactory.CreateEnemy("entities/rats.yaml", "Small Rat", Vector2f(150, 150));
Just wanted to share this. I just discovered it one hour ago
XianForce
Chaos Rift Devotee
Posts: 767 Joined: Wed Oct 29, 2008 8:36 pm
Post
by XianForce » Sun Dec 06, 2009 10:14 pm
Wow... That looks pretty legit =D. I'll have to take a look at it =p.
M_D_K
Chaos Rift Demigod
Posts: 1087 Joined: Tue Oct 28, 2008 10:33 am
Favorite Gaming Platforms: PC
Programming Language of Choice: C/++
Location: UK
Post
by M_D_K » Mon Dec 07, 2009 10:32 am
That's pretty awesome, I'll be checking that out later.
Gyro Sheen wrote: you pour their inventory onto my life
IRC wrote:
<sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
DaveB
Chaos Rift Newbie
Posts: 24 Joined: Sat Nov 21, 2009 1:57 pm
Post
by DaveB » Mon Dec 07, 2009 1:38 pm
Yeah I think I will diffidently use this, looks really clean and easy to use
thejahooli
Chaos Rift Junior
Posts: 265 Joined: Fri Feb 20, 2009 7:45 pm
Location: London, England
Post
by thejahooli » Sun Feb 28, 2010 6:11 pm
Do you know any tutorials or documentation on using it as there seems to be little on it.
I'll make your software hardware.
K-Bal
ES Beta Backer
Posts: 701 Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:
Post
by K-Bal » Mon Mar 01, 2010 2:45 am
LeonBlade
Chaos Rift Demigod
Posts: 1314 Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY
Post
by LeonBlade » Mon Mar 01, 2010 3:05 am
How would I use this for my maps
There's no place like ~/
pritam
Chaos Rift Demigod
Posts: 991 Joined: Thu Nov 13, 2008 3:16 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Amiga, PSOne, NDS
Programming Language of Choice: C++
Location: Sweden
Post
by pritam » Mon Mar 01, 2010 9:56 am
This looks very nice and clean, unlike how bloated XML can get.
mattheweston
Chaos Rift Junior
Posts: 200 Joined: Mon Feb 22, 2010 12:32 am
Current Project: Breakout clone, Unnamed 2D RPG
Favorite Gaming Platforms: PC, XBOX360
Programming Language of Choice: C#
Location: San Antonio,Texas
Contact:
Post
by mattheweston » Mon Mar 01, 2010 1:03 pm
I took a week long course on Adobe Flex and they were saying this is what will eventually replace XML due to various reasons.
K-Bal
ES Beta Backer
Posts: 701 Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:
Post
by K-Bal » Mon Mar 01, 2010 1:29 pm
mattheweston wrote: I took a week long course on Adobe Flex and they were saying this is what will eventually replace XML due to various reasons.
It will replace XML if we (the developers) use it and spread the word
thejahooli
Chaos Rift Junior
Posts: 265 Joined: Fri Feb 20, 2009 7:45 pm
Location: London, England
Post
by thejahooli » Mon Mar 01, 2010 3:05 pm
Sorry for being a noob, but could you please explain the set-up as I am not very experienced with command prompt, which is how they explain it.
I'll make your software hardware.
GroundUpEngine
Chaos Rift Devotee
Posts: 835 Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK
Post
by GroundUpEngine » Mon Mar 01, 2010 3:19 pm
Same here.. I epic fail at working with & setting up new libraries, I tryed to implement it before but gave up straight away lol. But I really want to use yaml properly!
K-Bal
ES Beta Backer
Posts: 701 Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:
Post
by K-Bal » Mon Mar 01, 2010 3:40 pm
What exactly is your problem? What do you need the cmd prompt for?
thejahooli
Chaos Rift Junior
Posts: 265 Joined: Fri Feb 20, 2009 7:45 pm
Location: London, England
Post
by thejahooli » Mon Mar 01, 2010 6:27 pm
I realised after downloading it that it was just a usual library set-up. I was just a bit thrown off by the How To Build section of the website.
I'll make your software hardware.
LeonBlade
Chaos Rift Demigod
Posts: 1314 Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY
Post
by LeonBlade » Mon Mar 01, 2010 8:47 pm
Hmm... I don't see how I could use this for a map structure, doesn't seem... efficient enough?
Should I just do tile by tile?
There's no place like ~/