Example #1
0
void AsciiTree::draw() {
    if (root == NULL) return;

    assignX();
    getOffset();

    vector<AsciiNode *> levelNodes;
    queue<AsciiNode *> fifo;
    int nextLevel = root->level;

    fifo.push(root);
    while (!fifo.empty()) {
        while (!fifo.empty() && fifo.front()->level == nextLevel) {
            AsciiNode *current = fifo.front();
            levelNodes.push_back(current);
            if (current->left)  {
                current->left->level = current->level + 1;
                fifo.push(current->left);
            }
            if (current->right) {
                current->right->level = current->level + 1;
                fifo.push(current->right);
            }
            fifo.pop();
        }

        if (!fifo.empty())
            nextLevel = fifo.front()->level;

        drawLevel(levelNodes);
        drawEdges(levelNodes);
        levelNodes.clear();
    }
}
Example #2
0
int dispThread(SceSize args, void *argp)
{
  sceIoChdir(cwd);
  initBackground();
  
  while (exit_state != EXCEPTION)
  {
    if (exit_state)
    {
      setFadeMode(&main_fade,FADE_IN,0);
      if (getFadeState(&main_fade) == FADE_DONE) break;
    }
 
    if (checkGameState(GSQUARE))
    {
      g2dClear(BLACK);
      dispgSquare();
    }
    if (checkGameState(BANNER))
    {
      g2dClear(BLACK);
      dispBanner();
    }
    if (checkGameState(MENU))
    {
      drawMovingBackground();
      dispMenu();
    }
    if (checkGameState(INGAME))
    {
      drawMovingBackground();
      camera();
      drawLevel();
      drawUI();
    }
    if (checkGameState(LEVEL_TITLE))
    {
      g2dClear(WHITE);
      intraFontSetStyle(seriffont,1.f,BLACK,0,0,INTRAFONT_ALIGN_CENTER);
      intraFontPrint(seriffont,G2D_SCR_W/2,G2D_SCR_H/2,lvl.title);
    }
    if (checkGameState(END))
    {
      g2dClear(WHITE);
      g2dBeginRects(img.end);
      {
        g2dAdd();
      }
      g2dEnd();
    }
    
    drawFade(&main_fade);
    g2dFlip(G2D_VSYNC);
  }
  
  if (exit_state == EXCEPTION) dispException();
  
  return 0;
}
Example #3
0
/**
 * Draw the current game scene
 */
