Exemplo n.º 1
0
GameController::GameController()
{
    initializeColors();

    worldMap = new Map("..//roguelikeProject//world_map.txt");
    worldMap->setName("World map");
    worldMap->addDungeon(new Dungeon("Right dungeon", 4, '*', 0, map_x / 2 + 2, map_y / 2));
    worldMap->addDungeon(new Dungeon("Left dungeon", 4, '*', 0, map_x / 2 - 2, map_y / 2));
    worldMap->getDungeonByName("Right dungeon")->setLevel(1, new Map("..//res//maps//testMap_90x30.txt"));

    Map *rightDungeonSecondLevel = worldMap->getDungeonByName("Right dungeon")->getLevel(1);
    Actor *orc = new Actor("AI-driven orc!", "humanoid", 'o', map_x / 2, map_y / 2, 10, 5, new CowardlyAI(), rightDungeonSecondLevel);
    Weapon *orcishWeapon = new Weapon("Orcish spear", 3);
    orc->getInventory()->addItem(orcishWeapon);
    orc->getInventory()->equipWeapon(orcishWeapon);
    rightDungeonSecondLevel->addActor(orc);

    rightDungeonSecondLevel->addItem(new Weapon("THE AXE", 6, map_x / 2, map_y / 2));

    player = new Actor("player", "player", '@', map_x / 2, map_y / 2, 6, 7, new PlayerAI(), worldMap);
    player->setSeen(true);
    player->getInventory()->addItem(new Weapon("THE SWORD", 30));
    player->getInventory()->addItem(new Armor("THE ARMOR", 5));
    currentDungeon = nullptr;
    currentMap = worldMap;
    state = playing;

    ui = new UI();
    ui->writeToStatusBar("Press 'h' for help\n");
    ui->updateStatsBar(player);

    score = 0;
}
Exemplo n.º 2
0
/// custom Qt message handler
static
void qtMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &pmsg)
{
    initializeColors();

    QString msg = pmsg;
    if( ! msg.endsWith( '\n')) {
        msg += '\n';
    }
    QByteArray localMsg = msg.toLocal8Bit();
    switch (type) {
    case QtDebugMsg:
        fprintf(stderr, "Debug: %s", localMsg.constData());
        break;
    case QtWarningMsg:
        fprintf(stderr, "%sWarning: %s (%s:%u, %s)%s\n",
                warningColor.c_str(),
                localMsg.constData(), context.file, context.line, context.function,
                resetColor.c_str());
        break;
    case QtCriticalMsg:
        fprintf(stderr, "%sCritical: %s (%s:%u, %s)%s\n",
                criticalColor.c_str(),
                localMsg.constData(), context.file, context.line, context.function,
                resetColor.c_str());
        break;
    case QtFatalMsg:
        fprintf(stderr, "%sFatal: %s (%s:%u, %s)%s\n",
                fatalColor.c_str(),
                localMsg.constData(), context.file, context.line, context.function,
                resetColor.c_str());
        abort();
    }

} // qtMessageHandler
Color gbGeneColor(struct track *tg, void *item, struct hvGfx *hvg)
/* Return color to draw gene in. */
{
struct sqlConnection *conn = hAllocConn(database);
struct sqlResult *sr;
char query[512];
struct bed *bed = item;
struct COG *COG=NULL;
char *temparray[160];
char **row;

if(hTableExists(database, "COG"))
    {
    sprintf(query, "select * from COG where name = '%s'", bed->name);
    sr = sqlGetResult(conn, query);
    if ((row = sqlNextRow(sr)) != NULL)
   	    COG = COGLoad(row);
    sqlFreeResult(&sr);
    hFreeConn(&conn);
    initializeColors(hvg);
    if(COG!=NULL)
	{
        chopString(COG->code, "," , temparray, 9999);
        return LLshadesOfCOGS[(temparray[0][0]-'A')];
	}
    else
        return blackIndex();
    }
else
    {
    hFreeConn(&conn);
    return blackIndex();
    }
slFreeList(&bed);
}
Exemplo n.º 4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuFlowCharacteristicsPlot::setLorenzCurve(const QStringList& dateTimeStrings, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
{
    initializeColors(dateTimes);

    m_lorenzPlot->detachItems(QwtPlotItem::Rtti_PlotCurve, true); 

    for (size_t tsIdx = 0; tsIdx < dateTimes.size(); ++tsIdx)
    {
        if (timeHistoryValues[tsIdx] == HUGE_VAL) continue;

        QDateTime dateTime = dateTimes[tsIdx];
        double timeHistoryValue = timeHistoryValues[tsIdx];

        QString curveName = dateTimeStrings[static_cast<int>(tsIdx)];

        RiuFlowCharacteristicsPlot::addCurveWithLargeSymbol(m_lorenzPlot, curveName, m_dateToColorMap[dateTime], dateTime, timeHistoryValue);
    }

    m_lorenzPlot->replot();
}
Exemplo n.º 5
0
// setup() is automatically called one time, when the application starts.
// Your implementation should set the background color (we recommend black)
// and call initializeColors according to the project instructions.
void testApp::setup() {
	ofBackground(0,0,0);
	initializeColors();
}