Example #1
0
int main(int argc, char* args[])
{
	int mainsurfX = 90;
	int mainsurfY = 75;

	GameData data;
	initGameData(data, mainsurfX, mainsurfY);
	data.RPG = initLevelData( "rpg", mainsurfX, mainsurfY);
	SetConsWinSize(mainsurfX*9, mainsurfY*10);
	
	new_GFSurface* surf = initBackground(mainsurfX, mainsurfY, CC_Cyan);
	
	pushGameSuface(data, *surf);

	Tasker tasker = processPrepair();
	
	processPush(tasker, activeRPG, "RPG");
	processPush(tasker, activeGraphic, "graph");
	while (true)
	{

		processIterator(data, tasker);
	}
	return 0;
}
Example #2
0
bool HelloWorld::init()
{
	if (!Layer::init())
	{
		return false;
	}
	winSize = Director::getInstance()->getWinSize();
	srand((int)time(NULL));

	listener = EventListenerTouchOneByOne::create();
	listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
	
	Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);

	initBG();
	initTitle();
	initGameData();
	initPlayer();
//	scoreboard(enemycount);
	setMissileInterface();
	initGameover();
	__String *tempScore = __String::createWithFormat("%i", score);
	scorelabel = LabelTTF::create(tempScore->getCString(), "Perfect Dark Zone.ttf", 40);
	scorelabel->setPosition(Vec2(150, 680));
	this->addChild(scorelabel, 150);
	this->scheduleUpdate();


	return true;
}
Example #3
0
bool GameScene::init()
{
    if (!Layer::init())
    {
        return false;
    }
    
    initGameData();
    
    initBG();
    initTopMenuLabel();
    
    initCard();
    
    return true;
}
Example #4
0
void HelloWorld::resetGameover()        //게임을 다시시작함
{
	auto label_1 = (Label*)this->getChildByTag(TAG_LABEL_GAMEOVER_1);
	label_1->stopAllActions();
	label_1->setScale(0.0f);
	label_1->setRotation(0);
	label_1->setVisible(false);

	auto label_2 = (Label*)this->getChildByTag(TAG_LABEL_GAMEOVER_2);
	label_2->stopAllActions();
	label_2->setScale(0.0f);
	label_2->setVisible(false);
	bossattack3 = 0;
	for (SpriteEnemy* enemy : vEnemy) {
		this->removeChild(enemy);
	}

	for (SpriteEnemy* enemy2 : vEnemy2) {
		this->removeChild(enemy2);
	}
	/*
	for (MiddleBoss* enemy3 : vMidBoss){
		this->removeChild(enemy3);
	}
	for (Boss* enemy4 : vBoss){
		this->removeChild(enemy4);
	}
	*/
	for (Sprite* missile : vMissile) {
		this->removeChild(missile);
	}

	for (Sprite* emissile : vEMissile) {
		this->removeChild(emissile);
	}

	for (Sprite* eitem : vItem) {
		this->removeChild(eitem);
	}

	this->unscheduleAllSelectors();

	initGameData();
	setTitle();
}
Example #5
0
IOStatus KGrGameIO::fetchGameListData
        (const Owner o, const QString & dir, QList<KGrGameData *> & gameList,
                              QString & filePath)
{
    QDir directory (dir);
    QStringList pattern;
    pattern << "game_*";
    QStringList files = directory.entryList (pattern, QDir::Files, QDir::Name);

    // KGr 3 has a game's data and all its levels in one file.
    // KGr 2 has all game-data in "games.dat" and each level in a separate file.
    bool kgr3Format = (files.count() > 0);
    if (! kgr3Format) {
        files << "games.dat";
    }

    // Loop to read each file containing game-data.
    foreach (const QString &filename, files) {
        if (filename == "game_ende.txt") {
            continue;			// Skip the "ENDE" file.
        }

        filePath = dir + filename;
        KGrGameData * g = initGameData (o);
        gameList.append (g);
        // kDebug()<< "GAME PATH:" << filePath;

        openFile.setFileName (filePath);

        // Check that the game-file exists.
        if (! openFile.exists()) {
            return (NotFound);
        }

        // Open the file for read-only.
        if (! openFile.open (QIODevice::ReadOnly)) {
            return (NoRead);
        }

        char c;
        QByteArray textLine;
        QByteArray gameName;

        // Find the first line of game-data.
        c = getALine (kgr3Format, textLine);
        if (kgr3Format) {
            while ((c != 'G') && (c != '\0')) {
                c = getALine (kgr3Format, textLine);
            }
        }
        if (c == '\0') {
            openFile.close();
            return (UnexpectedEOF);	// We reached end-of-file unexpectedly.
        }

        // Loop to extract the game-data for each game on the file.
        while (c != '\0') {
            if (kgr3Format && (c == 'L')) {
                break;			// End of KGr 3 game-file header.
            }
            // Decode line 1 of the game-data.
            QList<QByteArray> fields = textLine.split (' ');
            g->nLevels = fields.at (0).toInt();
            g->rules   = fields.at (1).at (0);
            g->prefix  = fields.at (2);
            // kDebug() << "Levels:" << g->nLevels << "Rules:" << g->rules <<
                // "Prefix:" << g->prefix;

            if (kgr3Format) {
                // KGr 3 Format: get skill, get game-name from a later line.
                g->skill = fields.at (3).at (0);
            }
            else {
                // KGr 2 Format: get game-name from end of line 1.
                int n = 0;
                // Skip the first 3 fields and extract the rest of the line.
                n = textLine.indexOf (' ', n) + 1;
                n = textLine.indexOf (' ', n) + 1;
                n = textLine.indexOf (' ', n) + 1;
                gameName = removeNewline (textLine.right (textLine.size() - n));
                g->name  = i18n (gameName.constData());
            }

            // Check for further settings in this game.
            // bool usedDwfOpt = false;		// For debug.
            while ((c = getALine (kgr3Format, textLine)) == '.') {
                if (textLine.startsWith ("dwf ")) {
                    // Dig while falling is allowed in this game, or not.
                    g->digWhileFalling = textLine.endsWith (" false\n") ?
                                         false : true;
                    // usedDwfOpt = true;		// For debug.
                }
            }

            if (kgr3Format && (c == ' ')) {
                gameName = removeNewline (textLine);
                g->name  = i18n (gameName.constData());
                c = getALine (kgr3Format, textLine);
            }
            // qDebug() << "Dig while falling" << g->digWhileFalling
                     // << "usedDwfOpt" << usedDwfOpt << "Game" << g->name;
            // kDebug() << "Skill:" << g->skill << "Name:" << g->name;

            // Loop to accumulate lines of about-data.  If kgr3Format, exit on
            // EOF or 'L' line.  If not kgr3Format, exit on EOF or numeric line.
            while (c != '\0') {
                if ((c == '\0') ||
                    (kgr3Format && (c == 'L')) ||
                    ((! kgr3Format) &&
                    (textLine.at (0) >= '0') && (textLine.at (0) <= '9'))) {
                    break;
                }
                g->about.append (textLine);
                c = getALine (kgr3Format, textLine);
            }
            g->about = removeNewline (g->about);	// Remove final '\n'.
            // kDebug() << "Info about: [" + g->about + "]";

            if ((! kgr3Format) && (c != '\0')) {
                filePath = dir + filename;
                g = initGameData (o);
                gameList.append (g);
            }
        } // END: game-data loop

        openFile.close();

    } // END: filename loop

    return (OK);
}