void GameScreen::draw() {
	// Draw the level in the specified area
	glViewport(0, 0, m_width, m_height-m_top_panel_height);
    drawLevel();
	// Draw the top panel
	glViewport(0, 0, m_width, m_height);
    drawTopPanel();
}
Example #4
0
void Game::draw(void)
{
	glViewport(x,y, width * 0.7, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1.5,28.5, 31.5, -1.5, -512, 512);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity() ;

	for (int i = 0; i < 31; i++)
	{
		for (int j = 0; j < 28; j++)
		{
			
			glPushMatrix();
				glTranslatef(j,i,0);
				switch (gameboard[i][j])
				{
				case 'd':
					dot->draw();
					break;
				case 'u':
					powerup->draw();
					break;
				case '0':
				case '9':
					 break;
				default:
					wallmanager->draw(gameboard[i][j]);
					break;
				}
			glPopMatrix();
		}
	}
	pacman->draw();
	ambusher->draw();
	chaser->draw();
	fickle->draw();
	stupid->draw();

	glViewport(width * 0.7 + x, 0 + y, width * 0.3, height);	
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-150,150, 500, -500, -512, 512);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;
	
	glPushMatrix();
		glTranslatef(-50, -500, 0);
		drawScore();
		drawLives();
		drawLevel();
		//drawAuthor();
	glPopMatrix();
}
Example #5
0
void Render::draw(Level* level, Node<Obj> *objects)
{
	// TODO Render Backdrop
	drawBackdrop();

	drawLevel(level);

	drawObjects(objects);
}
Example #6
0
void draw_schizo( void )
{
	RESET_ZBUFFER
	CLEAN_TARGET((*levelPointer)->backgroundColor)
	spSetZSet( Z_SORTING );
	spSetZTest( Z_SORTING );
	spSetAlphaTest( 1 );

	drawLevel((*levelPointer));

	//HUD (for debug reasons)
	spSetZSet( 0 );
	spSetZTest( 0 );
	spSetAlphaTest( 1 );
	char buffer[256];
	sprintf( buffer, "camera X: %i\ncamera Y: %i\ncollisiontests: %i\nfps: %i\nspeed:%.5i,%.5i",
			(*levelPointer)->currentCamera.x >> SP_ACCURACY-5,(*levelPointer)->currentCamera.y >> SP_ACCURACY-5,
			getCollisionCount(),spGetFPS(),
			(*levelPointer)->choosenPlayer->physicsElement->speed.x,
			(*levelPointer)->choosenPlayer->physicsElement->speed.y);
	spFontDrawRight( screen->w-1, screen->h-font->maxheight*5, -1, buffer, font );
	#if defined ZOOMUP && defined ZOOMDOWN
		#ifdef FIRSTUP
			spScale2XSmooth(screen,dummy_screen);
			spScaleDownSmooth(dummy_screen,screen);
		#else
			spScaleDownSmooth(screen,dummy_screen);
			spScale2XSmooth(dummy_screen,screen);
		#endif
	#elif defined ZOOMUP
		spScale2XSmooth(screen,real_screen);
	#elif defined ZOOMDOWN
		spScaleDownSmooth(screen,real_screen);
	#endif
	if (levelFade > 0) // Fade in
		spInterpolateTargetToColor(0,(levelFade*SP_ONE)/FADE_TIME);
	if (levelFade < 0) // Fade out
		spInterpolateTargetToColor(0,SP_ONE+(levelFade*SP_ONE)/FADE_TIME);
	spFlip();
}
Example #7
0
/**
 *	Used to return to the java app the data from the 2D screen array kept by the
 *	library.
 *
 *	@param	env		required by all java jni
 *	@param	obj		required by all java jni
 *	@param	animate	a number to use as an animation index, used mostly for the 
 *					animation of the rings.
 *	@return			the 1D representation of the 2D array of screen data.					
 */
