Esempio n. 1
0
void lvlIntro(Game *game, Level *level) {
	
	char levelNumber[50];
	int row,col,xPos, j = 0;
	sprintf(levelNumber, "LEVEL %d", game->levelNum);
	playMusic(intro, FALSE);
	
	// Draw stars, increasing length (speeding up)
	for ( j = 0; j < 30; j++ ) {
		
		lcd_fillScreen(BLACK);
		
		for (row = level->stars.y; row < DISPLAY_HEIGHT; row += STAR_SPACING_HEIGHT) { 
			for (col = level->stars.x; col < DISPLAY_WIDTH; col++) { 
				if (xPos%STAR_SPACING_WIDTH == 0) { 
					vLine(col,row, row + j, WHITE); 
				} 
				xPos++; 
			}
		}
		xPos=0; // reset xPos
		
		lcd_putString(100, 50, (unsigned char *)levelNumber);
		drawShip(level->player.currPos.x, -3*j + INIT_SHIP_POS_Y, level->player.type);
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
	}		
	
	lcd_fillScreen(WHITE);
	playMusic(RainPizz,FALSE);
	memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
	mdelay(150);
	// Draw stars, decreasing length (slowing down)
	
	for ( j = 15; j > 0; j-- ) {
		
		lcd_fillScreen(BLACK);
		
		for (row = level->stars.y; row < DISPLAY_HEIGHT; row += STAR_SPACING_HEIGHT) { 
			for (col = level->stars.x; col < DISPLAY_WIDTH; col++) { 
				if (xPos%STAR_SPACING_WIDTH == /*(row%2)*/ 0) { 
					vLine(col,row, row + j, WHITE); 
				} 
				xPos++; 
			}
		}
		xPos=0; // reset xPos
		
		lcd_putString(100, 50, (unsigned char *)levelNumber);
		drawShip(level->player.currPos.x, level->player.currPos.y - j*j, level->player.type);
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
		mdelay(100);
	}
}
Esempio n. 2
0
// Renders the screen to the correct layout for edit mode using the current sequence[] and final_timing[] arrays.
void setupScreen(int step_width, int left, int bottom, int right, int top)
{
	right = step_width;
	step_width = 320/sequence_steps;
	// Filling the full screen will cause a flicker if this function is over used. Therefore, used as a setup function for changing modes.
	lcd_fillScreen(LIGHT_GRAY);
	// Iterate one row at a time and set cell colours and grid lines.
	for(k=0; k<numNotes; k++){
		for(l=0; l<sequence_steps; l++) {
			lcd_drawRect(bottom, left, top, right, DARK_GRAY);
			if(k == sequence[l]){
				// If a note is found in this row. Setup the relative cell with the corresponding note size colour value.
				if(final_timing[l] == 1){
						lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, MAROON);
				}
				else if(final_timing[l] == 2){
						lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, OLIVE);
				}
				else if(final_timing[l] == 4){
						lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, PURPLE);
				}
			}
			left = left + step_width;
			right = right + step_width;
		}
		left = 0;
		right = step_width;
		top = top + (240/12);
		bottom = bottom + (240/12);
	}
}
Esempio n. 3
0
void gameOverScreen(Game *game, Level *level, Controller *userInput) {
	char extraMarks[50];
	
	
	lcd_fillScreen(BLACK);
	lcd_putString(95, 100, (unsigned char *)"GAMEOVER");
	lcd_putString(20, 200, (unsigned char *)"Insert 1 extra mark(s) for");
	lcd_putString(20, 210, (unsigned char *)"extra lives?");
	lcd_putString(20, 235, (unsigned char *)"-- Y (yes) / B (no)");
	memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
	pollController(userInput);
	while(!(userInput->y || userInput->b)) {
		pollController(userInput);
	}
	if(userInput->y) {
		level->levelOver = MARKS_INSERTED;
		game->extraMarks++;
		sprintf(extraMarks, "You have inserted %d extra", game->extraMarks);
		lcd_putString(20, 260, (unsigned char *)extraMarks);
		lcd_putString(20, 270, "mark(s) in total!");
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
		//mdelay(2000);
	}

}
Esempio n. 4
0
void lvlOutro(Game *game, Level *level, Controller *userInput) {
	char title[50];
	char score[50];
	char livesLeft[50];
	char hitRatioPercent[50];
	char print = FALSE;
	float hitRatio = (float)level->hits/(float)level->numberOfFires;
	playMusic(theme2,TRUE);
	game->score *= hitRatio;
	
	
	sprintf(title, "LEVEL %d PERFORMANCE", game->levelNum);
	sprintf(score, 		"Score: 		%d", game->score);
	sprintf(livesLeft, 	"Remaining lives: %d", level->player.lives);
	sprintf(hitRatioPercent, "Hit and Miss Ratio: %.2lf%%", hitRatio*100);
		
	while(!userInput->start) {
		// wait for start button
		lcd_fillScreen(BLACK);
		lcd_putString( 50, 50, (unsigned char *)title );
		lcd_putString(50, 100, (unsigned char *)score);
		lcd_putString(50, 110, (unsigned char *)livesLeft);
		lcd_putString(50, 120, (unsigned char *)hitRatioPercent);

		if(game->seed%10 == 0) {
			print = !print;
		}
		if(print) {
			lcd_putString(50, 300, "Press START to continue...");
		}
		game->seed++;
		pollController(userInput);
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
	}
}
Esempio n. 5
0
/*****************************************************************************
 *
 * Description:
 *    Sets up LCD. Required before using LCD.
 *
 * Params:
 *    None
 ****************************************************************************/
