Example #1
0
/* Replace substrings within asterisks. */
const char *
processLoreLine (const char *src, const char *arg = NULL)
{
    const char *what;
    const char *with;
    do {
        with = NULL;
        if ((what = strstr (src, "*arg*"))) {
            with = arg;
        } else if ((what = strstr (src, "*Arg*"))) {
            char *tmp = GetBuf ();
            strncpy (tmp, arg, SHBUFLEN);
            tmp[0] = toupper (tmp[0]);
            with = tmp;
        } else if ((what = strstr (src, "*args*"))) {
            char *tmp = GetBuf ();
            strncpy (tmp, arg, SHBUFLEN);
            makePlural (tmp, SHBUFLEN);
            with = tmp;
        } else if ((what = strstr (src, "*Args*"))) {
            char *tmp = GetBuf ();
            strncpy (tmp, arg, SHBUFLEN);
            tmp[0] = toupper (tmp[0]);
            makePlural (tmp, SHBUFLEN);
            with = tmp;
        } else if ((what = strstr (src, "*randomrace*"))) {
            with = randomRace ();
        } else if ((what = strstr (src, "*randomworld*"))) {
            with = randomWorld ();
        } else if ((what = strstr (src, "*profession*"))) {
            with = Hero.mProfession->mName;
        } else if ((what = strstr (src, "*heroname*"))) {
            with = Hero.cr ()->mName;
        }
        if (what) {
            char *buf = GetBuf ();
            char *line = GetBuf ();
            int length = (what - src);
            strncpy (buf, src, length);
            buf[length] = '\0'; /* Buf might have had contents. */
            ++what;
            while (*what != '*') ++what;
            ++what;
            snprintf (line, SHBUFLEN, "%s%s%s", buf, with, what);
            src = line;
        }
    } while (what);
    return src;
}
Example #2
0
File: TGApp.cpp Project: Nuos/DnDTG
TGApp::TGApp(PolycodeView *view) {
	core = new Win32Core(view,XSIZ,YSIZ,false,0,60);	  
	CoreServices::getInstance()->getResourceManager()->addArchive("default.pak");
	CoreServices::getInstance()->getResourceManager()->addDirResource("default", false);
	core->getInput()->addEventListener(this, InputEvent::EVENT_KEYUP);
	core->getInput()->addEventListener(this, InputEvent::EVENT_MOUSEMOVE);
	screen = new PhysicsScreen();
	title = new ScreenLabel("DnD Terrain Generator",16);
	title->setPosition(-XSIZ/2,-YSIZ/2);
	title->depthTest = false;
	screen->setScreenOffset(XSIZ/2,YSIZ/2);
	worldInit = false;
	randomWorld();
	screen->addChild(title);
}
Example #3
0
//Keyboard handler to be passed into glutKeyboardFunc
void keyboard(unsigned char key, int x, int y){
	switch(key){
		case 27: //esc key = exit window
		case 'q': //(or 'q')
			exit(0);
			break;
		case 32: //spacebar = pause/play toggle
			play = play==true ? false : true;
			timerCalled = false;
			break;
		case 'c': //clear world
			emptyWorld();
			break;
		case 'r': //randomize world
			randomWorld();
			break;
		default:
			break;
	}
}
Example #4
0
//Main function.
int main(int argc, char **argv) {
	instructions();
	srand(time(0));
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE);
	glutInitWindowSize(500, 500);
	glutCreateWindow("conway's game of life");
	initMenu();
	glClearColor(0,0,0,1);
	glutKeyboardFunc(keyboard);
	glutMouseFunc(mouse);
	glutSpecialFunc(special);
	gluOrtho2D(0, 50, 50, 0);
	glutDisplayFunc(display);
	glutIdleFunc(idle);
	emptyWorld();
	randomWorld();
	glutMainLoop();

	return 0;
}
Example #5
0
File: TGApp.cpp Project: Nuos/DnDTG
//Handle events
void TGApp::handleEvent(Event *e) {
	if(e->getDispatcher() == core->getInput()) {
		InputEvent *inputEvent = (InputEvent*)e;		
		switch(e->getEventCode()) {
			case InputEvent::EVENT_KEYUP:
				switch (inputEvent->key) {					
					case KEY_SPACE:
						randomWorld();
					break;
				}
			break;
			case InputEvent::EVENT_MOUSEDOWN:
				float xx = inputEvent->mousePosition.x - XSIZ/2;
				float yy = inputEvent->mousePosition.y - YSIZ/2;
				ScreenEntity *e = screen->getEntityAtPosition(xx,yy);
				if(e == NULL) break;
				e->setColor(1,0,0,1);
				printf("%f",e->bBox.length());				
			break;
		}		
	}
}