JNIEXPORT jintArray JNICALL Java_org_davidliebman_android_awesomeguy_Panel_drawLevel(JNIEnv * env, jobject  obj, jint animate)
{
	int j,k;
	jint size = SCREEN_WIDTH * SCREEN_HEIGHT;
	jint fill[size]; 
	jintArray graphic;
	drawLevel(animate);
	graphic = (*env)->NewIntArray(env, size);
	if(graphic == NULL) {
		LOGE("ARRAY NOT CREATED");
		return NULL;
	}
	for (j = 0; j < SCREEN_HEIGHT; j++) {
		for (k = 0; k < SCREEN_WIDTH ; k ++ ) {
			fill[ (j * SCREEN_WIDTH) + k ] = (jint) screen[j][k];
		}
	}
	
	
	(*env)->SetIntArrayRegion(env, graphic,0, size, fill);
	return graphic;
}
Example #8
0
void ExampleGame::draw()
{
	drawLevel();
	pPlayerTwo_->Draw(pDisplay_, camera_);
	Game::draw();
}
int main()
{
	REG_DISPCTL = MODE3 | BG2_ENABLE;

	while(1) {
		waitForVblank();

		//handle different states
		switch(state) {

		//Enter Title Screen
		case START:
			drawImage3(0, 0, 240, 160, title);
			state = LEVEL1;
			//state = LEVEL4;
			
			break;

		//Enter Level 1
		case LEVEL1:
			if (KEY_DOWN_NOW(BUTTON_START)) {
				drawLevel(state);
				state = play(state);
			}
			if (KEY_DOWN_NOW(BUTTON_SELECT)) {
				state = START;
			}
			break;

		//Enter Pause Screen 1
		case PAUSE1:
			drawImage3(0, 0, 240, 160, dkvsmario);
			if (KEY_DOWN_NOW(BUTTON_START)) {
				state = LEVEL2;
				drawLevel(state);
				state = play(state);
			}
			if (KEY_DOWN_NOW(BUTTON_SELECT)) {
				state = START;
			}
			break;

		//Enter Level 2
		case LEVEL2:
			drawLevel(state);
			state = play(state);
			if (KEY_DOWN_NOW(BUTTON_SELECT)) {
				state = START;
			}
			break;

		//Enter Pause Screen 2
		case PAUSE2:
			drawImage3(0, 0, 240, 160, dkvsmario);
			if (KEY_DOWN_NOW(BUTTON_START)) {
				state = LEVEL3;
				drawLevel(state);
				state = play(state);
			}
			if (KEY_DOWN_NOW(BUTTON_SELECT)) {
				state = START;
			}
			break;

		//Enter Level 3
		case LEVEL3:
			drawLevel(state);
			state = play(state);
			if (KEY_DOWN_NOW(BUTTON_SELECT)) {
				state = START;
			}
			break;

		// //Enter Pause Screen 3
		// case PAUSE3:
		// 	drawImage3(0, 0, 240, 160, dkvsmario);
		// 	if (KEY_DOWN_NOW(BUTTON_START)) {
		// 		state = LEVEL4;
		// 		drawLevel(state);
		// 		state = play(state);
		// 	}
		// 	if (KEY_DOWN_NOW(BUTTON_SELECT)) {
		// 		state = START;
		// 	}
		// 	break;

		// //Enter Level 4
		// case LEVEL4:
		// 	drawLevel(state);
		// 	state = play(state);
		// 	if (KEY_DOWN_NOW(BUTTON_SELECT)) {
		// 		state = START;
		// 	}
		// 	break;

		// //Enter Pause Screen 4
		// case PAUSE4:
		// 	drawImage3(0, 0, 240, 160, dkvsmario);
		// 	if (KEY_DOWN_NOW(BUTTON_START)) {
		// 		state = LEVEL4;
		// 		drawLevel(state);
		// 		state = play(state);
		// 	}
		// 	if (KEY_DOWN_NOW(BUTTON_SELECT)) {
		// 		state = START;
		// 	}
		// 	break;

		//You lost... gameover.
		case GAMEOVER:
			drawImage3(0, 0, 240, 160, gameover);
			if (KEY_DOWN_NOW(BUTTON_SELECT)) {
				state = START;
			}
			break;

		//You actually won...
		case WIN:
			drawImage3(0, 0, 240, 160, win);
			if (KEY_DOWN_NOW(BUTTON_SELECT)) {
				state = START;
			}
			break;
		}
	}
	return 0;
}
Example #10
0
bool GameState::update(double delta)
{
	SoundHandler::update(delta);

	SDL_RenderSetScale(m_renderer, m_cameraScale, m_cameraScale);
	m_renderer.setCamera(m_character, m_cameraScale);

	if (m_levelSwitching)
	{
		if ((m_levelAlpha -= delta * 500) <= 0)
		{
			switchLevels(*m_otherLevel);
		}
	}

	if (m_deathCamLifetime > 0)
	{
		m_deathCamLifetime -= delta;
	}
	else if(m_character->isDead())
	{
		respawn();
	}

	if (!m_skipped &&
		!m_character->isDead() &&
		!m_showScoreboard)
	{
		// It's unhealthy to run while switching dimensions
		if(m_mouseButtonDown && !m_levelSwitching)
		{
			const SDL_Point mouseWorld = {m_mousePosition.x + m_renderer.cameraOffsetX(), m_mousePosition.y + m_renderer.cameraOffsetY()};

			m_character->walkTowards(mouseWorld);
			m_character->setIsWalking(true);

			if(m_timeSinceStep == 0 || m_timeSinceStep > 0.3)
			{
				SoundHandler::play((SoundHandler::Sound::Value)(SoundHandler::Sound::Step + rand() % 10));
				m_timeSinceStep = 0;
			}

			m_timeSinceStep += delta;
		}
		else
		{
			m_character->walkTowards({0, 0});
			m_character->setIsWalking(false);

			m_timeSinceStep = 0;
		}

		std::vector<Player*> movableObjects;
		movableObjects.push_back(m_character);
		CollisionHandler::resolveCollisions(movableObjects, m_currentLevel);
	}

	drawLevel(*m_otherLevel, delta);
	drawLevel(*m_currentLevel, delta);

	if (!m_character->isDead())
	{
		m_character->draw(delta * m_running, m_renderer);

		if (!m_showScoreboard)
		{
			m_timeSinceRespawn += delta;
		}
	}

	if (m_showScoreboard)
	{
		SDL_RenderSetScale(m_renderer, 1, 1);
		m_scoreboard->draw(delta, m_renderer);
	}

	if (!m_skipped && !m_running)
	{
		SoundHandler::stopMusic();

		m_stateHandler.changeState<MapSelectionState>(true);
		m_skipped = true;

		return true;
	}

	return m_skipped || m_running;
}
Example #11
0
void ExampleGame::draw()
{
	drawLevel();
	Game::draw();
}
Example #12
0
void World::draw(float delta) {

    drawLevel(delta);

    player->draw((Screen*) gs, delta);
}
struct Monster* stringParsing(char* nameOfInputFile, struct HeroStatistics *heroStats, struct AllTheDoors * doorsInfo, struct Monster *monsterInfo, struct furthestRightWall *rightWall)
{
    int i;
    int k;
    int numberOfRooms;
    int numberOfTokens;
    char buf[102];
    char **brokenDownInput;
    char **roomString;
    FILE *inputFile;
    struct Coordinates * roomCoordinates;
    
    
    i = 0;
    k = 0;
    numberOfRooms = 0;
    numberOfTokens = 0;
    
    /*Opening the input file that is specified on the command line*/
    
    
    /*First finding the number of lines in the file aka the number of rooms*/
    /*FIX remove before submission*/
    if (nameOfInputFile != NULL)
    {
        inputFile = fopen(nameOfInputFile, "r");
    }
    if (inputFile != NULL)
    {
        while ((fgets(buf,101, inputFile)!=NULL))
        {
            numberOfRooms++;
        }
    }
    else
    {
        clear();
        mvprintw(0, 0, "There appears to be an error in opening the dungeon file. Exiting upon keypress.\n");
        getch();
        endwin();
        exit(0);
    }
    fclose(inputFile);
    
    /*Malloc array of structs based on numberOfRooms*/
    roomCoordinates = malloc(sizeof(struct Coordinates)*numberOfRooms);
    if (roomCoordinates == NULL)
    {
         clear();        
         mvprintw(0, 0, "out of memory: exiting upon keypress");
         getch();
         exit(1);
    }
    
    /*Malloc an array of pointer, one for each room/ line of text in file*/
    roomString = malloc(sizeof(char*)*numberOfRooms);
    if (roomString == NULL)
    {
         clear();    
         mvprintw(0, 0, "out of memory: exiting upon keypress");
         getch();
         exit(1);
    }
    
    if (nameOfInputFile != NULL)
    {
        inputFile = fopen(nameOfInputFile, "r");
    }
    else
    {
        clear();
        mvprintw(0, 0, "There was no input file name given, exiting upon keypress.");
        getch();
        endwin();
        exit(1);
    }
    if (inputFile != NULL)
    {
        /*As long as the file contains something, this loop will check to
         * see how many lines (aka rooms of the maze) are in the file*/
        /*Once it has the number of lines it will malloc memory
         * for the array of strings.*/
        /*It will then proceed to malloc the amount of memory needed for each
         * line of the input file. Then it will copy the line from the input file
         * into the designated string.*/
        if ((fgets(buf,101, inputFile)!=NULL))
        {
            do
            {
                roomString[i] = malloc(sizeof(char)*(strlen(buf)+1));
                if (roomString[i] == NULL)
                {
                    clear();
                    mvprintw(0, 0, "out of memory: exiting upon keypress");
                    getch();
                    exit(1);
                }
                strcpy(roomString[i], buf);
                i++;
            }
            while ((fgets(buf,101, inputFile)!=NULL));
        }
        else
        {
             clear();
             mvprintw(0, 0, "The file is empty. Exiting upon keypress.\n");
             getch();
             exit(0); 
        }
    }
    else
    {
         clear();    
         mvprintw(0, 0, "There appears to be an error in opening the dungeon file. Exiting upon keypress.");
         getch();
         endwin();
         exit(0);
    }
    fclose(inputFile);
    
    
    
    i = 0;
    /*This loop calls the drawing function at the end of it. It will loop until it has drawn all the rooms.*/
    while (i<numberOfRooms)
    {
        numberOfTokens = 0;
        
        
        /*First mallocs room for one pointer*/
        brokenDownInput = malloc(sizeof(char*)*1);
        if (brokenDownInput == NULL)
        {
            clear();
            mvprintw(0, 0, "out of memory: exiting upon keypress");
            getch();
            exit(1);
        }
        k = 0;
        
        /*Getting the first segment of information.*/
        brokenDownInput[k] = strtok(roomString[i], " ");
        
        /* Only runs if strtok actually returns a pointer*/
        if (brokenDownInput[k] != NULL)
        {
            /*Loops until the most recent token doesnt contain anything. Meaning it's the end of roomString[i]*/
            while (brokenDownInput[k] != NULL)
            {
                k++;
                /*Increases the size of brokenDownInput by 1 each time to have room to get another pointer.*/
                brokenDownInput = realloc(brokenDownInput, (sizeof(char*)*(k+1)));
                if (brokenDownInput == NULL)
                {
                    clear();  
                    mvprintw(0, 0, "out of memory: exiting upon keypress");
                    getch();
                    exit(1);
                }
                /*Returns a pointer to the segment of the room*/
                brokenDownInput[k] = strtok(NULL, " ");
            }
            /*Because of where k increases it will always be one more than the number of tokens. So tokens = k-1*/
            numberOfTokens = (k-1);
        }
        else
        {
            clear();
            mvprintw(0, 0, "There has been an error in parsing the file. Will exit upon keypress.");
            getch();
            exit(1);
        }
        monsterInfo = drawLevel(brokenDownInput, &roomCoordinates[0], heroStats, &doorsInfo[0], numberOfTokens, i, &monsterInfo[0], rightWall);
        
        i++;
        
        /*Frees brokenDownInput each time so it can hold the information of the next line of the file*/
        free(brokenDownInput);
    }
    /*numberOfRooms contains one line of file input per element of the array so each line needs to be freed.*/
    while (i< numberOfRooms)
    {
        free(roomString[i]);
        i++;
    }
    
    /*Freeing the array itself*/
    free(roomString);
    
    freeCoordinates(&roomCoordinates[0]);
    