void LCDSetup (void) {
	//Setup external SDRAM. Used for Frame Buffer
	sdramInit();	
	
	//Setup LPC2478 LCD Controller for our specific LCD
	//lcd_config is defined in lcd/lcd_cfg.h
	lcdInit(&lcd_config); 
	
	//Turn the LCD on
	lcdTurnOn();
	
	lcd_fillScreen(BLACK);
}
Esempio n. 6
0
void credits (Controller *userInput) {
	
	int i = DISPLAY_HEIGHT;
	playTheme();
	pollController(userInput);
	
	while((!userInput->x) && (i+70 > 0)) {
		lcd_fillScreen(BLACK);
		lcd_putString(DISPLAY_WIDTH/2-20, i, "CREDITS");
		lcd_putString(20, i + 30,    "Shanush and James -- Team Atari");
		lcd_putString(20, i + 50, "           Victor -- Example Project");
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
		pollController(userInput);
		i-=2;
	}
	
	stopMusic();
	mdelay(5000);
}
Esempio n. 7
0
// Renders the screen to the correct layout for playback mode using the current sequence[], currentlySelectedSequence variable and final_timing[] array.
void setupPlaybackMode () {
	// Filling the screen as this function is used as a setup function when changing modes.
	lcd_fillScreen(LIGHT_GRAY);
	lcd_fillRect(180, 0, 240, 320, DARK_GRAY);
	
	// Visually showing the sequence currently in use.
	for(k=0; k<9; k++) {
		if(currentlySelectedSequence == k) {
			lcd_fillRect(185, (35*k) + 5, 235, (35*k) + 35, MAGENTA);
		}
		else {
			lcd_fillRect(185, (35*k) + 5, 235, (35*k) + 35, LIGHT_GRAY);
		}
	}
	// Setting up the graphic bars for the sequence in use.
	displayNoteBars();
	// Setup BPM visual display.
	updateBPMVisuals();
	// Setup octave visual display.
	updateOctaveVisuals();
}
Esempio n. 8
0
void drawBackground(Position *stars){
	
	int row,col,xPos = 0;
	lcd_fillScreen(BLACK);
	
	// Fill stars 
	for (row = stars->y; row < DISPLAY_HEIGHT; row += STAR_SPACING_HEIGHT) { 
		for (col = stars->x; col < DISPLAY_WIDTH; col++) { 
			if (xPos%STAR_SPACING_WIDTH == /*(row%2)*/ 0) { 
				lcd_point(col,row,WHITE); 
			} 
      xPos++; 
		} 
	} 
	
	// Increment for the next time 
	if (stars->y == STAR_SPACING_HEIGHT*2) { 
		stars->y = 0; 
	} else { 
		stars->y++; 
	}	
}
Esempio n. 9
0
void processGame (game* g) {   // Processes the collisions in the game.
	int distance;
	volatile int x1, y1, z1;
	volatile char i = 0;
	
	// Check if the player has collided with a token.
	// Uses pythgoras to check for collisions between circles.
  if (g->swagToken.duration > 0) {
			x1 = (g->player.playerPosition.x - g->swagToken.debuffPosition.x);
			y1 = (g->player.playerPosition.y - g->swagToken.debuffPosition.y);
			z1 = (DEFAULT_PLAYER_SIZE + g->swagToken.debuffSize);
			distance = (x1*x1)+(y1*y1);
			if (distance <= (z1*z1)) {
				g->swagToken.duration = INACTIVE;
				g->player.totalSwag++;
				g->score += SWAG_POINTS;
			}
	}
	
	// Check if the player has collected a certain amount of tokens, and if so,
	// give the player a random buff:
	// 1) Invincibility
	// 2) Super Speed
	// 3) Full Heal
	if ((g->player.totalSwag % NUM_TOKENS_FOR_BUFF == 0)&&(g->player.totalSwag > 0)) {
		i = rand()%3;
		if (i == 0) {
			g->player.invincibleCounter = SWAG_INVINCIBILITY_TIME;
			lcd_fillScreen(YELLOW);
			g->player.totalSwag++;
		} else if (i == 1) {
			g->player.speedCounter = SUPER_SPEED_TIME;
			lcd_fillScreen(WHITE);
			g->player.totalSwag++;
		} else {
			g->player.health = STARTING_HEALTH;
			lcd_fillScreen(GREEN);
			g->player.totalSwag++;
		}
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600);
	}
	
  // This for-loop updates the positions/directions/duration of all the obstacles in the game:
	// a) Saw Blades (position and direction)
	// b) Firepits (duration)
	// c) Mudpits (duration)
	for (i=0; i<5; i++) {	
		// Update the positions & directions (if necessary) of all the saw blades.
		if (g->blades[i].active == ACTIVE) {
			if (g->blades[i].spawnTimer == 0) {
				if (((g->blades[i].bladePosition.x + g->blades[i].bladeSize) >= 240)||((g->blades[i].bladePosition.x - g->blades[i].bladeSize)<= 0)) {
						g->blades[i].bladeSpeed.x = -(g->blades[i].bladeSpeed.x);
				}
				if (((g->blades[i].bladePosition.y + g->blades[i].bladeSize) >= 320)||((g->blades[i].bladePosition.y - g->blades[i].bladeSize) <= 0)) {
					g->blades[i].bladeSpeed.y = -(g->blades[i].bladeSpeed.y);
				}
			} else {
				g->blades[i].spawnTimer--;
			}
			g->blades[i].bladePosition.x += g->blades[i].bladeSpeed.x;
			g->blades[i].bladePosition.y += g->blades[i].bladeSpeed.y;
		}
	
	// Update the remaining duration of any active firepits.
	if (g->firepits[i].duration > 0) {
			g->firepits[i].duration--;
		}	
	}	

	// This checks for collisions between the player and all active 'blades' and 'firepits'.
	// Player loses 1hp for a given collision and is then given temporary invincibility for about 1.5 seconds.
	// The screen will flash red when the player loses health.
	for (i=0; i<10; i++) {
		if ((i < 5)&&(g->blades[i].active == ACTIVE)) {
			x1 = (g->player.playerPosition.x - g->blades[i].bladePosition.x);
			y1 = (g->player.playerPosition.y - g->blades[i].bladePosition.y);
			z1 = (DEFAULT_PLAYER_SIZE + g->blades[i].bladeSize);
		} else if ((i>=5)&&(g->firepits[i-5].debuffSize == g->firepits[i-5].targetSize)&&(g->firepits[i-5].duration > 0)) {
				x1 = (g->player.playerPosition.x - g->firepits[i-5].debuffPosition.x);
				y1 = (g->player.playerPosition.y - g->firepits[i-5].debuffPosition.y);
				z1 = (DEFAULT_PLAYER_SIZE + g->firepits[i-5].debuffSize);
		} else {
			x1 = 1;
			y1 = 1;
			z1 = 0;
		}
		distance = (x1*x1)+(y1*y1);
		if ((distance <= (z1*z1)) && (g->player.invincibleCounter == 0)) {
			g->player.health--;
			g->player.invincibleCounter = TEMP_INVINCIBILITY_TIME;
			lcd_fillScreen(RED);
			memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600);
		} else if (g->player.invincibleCounter > 0) {
			g->player.invincibleCounter--;
		}
	}
}
Esempio n. 10
0
void drawGame (game* g) {

	volatile char i = 0;
	lcd_fillScreen(DARK_GRAY);
	
	//Draw the mudpits onto the screen.
	if (g->mudpit1.duration > 0) {
		lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize, BROWN);
		lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -1, BROWN);
		lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -2, BROWN);
		lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -3, BROWN);
		lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -4, BROWN);
		lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -6, BROWN);
		lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -8, BROWN);
	}
	if (g->mudpit2.duration > 0) {
		lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize, BROWN);
		lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -1, BROWN);
		lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -2, BROWN);
		lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -3, BROWN);
		lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -4, BROWN);
		lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -6, BROWN);
		lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -8, BROWN);
	}
	
	//Draw the firepits onto the screen.
	for (i=0; i<5; i++) {
		if (g->firepits[i].duration > 0) {
			if (g->firepits[i].debuffSize < g->firepits[i].targetSize) {
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize, RED);
				g->firepits[i].debuffSize++;
			} else if (g->firepits[i].debuffSize == g->firepits[i].targetSize) {
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize, RED);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 1, RED);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 2, RED);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 4, ORANGE);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 6, ORANGE);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 8, ORANGE);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 10, LIGHT_YELLOW);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 12, LIGHT_YELLOW);
				lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 14, LIGHT_YELLOW);
			}	
		}
	}
	
	//Draw the blades onto the screen.
	for (i=0; i<5; i++) {
		if (g->blades[i].active == ACTIVE) {
			lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize, WHITE);
			lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 1, WHITE);
			lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 2, LIGHT_GRAY);
			lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 3, LIGHT_GRAY);
			lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 4, DARK_GRAY);
			lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 5, DARK_GRAY);
	  }
	}
	
	if (g->swagToken.duration > 0) {
		lcd_picture((unsigned short)g->swagToken.debuffPosition.x - 10,(unsigned short)g->swagToken.debuffPosition.y - 10, 20, 20, swagToken);
	}

}
Esempio n. 11
0
static portTASK_FUNCTION( vLcdTask, pvParameters )
{
	unsigned int pressure;
	unsigned int xPos;
	unsigned int yPos;
	//portTickType xLastWakeTime;
	
	int step_width = 320/sequence_steps;
	int step_height = 240/numNotes;
	int left, bottom = 0;
	int right = step_width;
	int top = step_height;
	
	int i, n, x;
	int waiting = 0;
	
	int newlySelectedSequence = 0;
	
	int prevMode = 0;
	int prevSeq = 0;

	/* Just to stop compiler warnings. */
	( void ) pvParameters;

	/* Initialise LCD display */
	/* NOTE: We needed to delay calling lcd_init() until here because it uses
	 * xTaskDelay to implement a delay and, as a result, can only be called from
	 * a task */
	lcd_init();
	
	lcd_fillScreen(LIGHT_GRAY);
	
	/* Initial LCD display */
	setupScreen(step_width,left, bottom,right,top);

	/* Infinite loop blocks waiting for a touch screen interrupt event from
	 * the queue. */
	 
	while(1)
	{
		/* Clear TS interrupts (EINT3) */
		/* Reset and (re-)enable TS interrupts on EINT3 */
		EXTINT = 8;						/* Reset EINT3 */

		/* Enable TS interrupt vector (VIC) (vector 17) */
		VICIntEnable = 1 << 17;			/* Enable interrupts on vector 17 */

		/* Block on a queue waiting for an event from the TS interrupt handler */
		xSemaphoreTake(xLcdSemphr, portMAX_DELAY);
				
		/* Disable TS interrupt vector (VIC) (vector 17) */
		VICIntEnClr = 1 << 17;

		/* Measure next sleep interval from this point */
		//xLastWakeTime = xTaskGetTickCount();
		
		// When switching sequences in edit mode.
		if(mode == 2){
			setupScreen(step_width,0, 0,step_width,step_height);
			mode = 0;
		}
		// Switching from playback mode to edit mode, screen must be setup.
		if((prevMode == 1) && (mode == 0)){
			setupScreen(step_width,0, 0,step_width,step_height);
		}
		// Switching from edit mode to playback mode.
		else if((prevMode == 0) && (mode == 1)) {
			setupPlaybackMode();
		}
		
		prevMode = mode;
		
		/*** EDIT MODE ***/
		/*****************/
		if(mode != 1) {
			/* Start polling the touchscreen pressure and position ( getTouch(...) ) */
			/* Keep polling until pressure == 0 */
			getTouch(&xPos, &yPos, &pressure);
			while (pressure > 0)
			{
				// Button debounce on screen touch.
				waiting = 0;
				while(waiting<100000) {
					waiting++;
				}
				// Iterating through each row.
				for(i=0; i<numNotes; i++) {
					if((xPos < top) && (xPos > bottom)) {
						// If touch within bounds of row i, check for the corresponding column.
						for(n=0; n<sequence_steps; n++) {
							if((yPos < right) && (yPos > left)){
								// Render column cells to clear previously selected cell and set up newly selected or change previously selected note time.
								for(x=0; x<numNotes;x++){
									lcd_fillRect((x*step_height), (n*step_width), (x*step_height)+step_height, ((n*step_width)+step_width), LIGHT_GRAY);
									lcd_drawRect((x*step_height), (n*step_width), (x*step_height)+step_height, ((n*step_width)+step_width), DARK_GRAY);
									if(x != i){
										// Majority of cells will have no note.
										timing[x][n] = 0;
									}
								}
								if(timing[i][n]==0 || timing[i][n]==1){
									timing[i][n]++;
								}
								else {
									timing[i][n] = timing[i][n] + 2;
								}
								if (timing[i][n] > 4){
									timing[i][n] = 0;
								}
								final_timing[n] = timing[i][n];
							  
								if(timing[i][n] == 1){
									// Full note.
									lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, MAROON);
								}
								else if(timing[i][n] == 2){
									// Half note.
									lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, OLIVE);
								}
								else if(timing[i][n] == 4){
									// Quarter note.
									lcd_fillRect(bottom + 4, left + 4, top - 4, right - 4, PURPLE);
								}
								sequence[n] = i;
							}
							left = left + step_width;
							right = right + step_width;
						}	
					}
					left = 0;
					right = step_width;
					top = top + step_height;
					bottom = bottom + step_height;
				}
				step_width = 320/sequence_steps;
				bottom = 0;
				left = 0;
				right = step_width;
				top = step_height;
				
				getTouch(&xPos, &yPos, &pressure);
			}
		}
		/*** PLAYBACK MODE ***/
		/*********************/
		else {
			/* Start polling the touchscreen pressure and position ( getTouch(...) ) */
			/* Keep polling until pressure == 0 */
			getTouch(&xPos, &yPos, &pressure);
			while (pressure > 0)
			{
				// Bound touch area for more efficiency.
				if((xPos < 235) && (xPos > 185)){
					// Select current sequence.
					for(i=0; i<9; i++) {
						if(((xPos < 235) && (xPos > 185)) && ((yPos < (35*i) + 35) && (yPos > (35*i) + 5))){
							// If a new sequence selected, must save the one that's currently in use to the listOfSequences[][] and listOfTimingSequences[][]
							// and then reinitialise the current sequence[] to the relative one in listOfSequences[][] and listOfTimingSequences[][].
							newlySelectedSequence = i;
							if(newlySelectedSequence != currentlySelectedSequence) {
								lcd_fillRect(185, (35*currentlySelectedSequence) + 5, 235, (35*currentlySelectedSequence) + 35, LIGHT_GRAY);
								lcd_fillRect(185, (35*newlySelectedSequence) + 5, 235, (35*newlySelectedSequence) + 35, MAGENTA);
								for(n=0;n<sequence_steps;n++){
									listOfSequences[currentlySelectedSequence][n] = sequence[n];
									listOfTimingSequences[currentlySelectedSequence][n] = final_timing[n];
								}
								currentlySelectedSequence = newlySelectedSequence;
								for(n=0;n<sequence_steps;n++){
									sequence[n] = listOfSequences[currentlySelectedSequence][n];
									final_timing[n] = listOfTimingSequences[currentlySelectedSequence][n];
								}
							}
						}
					}
				}
				getTouch(&xPos, &yPos, &pressure);
			}
			// Prevent flicker.
			if(prevSeq != currentlySelectedSequence){
				// Only fill part of screen to reduce flicker.
				lcd_fillRect(0, 0, 175, 320, LIGHT_GRAY);
				// Setup note bars for current sequence[] and final_timing[].
				for(i=0; i<sequence_steps; i++) {
					if(sequence[i] != numNotes) {
						if(final_timing[i]==1){
							lcd_fillRect(0, (i*31)+5, ((sequence[i]+1)*11), (i*31)+31, MAROON);
						}
						else if(final_timing[i]==2){
							lcd_fillRect(0, (i*31)+5, ((sequence[i]+1)*11), (i*31)+31, OLIVE);
						}
						else if(final_timing[i]==4){
							lcd_fillRect(0, (i*31)+5, ((sequence[i]+1)*11), (i*31)+31, PURPLE);
						}
					}
				}
				// Setup BPM visual display.
				updateBPMVisuals();
				// Setup octave visual display.
				updateOctaveVisuals();
			}
			prevSeq = currentlySelectedSequence;
		}
	}
}
Esempio n. 12
0
int titleScreen (Controller *userInput, int highestScore, int *numberOfLives, char *shipType)  {
	char print = TRUE;
	Position star;
	int seed = 1;
	int i = 0;
	char score[50];
	
	unsigned short *universianArray[SPLASH_FRAMES];
	universianArray[0] = Universian1;
	universianArray[1] = Universian2;
	universianArray[2] = Universian3;
	universianArray[3] = Universian4;
  universianArray[4] = Universian5;
	universianArray[5] = Universian6;
	
	lcd_fillScreen(BLACK);
	
	memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
	
	star.x = 0;
	star.y = 0;
	
	mdelay(300);
	playTheme();
		
	for (i = 0; i < SPLASH_FRAMES; i++) {
		drawBackground(&star);
		lcd_BMP(DISPLAY_WIDTH/2, SPLASH_HEIGHT, -(0.5), -(0.5), universianArray[i], TRUE, FALSE);
		
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
		
		mdelay(SPLASH_DELAY);
	}
	
	mdelay(1000);
	
	
	sprintf(score, "Highest Score: %9d", highestScore);
	
	while(!userInput->start) {
		// wait for start button
		drawBackground(&star);
		drawShip(INIT_SHIP_POS_X, INIT_SHIP_POS_Y, DEFAULT_SHIP_TYPE);
		lcd_BMP(DISPLAY_WIDTH/2, SPLASH_HEIGHT, -(0.5), -(0.5), Universian6, TRUE, FALSE);
		if(seed%BLINK_RATE == 0) {
			print = !print;
		}
		if(print) {
			lcd_putString(50, 300, "Press START to continue...");
			//lcd_putString(50, SPLASH_HEIGHT+27, "Press START to continue...");
			//lcd_putString(50, 300, "Press START to continue...");
		}
		lcd_putString(50, SPLASH_HEIGHT+37, (unsigned char *)score);
		lcd_putString(50, SPLASH_HEIGHT+55, "         Made by");
		lcd_putString(50, SPLASH_HEIGHT+65, "    James Slack-smith");
		lcd_putString(50, SPLASH_HEIGHT+75, "Shanush Prema Thasarathan");
		seed++;
		pollController(userInput);
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
		/*
		if (userInput->select) {
			selectMenu(userInput, numberOfLives, shipType);
		}
		*/
		mdelay(100);
		pollController(userInput);
		
	}
	stopMusic();
	mdelay(500);
	
	
	return seed;
}
Esempio n. 13
0
void selectMenu (Controller *userInput, int *numberOfLives, char *shipType) {
	
	int i = 0;
	int seed = 1;
	int print = TRUE;
	
	pollController(userInput);
	
	do {
		lcd_fillScreen(BLACK);
		if (userInput->left && *numberOfLives > 3) {
			(*numberOfLives)--;
		} else if (userInput->right && *numberOfLives < 5) {
			(*numberOfLives)++;
		} else if (userInput->left_shoulder) {
			*shipType = NUMBER_OF_SHIPS;
		} else if (userInput->right_shoulder) {
			*shipType = 1;
		}
		
		lcd_putString(LEFT_ALIGN, TOP_ITEM, "NUMBER OF LIVES");
		for (i = 0; i < *numberOfLives; i++) {
			lcd_BMP( LEFT_ALIGN, TOP_ITEM+15, 1*(i+1), 0,Heart, TRUE, FALSE);
		}
		lcd_putString(LEFT_ALIGN, TOP_ITEM+34, "Right and left to increase and");
		lcd_putString(LEFT_ALIGN, TOP_ITEM+44, "decrease lives");
		
		
		lcd_putString(LEFT_ALIGN, TOP_ITEM+60, "Ship sprite");
		switch (*shipType) {
			case 1:
				lcd_BMP(DISPLAY_WIDTH/2, TOP_ITEM+90, -(0.5), -(0.5), ship1, TRUE, TRUE);
				break;
			default:
				lcd_BMP(DISPLAY_WIDTH/2, TOP_ITEM+90, -(0.5), -(0.5), ship2, TRUE, FALSE);
				break;
		}
		
		lcd_putString(LEFT_ALIGN, TOP_ITEM+110, "Left and Right shoulder to ");
		lcd_putString(LEFT_ALIGN, TOP_ITEM+120, "change ship");
		
		// Controls
		lcd_putString(LEFT_ALIGN, CONTROL_LIST, 	 "------------------------------");
		lcd_putString(LEFT_ALIGN, CONTROL_LIST+10, "Game Controls");
		
		lcd_putString(LEFT_ALIGN, CONTROL_LIST+30, "A     - fire 1");
		lcd_putString(LEFT_ALIGN, CONTROL_LIST+40, "B     - fire 2");
		lcd_putString(LEFT_ALIGN, CONTROL_LIST+50, "D PAD - ship movement");
		lcd_putString(LEFT_ALIGN, CONTROL_LIST+60, "START - pause");
		
		
		if(seed%BLINK_RATE == 0) {
			print = !print;
		}
		if(print) {
			lcd_putString(50, 300, "Press START to continue...");
			//lcd_putString(50, SPLASH_HEIGHT+27, "Press START to continue..."); 
			//lcd_putString(50, 300, "Press START to continue...");
		}
		
		seed++;
		
		memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
		pollController(userInput);
		
		mdelay(50);
		
	} while (userInput->start == FALSE);
}
Esempio n. 14
0
void pauseMenu (void) {
	lcd_fillScreen(BLACK);
	lcd_putString(50,50,"Level paused");
	lcd_putString(50, 70, "Skip Level: A");
	memcpy((char*)LCD_FRAME_BUFFER,(char*)LCD_TEMP_BUFFER, 153600); // write temp buffer to fram buffer
}