🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Core Library

posted in A Keyboard and the Truth for project 96 Mill
Published October 08, 2007
Advertisement
Greetings all, I've been busy putting some final touches on my core library, and it looks like it's pretty much done. I still have to decide what kind of license I'm going to be releasing it under, and I'm still unsure weather it will be free or not (perhaps free for non-commercial applications), but the fee will be very minimal if I do decide to sell it (perhaps $30.00 for unlimited license).

I also finished a suitable logo, a sort of earth's core/pac man kind of feel:



In the mean time feel free to look over the online documentation (still needs to be revised for spelling and such but the meat is all there).

Core Library Preliminary Documentation

To those of you who showed interest in using it, I'd like to have some test candidates, if you could get in touch with me via AIM SN: EtherealDarknes (one s is intentional) or MSN: rmanpres@hotmail.com we can talk about usage of the library.

And check this out, a simple script able text adventure engine (with lots of room to grow), using the core library for state management, game loop, save/load and scripting.

#include "Core.h"#include #include #include #include #define WINDOWS_LEAN_AND_MEAN#include Object* factory(int type);void update(float time);void newGame(void);bool loadGame(const std::string& file);bool saveGame(const std::string& file);void output(const std::string& str);std::string input(void);std::string prompt(const std::string& text);bool question(const std::string& text);bool containsKeyword(const std::string& str,const std::string& keyword);int scriptCreateRoom(void* sc);int scriptSelectRoom(void* sc);int scriptOutput(void* sc);class Game;class Room;#define TYPEID_GAME 1class Game: public Object{public:	Room* room;public:	void init(void)	{		room=0;		raiseEvent("onInit");	}	void save(OutputArchive& oa)	{		Object::save(oa);		oa.writeObject((Object*)room);	}	void load(InputArchive& ia)	{		Object::load(ia);		room=(Room*)ia.readObject();	}};#define TYPEID_ROOM 2class Room: public Object{public:public:	void init(void)	{		raiseEvent("onInit");	}};Core* core=0;Game* game=0;int main(const char** argv, int argn){	core=new Core(factory,update);	core->registerFunction("createRoom",scriptCreateRoom);	core->registerFunction("selectRoom",scriptSelectRoom);	core->registerFunction("output",scriptOutput);	newGame();	bool ret=core->start();	delete core;	if(ret)return 0;	return 1;}Object* factory(int type){	switch(type)	{	case TYPEID_GAME:		return new Game();	case TYPEID_ROOM:		return new Room();	default:		return 0;	}}void update(float time){	std::string buf=input();	if(containsKeyword(buf,"look"))	{		if(game->room==0||!game->room->raiseEvent("onLook"))		{			game->raiseEvent("onLook");		}	}	else if(containsKeyword(buf,"north"))	{		if(game->room==0||!game->room->raiseEvent("onNorth"))		{			game->raiseEvent("onNorth");		}	}	else if(containsKeyword(buf,"south"))	{		if(game->room==0||!game->room->raiseEvent("onSouth"))		{			game->raiseEvent("onSouth");		}	}	else if(containsKeyword(buf,"east"))	{		if(game->room==0||!game->room->raiseEvent("onEast"))		{			game->raiseEvent("onEast");		}	}	else if(containsKeyword(buf,"west"))	{		if(game->room==0||!game->room->raiseEvent("onWest"))		{				game->raiseEvent("onWest");		}	}	else if(containsKeyword(buf,"quit"))	{		if(question("Do you really want to quit?"))PostQuitMessage(0);	}	else if(containsKeyword(buf,"new"))	{		if(question("Do you really want to start a new game?"))		{			newGame();			}	}	else if(containsKeyword(buf,"save"))	{		saveGame(prompt("Filename to save?"));	}	else if(containsKeyword(buf,"load"))	{		loadGame(prompt("Filename to load?"));	}}void newGame(void){	core->clear();	game=(Game*)core->newObject(TYPEID_GAME,"game.script");	game->init();}bool loadGame(const std::string& file){	if(core->load(file))	{		game=(Game*)core->getObject(1);		return true;	}	return false;}bool saveGame(const std::string& file){	return core->save(file);}void output(const std::string& str){	std::cout << str << std::endl;}std::string input(void){	std::string buf;	std::cout << std::endl << "?> ";	std::getline(std::cin,buf);	return buf;}bool containsKeyword(const std::string& str,const std::string& keyword){	return str.find(keyword)!=str.npos;}std::string prompt(const std::string& text){	std::string buf;	std::cout << std::endl << text<<"> ";	std::getline(std::cin,buf);	return buf;}bool question(const std::string& text){	output(text);	return containsKeyword(prompt("yes/no?"),"yes");}int scriptCreateRoom(void* sc){	Room* room=(Room*)core->newObject(TYPEID_ROOM,callToString(sc,1));	room->init();	callPushObject(sc,room);	return 1;}int scriptSelectRoom(void* sc){	if(game->room!=0)game->room->raiseEvent("onLeave");	game->room=(Room*)callToObject(sc,1);	if(game->room!=0)game->room->raiseEvent("onEnter");	return 0;}int scriptOutput(void* sc){	output(callToString(sc,1));	return 0;}
Previous Entry Reusable Core
Next Entry Animation Format
0 likes 1 comments

Comments

nolongerhere
Cant wait to see it!
Ide be willing to purchase it! Would it come with source code?
October 08, 2007 05:10 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement