Beispiel #1
0
void Game::movePlayer(const char *dir){
    if (hrac_posunul && can_move) {
        int x;
        int y;
        int old_item = hrac[hracNaTahu].hledany_predmet();
        int pohyb = plan.pohyb_hrace(dir,velikost,&hrac[hracNaTahu],hracNaTahu,&historie);
        if(pohyb < 0) {
            hrac[hracNaTahu].vrat_pozici(&x, &y);
            int posunx = 70;
            int posuny = 70;
            if(hracNaTahu == 1) {
                posunx = 80;
                posuny = 80;
            }
            else if(hracNaTahu == 2) posuny = 80;
            else if(hracNaTahu == 3) posunx = 80;
            hrac_gui[hracNaTahu]->setPos(posuny+y*52,posunx+x*52);
            if(old_item != hrac[hracNaTahu].hledany_predmet()) {
                can_move = false;
                updateGame();
            }
        }
        else if(pohyb > 0) { // konec hry
            showGameOverMenu(pohyb);
        }
    }
}
Beispiel #2
0
// "Orbital decay" countdown timer
void Room::tug3Timer1Expired() {
	if (_awayMission->tug.orbitalDecayCounter < 10) { // Decay still preventable
		showText(TX_SPEAKER_SHIPS_COMPUTER, TX_COMPU182);
		_awayMission->timers[1] = 100;
		_awayMission->tug.orbitalDecayCounter++;
	} else if (_awayMission->tug.orbitalDecayCounter < 16) { // Decay now unavoidable
		showText(TX_SPEAKER_SHIPS_COMPUTER, TX_COMPU181);
		_awayMission->timers[1] = 100;
		_awayMission->tug.orbitalDecayCounter++;
	} else { // Game over
		showText(TX_TUG3N006);
		showGameOverMenu();
	}
}
Beispiel #3
0
void Room::tug3AllCrewmenDead() {
	playMidiMusicTracks(2, -1);
	showGameOverMenu();
}
Beispiel #4
0
void Room::muddaTick() {
	// This function deals with the atmosphere running out when the life support generator
	// is malfunctioning.
	// NOTE: This has been changed a bit; in the original, they would just walk to
	// a position and stay standing, though the code indicates they were supposed to
	// collapse after walking.
	// To simplify things, and since it makes more sense, now they'll just collapse on the
	// spot instead.

	assert(_roomIndex >= 0 && _roomIndex <= 5);

	/*
	// Unused: The positions to they originally walked to before collapsing.
	const Common::Point deathPositions[][4] = {
	    { Common::Point(0xbb, 0x8d), Common::Point(0xd0, 0x89), Common::Point(0xaa, 0x85), Common::Point(0xbf, 0x83) },
	    { Common::Point(0xaa, 0xa5), Common::Point(0x83, 0xac), Common::Point(-1, -1), Common::Point(-1, -1) },
	    { Common::Point(0x108, 0xbb), Common::Point(0x118, 0xc4), Common::Point(0xfe, 0xb2), Common::Point(0x117, 0xae) },
	    { Common::Point(0xf1, 0x95), Common::Point(0xcd, 0x87), Common::Point(0xec, 0x84), Common::Point(0x110, 0xa6) },
	    { Common::Point(0x8b, 0xb6), Common::Point(0x69, 0xb7), Common::Point(-1, -1), Common::Point(-1, -1) },
	    { Common::Point(0x8b, 0xac), Common::Point(0x6f, 0x99), Common::Point(-1, -1), Common::Point(-1, -1) },
	};
	*/

	const TextRef deathText[] = { // All of these audio files are identical, but there's one for each room.
		TX_MUD0N006, TX_MUD1N007, TX_MUD2N005, TX_MUD3N008, TX_MUD4N005, TX_MUD5N105
	};

	// UNUSED: something similar to "deathText" which would also fit in this situation.
	/*
	const TextRef deathText2[] = { // All of these audio files are identical, but there's one for each room.
		TX_MUD0N009, TX_MUD1N010, TX_MUD2N009, TX_MUD3N013, TX_MUD4N007, TX_MUD5N007
	};
	*/

	const int TIMER_LENGTH = 27000;

	if (_awayMission->mudd.lifeSupportMalfunctioning) {
		if (!_awayMission->mudd.startedLifeSupportTimer) {
			_awayMission->mudd.startedLifeSupportTimer = true;
			_awayMission->mudd.lifeSupportTimer = TIMER_LENGTH;
		}
		_awayMission->mudd.lifeSupportTimer--;

		// BUGFIX: the warnings at 75%, 50%, and 25% were only voiced in MUDD0.
		if (_awayMission->mudd.lifeSupportTimer == (int)(TIMER_LENGTH * 0.25))
			showText(TX_SPEAKER_SPOCK, TX_MUD0_018);
		else if (_awayMission->mudd.lifeSupportTimer == (int)(TIMER_LENGTH * 0.5))
			showText(TX_SPEAKER_SPOCK, TX_MUD0_019);
		else if (_awayMission->mudd.lifeSupportTimer == (int)(TIMER_LENGTH * 0.75))
			showText(TX_SPEAKER_SPOCK, TX_MUD0_020);
		else if (_awayMission->mudd.lifeSupportTimer == 1) {
			_awayMission->disableInput = true;

			// In each room, the crewmen collapse in a different directions.
			// NOTE: "kgetdn" (kirk, north) doesn't work properly; files in the animation
			// are missing. It's replaced with 'e' (east) in MUDD1, MUDD3, MUDD5. Only
			// applies to Kirk, others seem fine...
			// TODO: check if this is the case across all versions...
			const char *directions[] = {
				"weseee", // KIRK
				"sewene", // SPOCK
				"nsesss", // MCCOY
				"ewesww", // REDSHIRT
			};

			for (int i = OBJECT_KIRK; i <= OBJECT_REDSHIRT; i++) {
				Common::String anim = getCrewmanAnimFilename(i, "getd");
				anim += directions[i][_roomIndex];
				loadActorAnim2(i, anim);
			}
			showText(deathText[_roomIndex]);
			showGameOverMenu();
		}
	}
}
Beispiel #5
0
//main game loop 
extern void showGame(MI0283QT9 lcd){
	//setup seed
	
	uint16_t seed = (rand() % 65534) + 1;
	srand(seed);
	
	//setup car
	uint8_t x = 2;
	uint8_t movCounter = 0;
	uint8_t colored[] = {red,green,blue};
	uint16_t score = 0;
	uint8_t pSensitivity = 0;
	
	  initGenObjects();
	//objects preGenObjects[128];

	
	if (sLow == 1)
	{
		pSensitivity = 5;
	} else if (sMedium == 1)
	{
		pSensitivity = 4;
	} else if (sHigh == 1){
		pSensitivity = 3;
	}
	
	//Draw game road
	showDefaultLayout(lcd);
	
	nun.nunchuck_init();

	posYobj1 = 0;
	posYobj2 = 0;
	posYobj3 = 0;

	prevposXobj1 = 0;
	prevposXobj2 = 0;
	prevposXobj3 = 0;

	keepObj2Alive = 0;
	keepObj3Alive = 0;
	
	uint8_t carHitMax = 15;
	uint8_t truckHitmax = 18;
	
	
	uint8_t countDown = 3;
	
	//start game loop
	while(1){
		
		
		
		if(returnToMain){
			returnToMain = 0;
			lcd.fillScreen(BACKGROUND);
			break;
		}
		
		if(restartGame){
			
			
			posYobj1 = 0;
			posYobj2 = 0;
			posYobj3 = 0;

			prevposXobj1 = 0;
			prevposXobj2 = 0;
			prevposXobj3 = 0;

			keepObj2Alive = 0;
			keepObj3Alive = 0;
			
			
			//Draw game road
			 initGenObjects();
			
			
			x = 2;
			
			movCounter = 0;
			colored[0] = red;
			colored[1] = green;
			colored[2] = blue;
			score = 0;
			
			pSensitivity = 0;
			
			if (sLow == 1)
			{
				pSensitivity = 5;
			} 
			else if (sMedium == 1)
			{
				pSensitivity = 4;
			}
			else if (sHigh == 1)
			{
				pSensitivity = 3;
			}
			
			showDefaultLayout(lcd);
			
			onBeginB = 0;
			restartGame = 0;
			countDown = 3;
		}
		
		//countdown before game start
		while(countDown != 0){
			lcd.drawInteger(centerText(" ", 3), 150, countDown, DEC, OBJECTCOLOR, BACKGROUND, 3);
			_delay_ms(1000);
			lcd.drawInteger(centerText(" ", 3), 150, countDown, DEC, BACKGROUND, BACKGROUND, 3);
			if(countDown == 1){
				lcd.drawText(centerText("START" , 3), 150, "START", OBJECTCOLOR, BACKGROUND, 3);
				_delay_ms(1000);
				lcd.drawText(centerText("START" , 3), 150, "START", BACKGROUND, BACKGROUND, 3);
			}
			countDown--;
		}
		//shows the enemy cars
		showGenObjects(lcd);
		
		//Draw player car at start location
		drawCar(lcd, x, 12,colored);
		
		
		
		
		//If obj1 is at you y location, check if objectx = playerx
		if((object[0].type == 1 && object[0].posY >= 12  && object[0].posY <= carHitMax ) || (object[0].type == 2 && object[0].posY >= 12 && object[0].posY <= truckHitmax)){
			if (object[0].posX == x ) {
				showGameOverMenu(lcd, score);
			}else{
				
				if(object[0].posY == carHitMax  || object[0].posY == truckHitmax){
					score = object[0].type + score;
				}
				
				
			}
		}else if((object[1].type == 1 && object[1].posY >= 12 && object[1].posY <= carHitMax ) || (object[1].type == 2 && object[1].posY >= 12 && object[1].posY <= truckHitmax)){
			//If obj2 is at player y location, check if objectx = playerx
			if (object[1].posX == x) {				
				showGameOverMenu(lcd,score);
			}else{
				
				if(object[1].posY == carHitMax  || object[1].posY == truckHitmax){
					score = object[1].type + score;
				}
			}
		} else if((object[2].type == 1 && object[2].posY >= 12 && object[2].posY <= carHitMax ) || (object[2].type == 2 && object[2].posY >= 12 && object[2].posY <= truckHitmax)){
			
			//If obj3 is at player y location, check if objectx = playerx
			if (object[2].posX == x) {
				showGameOverMenu(lcd,score);
			}else{
				
				if(object[2].posY == carHitMax || object[2].posY == truckHitmax){
					score = object[2].type + score;
				}
			}
		}
		
		
		
		//draws car at x depending on tilt, and y = 12 (front of car), y = 15 end of car
		if(nun.retreive_data()){
			
			
			if (nun.getC() ==1) {
				showPauseMenu(lcd);
			}
			
			
			//if nunchuck is tilted right, increment x
			if(nun.getAccX() > 148 || nun.getJoyX() > 150){
				if(movCounter == 0){
					removeCar(lcd, x, 12);
					if(x<4){
						x++;
					}
					movCounter++;
					}else{
					movCounter++;
					if(movCounter>=pSensitivity){
						movCounter = 0;
					}
				}
				drawCar(lcd, x, 12, colored);
			}
			//draw car at x location
			//if nunchuck is tilted left, substract 1 from x
			else if((nun.getAccX() > 70 && nun.getAccX() < 108) || nun.getJoyX() < 90){
				if(movCounter==0){
					removeCar(lcd, x, 12);
					if(x>0){
						x--;
					}
					movCounter++;
					}else{
					movCounter++;
					if(movCounter>=pSensitivity){
						movCounter = 0;
					}
				}
				//draw car at x location
				drawCar(lcd, x, 12, colored);
				//if nunchuck is in middle, movCounter = 0
			}else if(nun.getAccX() > 120 && nun.getAccX() < 136){
				movCounter = 0;
			}
			
			lcd.drawInteger(22, 2, score, DEC, GRASSCOLOR, BACKGROUND, 1);
			
		}
	}
}