Exemple #1
0
//Main run, checks boundaries, wins, increments forward
void runSnake() {
	switch(dir) {
		case 1: //up
			if(checkBoundaryUp()) {
				//printf("GAME OVER\n");
				state = 0; // state 0 = game over
			}
			else
				incrementUp();
			break;
		case 2: //right
			if(checkBoundaryRight()) {
				//printf("GAME OVER\n");
				state = 0;
			}
			else
				incrementRight();
			break;
		case 3: //down
			if(checkBoundaryDown()) {
				//printf("GAME OVER\n");
				state = 0;
			}
			else
				incrementDown();
			break;
		case 4: //left
			if(checkBoundaryLeft()) {
				//printf("GAME OVER\n");
				state = 0;
			}
			else
				incrementLeft();
			break;
	}
}
Exemple #2
0
// MAKE IT RETURN A VALUE!
int main(void){
	incrementUp(START, STOP);		// part(a) function declaration
	incrementDown(START, STOP);		// part(b) function declaration
	getchar();
	return 0;
}