Пример #1
0
GameScores::GameScores()
{
	fatInit = fatInitDefault();
	if ( !areAvailable() ) {
		return;
	}
	for (int i = 0; i < MAX_SCORES; i++) {
		scores[i].name = (char *)malloc(sizeof(char) * 50);
	}
	readScores();
}
Пример #2
0
int main() {
	
	int numScores = 0;
	int scores[100];	
	int* numScoresPointer = &numScores;

	readScores(scores, numScoresPointer);
	printf("\n\nScores:\n");
	displayScores(scores, numScores);




	int numFreq = 0;
	struct freq frequencies[numScores];
	
	int i;
	for (i = 0; i < numScores; i++) {
		(*(frequencies + i)).number = 0;
	}

	int* numFreqPointer = &numFreq;




	calcHistogram(frequencies, numFreqPointer, scores, numScores);
	printf("\n\n\nUnsorted Histogram:\n");
	displayHistogram(frequencies, numFreq);

	sortHistogram(frequencies, numFreq);
	printf("\n\n\nSorted Histogram:\n");
	displayHistogram(frequencies, numFreq);

	return 0;
}
void drawGameScreen() {
    clear();
    //draw exterior of game
    drawBox(10, 3, 44, 34, 0);
    
    //draw path walls
    drawBox(10, 7, 11, 3, 0);
    drawBox(18, 7, 4, 14, 0);
    drawBox(18, 18, 16, 3, 0);
    drawBox(31, 7, 4, 14, 0);
    drawBox(31, 7, 18, 3, 0);
    drawBox(46, 7, 4, 24, 0);
    drawBox(19, 28, 30, 3, 0);
    drawBox(19, 28, 4, 9, 0);

    //fix up the corners
    clearPath();
    fixCorners();

    //add beginning and ending chars
    mvaddch(8, 8, '>');
    mvaddch(37, 21, ACS_DARROW);

    //draw and fill the purchase portion of the screen
    attron(COLOR_PAIR(0));
    drawPurchaseArea();
    basicSetupScreen(1);
    updateScore(0);
    attroff(COLOR_PAIR(0));
    drawTowerExplain();

    //load arrays for drawing
    TowerArray* theTowerList = getTowerArray("assets/towersLevel1.txt");
    Path* thePath = getPathArray("assets/path.txt");
    UnitListHeader * unitList = malloc(sizeof(UnitListHeader));
    int moneyAmount = STARTINGMONEY;
    initializeList(unitList);
    drawUnitTypes(unitList);
    int theScore = 0;

    drawTowers(theTowerList);

    //go to entering unit purchases (gives control back to user)
    selectUnitsInterface(thePath,unitList,&moneyAmount,theTowerList,&theScore);

    //get lowest score of highscores
    ScoreHead scores;
    scores.size = 0;
    scores.first = NULL;
    ScoreNode * currScore = NULL;
    readScores(&scores);
    currScore = scores.first;
    int numScores = 1;
    int highestScore = 0;

    while ((currScore->next != NULL) && (numScores < 9)) { 
        numScores += 1;
        currScore = currScore->next;
    }

    highestScore = -1;
    if (numScores > 8 && currScore != NULL) {
        highestScore = currScore->score;
    }

    char * enterName;
    if (theScore > highestScore) {
        enterName = drawScore(theScore,1);
        if (enterName != NULL) {
            addScore(&scores, enterName, theScore);
            writeScores(&scores);
        }
    } else {
        drawScore(theScore,0);
    }

    if (scores.size > 0) destroyScores(&scores);

}