    return (&monsterInfo[0]);
}
Example #14
0
void Level::renderLevel() {
    
    glEnable(GL_TEXTURE_2D);
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    
    // Background
    glBindTexture(GL_TEXTURE_2D, levelSprite.getID());
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glColor3f(1.0f, 1.0f, 1.0f);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 1.0f);
    glVertex2f(0.0f, 0.0f);
    
    glTexCoord2f(0.0f, 0.0f);
    glVertex2f(0.0f, height);
    
    glTexCoord2f(4.0f, 0.0f);
    glVertex2f(width, height);
    
    glTexCoord2f(4.0f, 1.0f);
    glVertex2f(width, 0.0f);
    glEnd();
    
    // Grass
    glBindTexture(GL_TEXTURE_2D, levelSpriteGroundTop.getID());
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    
    glColor3f(1.0f, 1.0f, 1.0f);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 1.0f);
    glVertex2f(0, height);
    
    glTexCoord2f(0.0f, 0.0f);
    glVertex2f(0, height + 10.0f);
    
    glTexCoord2f(width / levelSpriteGroundTop.getWidth(), 0.0f);
    glVertex2f(width, height + 10.0f);
    
    glTexCoord2f(width / levelSpriteGroundTop.getWidth(), 1.0f);
    glVertex2f(width, height);
    glEnd();
    
    // Ground
    glBindTexture(GL_TEXTURE_2D, levelSpriteGroundBottom.getID());
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    
    glColor3f(1.0f, 1.0f, 1.0f);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 3.0f);
    glVertex2f(0, height + 10.0f);
    
    glTexCoord2f(0.0f, 0.0f);
    glVertex2f(0, height + 50.0f);
    
    glTexCoord2f(width / levelSpriteGroundTop.getWidth(), 0.0f);
    glVertex2f(width, height + 50.0f);
    
    glTexCoord2f(width / levelSpriteGroundTop.getWidth(), 3.0f);
    glVertex2f(width, height + 10.0f);
    glEnd();
    
    glDisable(GL_TEXTURE_2D);
    glClear(GL_DEPTH_BUFFER_BIT);
    
    drawLevel();
}
Example #15
0
void SoftFox::run()
{
	//Set all default boolean
	running = true;
	jump = false;
	hasJumped = false;
	playerCollision = false;

	resetPlayer(); 	//Sets the players position

	//Thomas Easterbrook Coding Task two start
	hunterX = tileSize * level->getVillianX() + tileSize/2;
	hunterY = tileSize * level->getVillianY() + tileSize/2;
	//Thomas Easterbrook Coding Task two end

	//Dean Harland Coding Task Two Start
	//Set mushroom start posistion to the tile using level
	mushroomX = tileSize * level->getMushroomX() + tileSize / 2;
	mushroomY = tileSize * level->getMushroomY() + tileSize / 2;
	//Dean Harland Coding Task Two End

	while (running)
	{
		//Set an event
		SDL_Event ev;
		if (SDL_PollEvent(&ev))
		{
			switch (ev.type)
			{
				//Create a case for quitting the window and set running to false to deconstruct the window
				//Break or system breaks
				case SDL_QUIT:
					running = false;
					break;

				default:
					break;
			}
		}

		SDL_RenderCopy(renderer, backgroundImage, nullptr, NULL); //Render the background first

		drawLevel(); //Draw the level using the method drawTile shown below
		playerKeyBoardCommands();

		//Thomas Easterbrook Coding Task two start
		hunterSprite->render(renderer, hunterX, hunterY + spriteAdjustmentHunterSize, tileSize, tileSize);
		//Thomas Easterbrook Coding Task two end

		//Drawing mushroom sprite
		mushroomSprite->render(renderer, mushroomX, mushroomY + spriteAdjustmentMushroomSize, SPRITE_SIZE, SPRITE_SIZE);

		///Drawing player sprite (texture class)
		playerSprite->render(renderer, playerX, playerY, SPRITE_SIZE, playerSpriteHeight);

		//Drawing player sprite (texture class)
		controls->render(renderer, WINDOW_WIDTH - spriteControlXAdjustment, spriteControlYAdjustment, tileSize * 1.5, tileSize);

		////Sam Wills coding task two start
		jumping();
		hasFoxTouchedPlatform();
		sideCollision();
		isFoxInWindow();
		//Sam Wills coding task two end

		//Thomas Easterbrook Coding Task two start
		hunterMovement();
		hasFoxTouchedHunter();
		//Thomas Easterbrook Coding Task two end

		//Dean Harland Coding Task Two Start
		endGameMushroom();	
		//Dean Harland Coding Task Two Start

		SDL_RenderPresent(renderer);				
	}
}
Example #16
0
int main(int argc, char **argv) {
    enum GameMode gameMode;
    struct Windows windows;
    struct MapList mapList;
    struct Map *map;
    struct Dialog dialog[MAX_LEVELS];
    struct UnitList inmates, guards;
    struct UnitNode *unitNode;
    struct Path path;
    bool progress[MAX_LEVELS];
    int level=0;

    /* Parse map files */
    parseMap(argv[1], &mapList, dialog);

    /* Create nCurses WINDOWs */
    uiInit(&windows);

    /* Present user with main menu */
    gameMode = menuMain(&windows);

    do{
        if(gameMode==EXIT){
            break;
        } else if (gameMode!=NEW){
            level = levelSelect(&windows, &mapList, progress);
        }

        /* Select current map */
        map = &(mapList).level[level];

        /* Display intro text */
        drawText(&windows, dialog[level], gameMode);

        /* Initialize game elements */
        getGuards(&guards, *map);
        getPath(&path, *map);
        inmates.count = 0;
        inmates.head = NULL;
        inmates.tail = NULL;

        /* Draw level */
        drawLevel(&windows, map, &guards);

        /* Prompt user for unit selection */
        drawInmateSelection(&windows, map, &inmates, &guards);

        unitNode = getHead(&inmates);
        for (int i = 0; i < inmates.count; i++) {
            ((struct Inmate *) unitNode->unit)->position = path.first->location;
            unitNode = unitNode->next;
        }

        /* Simulate unit interactions */
        progress[level] = simulate(&windows, &guards, &inmates, &path);
        if(progress[level]) gameMode=WIN;
        else gameMode=LOSE;

        /* Display outro text */
        drawText(&windows, dialog[level], gameMode);

    } while (level!=EXIT);

    uiFree(&windows);
    quit("Thanks for playing.\n");

    return 0;
}