[QUOTE=MultiPurpose;20071246]I don't know what the problem is then. Did you mess with anything?[/QUOTE]
settings? No. The stuff you told me to, yes. Copy and past to your compiler and see if it works.
I did, it works. Also, it's called an IDE, which is a tool to make programming projects easier. A compiler actually translates the c++ code to computer language.
[QUOTE=MultiPurpose;20071323]I did, it works. Also, it's called an IDE, which is a tool to make programming projects easier. A compiler actually translates the c++ code to computer language.[/QUOTE]
Oh, well instead of editing I guess I will just copy and paste your edits if that's ok.
[editline]08:30PM[/editline]
Works now, weird.
thought id do it a different way just as a small exercise for myself
[cpp]
#include <iostream>
#include <string>
#include <list>
using namespace std;
bool IsStringInOptionList(string s);
list<string> optionList;
int main()
{
string userInput;
cout << "Welcome to the game of life, were you win or die horribly." << endl;
cout << "You are born as a male with the name of Habeeb in the town of Facepunch" << endl;
cout << "Will you cry or stay quiet like a good child?" << endl;
cout << "Cry" << endl;
cout << "Stay quiet" << endl;
optionList.push_front("cry");
optionList.push_front("stay quiet");
cin >> userInput;
while (!IsStringInOptionList(userInput))
{
cout << "No dice, " << userInput << " is not a valid option!" << endl;
cout << "Try again.." << endl;
cin >> userInput;
}
return 0;
}
bool IsStringInOptionList(string s)
{
list<string>::iterator optionList_iterator = optionList.begin();
while (optionList_iterator != optionList.end())
{
if (s == *optionList_iterator)
return true;
else optionList_iterator++;
}
return false;
}
[/cpp]
kinda pointless :D
Ick, ran into some kinks that make it weird, no errors so I can run ti but a few bugs, gonna watch some doctor who and work on it later.
[QUOTE=Xera;20069907]How exactly do you use templates in a generic way in an array/container in C++? Wouldn't that require reflection? I tried something for a factory, but gave up in the end.
-snip-
Garry(or everyone in general), how do you do your factories?[/QUOTE]
I haven't slept in over 24 hours but... I got this far:
[cpp]
#include <iostream>
#include "entity.hpp"
class Door : public IEntity
{
private:
static Creator<IEntity, Door> _creator;
void open()
{
std::cout << "Door opened!\n";
}
public:
virtual void use(){ open(); }
};
Creator <IEntity, Door> Door::_creator("ent_door");
int main()
{
Factory<IEntity> fac;
IEntity* door = fac.create("ent_door");
door->use();
delete door;
return 0;
}
[/cpp]
Can anyone see how I could wrap that up in one pretty macro? Because everything else works, I just need to prettify those two lines...
Can anyone show me how to get this working? Run it in Visual C++ and you'll see what I mean, Stay quit is the right answer yet it won't work.
[cpp]#include <iostream>
#include <string>
using namespace std;
int main()
{
string userInput;
cout << "Welcome to the game of life, were you win or die horribly.\n";
cout << "You are born as a male with the name of Habeeb in the town of Facepunch\n";
cout << "Will you cry or stay quiet like a good child?" << endl;
cout << "Cry\n";
cout << "Stay quiet\n";
cin >> userInput;
if(userInput != "Cry" && userInput != "Stay quiet")
{
cout << "Fucking retard, type out the answer\n";
cin.get();
return 0;
}
if(userInput == "Cry")
{
cout << "You fucking wimp, you cried so much you drowned yourself.\n";
cin.get();
return 0;
}
if(userInput == "Stay quiet")
cout << "You have aged 1 year! Keep doing good and I won't fuck you in the ass.";
cout << "So are you going to be a stubborn bitch or are you going to walk?" << endl;
cout << "Walk\n";
cout << "Don't walk\n";
cin >> userInput;
if(userInput != "Walk" && userInput != "Don't walk")
{
cout << "Fucking retard, type out the answer\n";
cin.get();
return 0;
}
cin.get();
return 0;
}[/cpp]
Usability tip #4928: Don't call the user a "fucking retard".
[QUOTE=AteBitLord;20074366]Can anyone show me how to get this working? Run it in Visual C++ and you'll see what I mean, Stay quit is the right answer yet it won't work.
[cpp]#include <iostream>
#include <string>
using namespace std;
int main()
{
string userInput;
cout << "Welcome to the game of life, were you win or die horribly.\n";
cout << "You are born as a male with the name of Habeeb in the town of Facepunch\n";
cout << "Will you cry or stay quiet like a good child?" << endl;
cout << "Cry\n";
cout << "Stay quiet\n";
cin >> userInput;
if(userInput != "Cry" && userInput != "Stay quiet")
{
cout << "Fucking retard, type out the answer\n";
cin.get();
return 0;
}
if(userInput == "Cry")
{
cout << "You fucking wimp, you cried so much you drowned yourself.\n";
cin.get();
return 0;
}
if(userInput == "Stay quiet")
cout << "You have aged 1 year! Keep doing good and I won't fuck you in the ass.";
cout << "So are you going to be a stubborn bitch or are you going to walk?" << endl;
cout << "Walk\n";
cout << "Don't walk\n";
cin >> userInput;
if(userInput != "Walk" && userInput != "Don't walk")
{
cout << "Fucking retard, type out the answer\n";
cin.get();
return 0;
}
cin.get();
return 0;
}[/cpp][/QUOTE]
[URL="http://en.wikipedia.org/wiki/Conway's_Game_of_Life"]Game of Life[/URL]
[QUOTE=Ortzinator;20074423]Usability tip #4928: Don't call the user a "fucking retard".[/QUOTE]
It's just some good fun, if you're offended you shouldn't be on FP.
[QUOTE=AteBitLord;20074366]Can anyone show me how to get this working? Run it in Visual C++ and you'll see what I mean, Stay quit is the right answer yet it won't work.
*code*
[/quote]
Learn to use the debugger, it can be your best friend, possibly lover.
Anyway, you have to use getline(). You are only reading in the first word; because of the space.
[editline]09:58PM[/editline]
[url]http://www.cplusplus.com/reference/iostream/istream/getline/[/url]
[editline]10:02PM[/editline]
[IMG]http://i429.photobucket.com/albums/qq12/the1trueryandaniels/fp_code_debug.png[/IMG]
[editline]10:03PM[/editline]
/over-answering
[editline]10:03PM[/editline]
night gents
Despite many hacky attempts, I eventually landed at this:
[cpp]
#include <iostream>
#include "entity.hpp"
class Door : public IEntity
{
FACTORY_ENTITY(Door, IEntity);
public:
virtual void use()
{
open();
}
private:
void open()
{
std::cout << "Door opened!\n";
}
};
NAME_ENTITY(Door, "ent_door");
int main()
{
Factory<IEntity> factory;
IEntity* door = factory.create("ent_door");
door->use();
delete door;
return 0;
}
[/cpp]
Doesn't really get any nicer than this when in C++ :love:
what are factories used for anyway
are you serious?
[QUOTE=efeX;20074973]are you serious?[/QUOTE]
he doesn't know what a factory in terms of programming is holy shit what a retard. why is he even in this forum?
[QUOTE=jA_cOp;20074680]Despite many hacky attempts, I eventually landed at this:
[cpp]
#include <iostream>
#include "entity.hpp"
class Door : public IEntity
{
FACTORY_ENTITY(Door, IEntity);
public:
virtual void use()
{
open();
}
private:
void open()
{
std::cout << "Door opened!\n";
}
};
NAME_ENTITY(Door, "ent_door");
int main()
{
Factory<IEntity> factory;
IEntity* door = factory.create("ent_door");
door->use();
delete door;
return 0;
}
[/cpp]
Doesn't really get any nicer than this when in C++ :love:[/QUOTE]
Would be cool to see the defines :P
[QUOTE=Eleventeen;20074802]what are factories used for anyway[/QUOTE]
[url]http://en.wikipedia.org/wiki/Abstract_factory_pattern[/url]
[QUOTE=efeX;20074973]are you serious?[/QUOTE]
No reason to be such as asshole.
[QUOTE=high;20075086]Would be cool to see the defines :P
[url]http://en.wikipedia.org/wiki/Abstract_factory_pattern[/url]
No reason to be such as asshole.[/QUOTE]
He was taking the piss out of efex
[QUOTE=ryandaniels;20074589]Learn to use the debugger, it can be your best friend, possibly lover.
Anyway, you have to use getline(). You are only reading in the first word; because of the space.
[editline]09:58PM[/editline]
[url]http://www.cplusplus.com/reference/iostream/istream/getline/[/url]
[editline]10:02PM[/editline]
[IMG]http://i429.photobucket.com/albums/qq12/the1trueryandaniels/fp_code_debug.png[/IMG]
[editline]10:03PM[/editline]
/over-answering
[editline]10:03PM[/editline]
night gents[/QUOTE]
Example please, this is oh so confusing.
[QUOTE=Eleventeen;20074802]what are factories used for anyway[/QUOTE]
A lot. It increases encapsulation and shortens code a lot because you're only dependent on one central object, the factory. So if you're working with 5 different kinds of entities in one file, you're still only depending on one module to do the object creation. It also increases encapsulation by hiding every implementation detail of the entity except for its name in string form. It increases flexibility a lot because you can dynamically choose what kind of entity to create with comparatively great runtime efficiency (a major boon if you're embedding a scripting language, for example). Of course, an entity system is just an example of what you typically use them for, everything is templated so you can apply it to any base class.
[QUOTE=high;20075086]Would be cool to see the defines :P[/QUOTE]
It just expands to what I posted earlier. I can put it up as a header-only library if anyone wants it, but right now I need some sleep.
Thanks to jA_cOp, I've finally started getting onto the LISP bandwagon. I spent a bit of time messing around with a scheme implementation, and oh man do I like it.
I think I'll make some CSFML bindings and see if that works out :v:
[QUOTE=Chandler;20075399]Thanks to jA_cOp, I've finally started getting onto the LISP bandwagon. I spent a bit of time messing around with a scheme implementation, and oh man do I like it.
I think I'll make some CSFML bindings and see if that works out :v:[/QUOTE]
Which Scheme interpreter/compiler did you end up getting?
edit:
Oh and... I've got some bad news about that wagon... we're the only ones left on it :(
[QUOTE=jA_cOp;20075500]Which Scheme interpreter/compiler did you end up getting?
edit:
Oh and... I've got some bad news about that wagon... we're the only ones left on it :([/QUOTE]
the one you're using (Gambit)
Also, I've got proggit on my side. Those guys lurve Functional Programming. Isn't there also a haskell guy around here? :v:
[QUOTE=Eleventeen;20070082]garry are you making source engine v2?[/QUOTE]
Hes probably not good enough to make a new source engine, I dunno. Although considering how Botch is coming along he would probably do good at making a newer/better version of the Hammer editor.
[QUOTE=nick10510;20075623]Hes probably not good enough to make a new source engine, I dunno. Although considering how Botch is coming along he would probably do good at making a newer/better version of the Hammer editor.[/QUOTE]
Anyone could make a better hammer editor. It uses MFC from 1998 for chrissakes.
[QUOTE=Chandler;20075650]Anyone could make a better hammer editor. It uses MFC from 1998 for chrissakes.[/QUOTE]
I've seen some of the custom hammer editors that individual scripters have made, but considering the resources and coding abilities of garry he could make something godlike
[QUOTE=nick10510;20075674]I've seen some of the custom hammer editors that individual scripters have made, but considering the resources and coding abilities of garry he could make something godlike[/QUOTE]
[IMG]http://i49.tinypic.com/2n19lw4.png[/IMG]
[QUOTE=AteBitLord;20075151]Example please, this is oh so confusing.[/QUOTE]
Anyone? I would love to keep working on my game but this is quite the pickle I am in.
[QUOTE=nick10510;20075674]I've seen some of the custom hammer editors that individual scripters have made, but considering the resources and coding abilities of garry he could make something godlike[/QUOTE]
I would pay a decent amount of money for a better Hammer.
[QUOTE=AteBitLord;20076104]Anyone? I would love to keep working on my game but this is quite the pickle I am in.[/QUOTE]
Okay, instead of doing
cin >> userinput;
Use std::getline to get the whole line.
[cpp]
#include <iostream>
#include <string>
int main()
{
std::string userInput;
std::cout << "Input: ";
std::getline(std::cin, userInput);
std::cout << "You entered: " << userInput;
}
[/cpp]
[QUOTE=nick10510;20075674]I've seen some of the custom hammer editors that individual scripters have made, but considering the resources and coding abilities of garry he could make something godlike[/QUOTE]
First you say he wouldn't be good enough, then you say he'd be godlike?
Sorry, you need to Log In to post a reply to this thread.