示例#1
0
BUTTON_STATE keyState(int key) {
#ifdef _DEBUG
	return true;
#else
	switch(theButton[key]) {
		case B_OFF:
			if(keyHit(1<<key)) 
				theButton[key] = B_PRESSED;
			break;
		case B_PRESSED:
			if(keyHit(1<<key)) 
				theButton[key] = B_ON;
			else
				theButton[key] = B_RELEASED;
			break;
		case B_ON:
			if(!keyHit(1<<key)) 
				theButton[key] = B_RELEASED;
			break;
		case B_RELEASED:
			if(keyHit(1<<key)) 
				theButton[key] = B_PRESSED;
			else
				theButton[key] = B_OFF;
			break;
	}
	return theButton[key];
#endif
}
示例#2
0
uint8_t _keyHit()
{
  if(keyHit())
  {
    if(LastKey==STARKEY)return 0; // ignore shift key
    return 1;
  }else  return 0;
}
示例#3
0
uint8_t keyPressed()
{
  uint8_t temp;
  if(keyHit())
  {

    temp=__keyPressed();
    if(temp!=STARKEY) LastInKey=temp;
    else LastInKey=NOKEY;
    if(LastInKey==NOKEY) return 0;
    else return 1;
  }
  return 0;
}
示例#4
0
void pause()
{
  while(keyHit(BUTTON_START));
  while(!keyHit(BUTTON_START));
  while(keyHit(BUTTON_START));
}
示例#5
0
bool Game::cursesMain()
{
    initscr();
    noecho();
    curs_set(FALSE);
    nodelay(stdscr, TRUE);
    keypad(stdscr,TRUE);
    srand(time(NULL));

    // Coloring the screen
    start_color();
    init_pair(1, COLOR_WHITE, COLOR_RED); // border
    init_pair(2, COLOR_GREEN, COLOR_GREEN); // barrier
    init_pair(3, COLOR_GREEN, COLOR_BLACK); // player
    init_pair(4,   COLOR_RED, COLOR_BLACK); // boss

    // set up initial windows
    getmaxyx(stdscr, parent_y, parent_x);

    //set default space
    player.lives = 3;
    player.score = 0;
    player.x = 14;
    player.y = parent_y - (score_size + 3);

    WINDOW *field = newwin(parent_y - score_size, parent_x, 0, 0);
    WINDOW *score = newwin(score_size, parent_x, parent_y - score_size, 0);

    drawBorders(score);
    buildGame(board);

    int alienCount = 0;
    for(int i = 0; i < BOARDROWSIZE;i++)
    {
        for(int j = 0; j < BOARDCOLUMNSIZE;j++)
        {
            char temp = board[i][j];
            wmove(field, i, j);
            waddch(field, temp);
            if(temp == ALIEN1 || temp == ALIEN2 || temp == ALIEN3)
                alienCount++;
//            mvwprintw(field, i, j, "%c", board[i][j]);
        }
    }
    numberOfAliens = alienCount;
    rawtime = time(NULL);
    alienGroup.waitTime = rawtime+8;
    // uncomment for cout
    // /*
    while(1)
    {
        getmaxyx(stdscr, new_y, new_x);

        if (new_y != parent_y || new_x != parent_x)
        {
            parent_x = new_x;
            parent_y = new_y;

            wresize(field, new_y - score_size, new_x);
            wresize(score, score_size, new_x);
            mvwin(score, new_y - score_size, 0);

            wclear(stdscr);
            wclear(field);
            wclear(score);

            drawBorders(score);
        }

//        board[20][18] = 'O';
        // draw to our windows
        for(int i = 0; i < BOARDROWSIZE;i++)
        {
            for(int j = 0; j < BOARDCOLUMNSIZE;j++)
            {
                char piece = board[i][j];
//                writeToFile("%c", piece);
                wmove(field, i, j);
                // check if our bullet should be seen
                if(board[i][j] == BULLET && player.bullet.enabled == true)
                    waddch(field, board[i][j]);
                // if it shouldnt be seen then we remove it
                else if(board[i][j] == BULLET && player.bullet.enabled == false)
                {
                    waddch(field, ' ');
                    board[i][j] = ' ';
                    wmove(field, i-1, j);
                    waddch(field, ' ');
                    board[i-1][j] = ' ';
                    wmove(field, i, j);
                }
                // print everything else
                else
                {
                    // color certain pieces
                    switch(piece)
                    {
                        //border
                        case '+':
                        case '-':
                        case '|':
                            waddch(field, piece | COLOR_PAIR(1));
                            break;
                        // barriers
                        case '/':
                        case '\\':
                        case '#':
                            waddch(field, piece | COLOR_PAIR(2));
                            break;
                        //player
                        case 'A':
                            waddch(field, piece | COLOR_PAIR(3));
                        default:
                            waddch(field, piece);
                    }
                }
            }
//            writeToFile("\n");
        }

        // Draw score board
        mvwprintw(score, 1, 2, "Score: ");
        mvwprintw(score, 1, 9, itoa(player.score, buffer, 10));
        mvwprintw(score, 1, 70, "Lives: ");
        mvwprintw(score, 1, 77, itoa(player.lives, buffer, 10));

        if(DEBUG == true)
        {
            string screensizex = itoa(new_x, buffer, 10);
            string screensizey = itoa(parent_y, buffer, 10);
            mvwprintw(score, 1, 30, "X: ");
            mvwprintw(score, 1, 34, screensizex.c_str());
            mvwprintw(score, 1, 40, "Y: ");
            mvwprintw(score, 1, 44, screensizey.c_str());
        }

        bool aliensMovement = true;
        aliensMovement = moveAliens(rawtime);
        alienShoot();
        if(player.bullet.enabled == true)
        {
            if(player.bullet.direction == 'U') // safety check
            {
                timerCheck = clock()-timer;
                if(timerCheck > 15)
                {
                    if(DEBUG == true)
                        writeToFile("Current: %i,%i | New: %i,%i\n", player.bullet.x, player.bullet.y, player.bullet.x-1, player.bullet.y);
                    char temp = board[player.bullet.x-1][player.bullet.y];
                    char temp2 = board[player.bullet.x-1][player.bullet.y+1];
                    switch(temp)
                    {
                        // all these will trigger the last case
                        case 'S':
                        case '@':
                        case '%':
                        case '&':
                        case '#':
                        case '/':
                        case '\\':
                        case '+': // most likely never reach here
                        case '|':
                            if(DEBUG == true)
                                writeToFile("Collision with [%c]\n", temp);
                            if(temp == ALIEN1)
                            {
                                player.score += 10;
                                numberOfAliens--;
                            }
                            else if(temp == ALIEN2)
                            {
                                player.score += 20;
                                numberOfAliens--;
                            }
                            else if(temp == ALIEN3)
                            {
                                player.score += 40;
                                numberOfAliens--;
                            }
                            else if(temp == BOSS)
                            {
                                player.score += 150;
                            }
                            temp = ' ';
                            temp2 = ' ';
                            player.bullet.enabled = false;
                            break;
                        case '-':
                            if(DEBUG == true)
                                writeToFile("Bullet hits wall\n");
                            player.bullet.enabled = false;
                            board[player.bullet.x][player.bullet.y] = ' ';
                            break;
                        default: // spaces and whatnot
                            if(DEBUG == true)
                                writeToFile("%i,%i = %c\n%i,%i\n",player.bullet.x,player.bullet.y-1,board[player.bullet.x][player.bullet.y],player.bullet.x,player.bullet.y);
                            board[player.bullet.x-1][player.bullet.y] = BULLET;
                            board[player.bullet.x][player.bullet.y] = ' ';
                            player.bullet.x = player.bullet.x-1;
                            break;
                    }
                    timer = clock();
                }
            }
        }
        for(int x = 1;x<5;x++)
        {
            timerCheck = clock()-timer;
            if(timerCheck > 50)
            {
                char temp = ' ';
                switch(x)
                {
                    case 1:
                        temp = board[alienGroup.alienBullet1.x+1][alienGroup.alienBullet1.y];
                        if(alienGroup.alienBullet1.enabled == true)
                        {
                            switch(temp)
                            {
                                case '/':
                                case '\\':
                                case '#':
                                    temp = ' ';
                                    alienGroup.alienBullet1.enabled = false;
                                    board[alienGroup.alienBullet1.x][alienGroup.alienBullet1.y] = ' ';
                                    alienGroup.missles--;
                                    break;
                                case 'A':
                                    player.lives--;
                                    board[player.x][player.y]= ' ';
                                    player.x = 14;
                                    player.y = parent_y - (score_size + 3);
                                    board[player.x][player.y] = PLAYER;
                                    alienGroup.missles--;
                                    break;
                                case '-':
                                    if(DEBUG == true)
                                        writeToFile("Bullet hits wall\n");
                                    alienGroup.alienBullet1.enabled = false;
                                    board[alienGroup.alienBullet1.x][alienGroup.alienBullet1.y] = ' ';
                                    alienGroup.missles--;
                                    break;
                                default:
                                    if(DEBUG == true)
                                        writeToFile("%i,%i = %c\n%i,%i\n",player.bullet.x,player.bullet.y-1,board[player.bullet.x][player.bullet.y],player.bullet.x,player.bullet.y);
                                    board[alienGroup.alienBullet1.x+1][alienGroup.alienBullet1.y] = ALIENBULLET;
                                    board[alienGroup.alienBullet1.x][alienGroup.alienBullet1.y] = ' ';
                                    alienGroup.alienBullet1.x = alienGroup.alienBullet1.x+1;
                                    break;
                            }
                            /*
                            if(temp == PLAYER)
                            {
                                player.lives--;
                                player.x = 14;
                                player.y = parent_y - (score_size + 3);
                                board[player.x][player.y] = PLAYER;
                                alienGroup.alienBullet1.enabled = false;
                                alienGroup.missles--;
                            }
                            else if(temp == BARRIERCORNER1 || temp == BARRIERCORNER2 || temp == BARRIERMAIN)
                            {
                                temp = ' ';
                                alienGroup.alienBullet1.enabled = false;
                                alienGroup.missles--;
                            }
                            else if(temp == '-')
                            {
                                alienGroup.alienBullet1.enabled = false;
                                alienGroup.missles--;
                            }
                            else
                            {
                                temp = BULLET;
                                board[alienGroup.alienBullet1.x][alienGroup.alienBullet1.y] = ' ';
                                alienGroup.alienBullet1.y += 1;
                            }*/
                        }
//                    case 2:

//                    case 3:

//                    case 4:
                    default:
                        break;
                }
            }
        }
        if(keyHit())
        {
            key = getch();
            keyChecker = keyCheck(key);
            if(keyChecker == true)
                break;
            // have code in CP
        }

        // refresh each window
        wrefresh(field);
        wrefresh(score);
        if(numberOfAliens == 0)
            break;
    }
    endwin();
    // */
    return true;
}
示例#6
0
void processCommand(const char *cmd) {
  int tmpx, tmpy, btn;
  float tmpInterval;
  UInt32 tmpkc;
  char str[CMD_STRING_MAXLEN];

  bzero(str, CMD_STRING_MAXLEN);
  if (IS_CMD(cmd, "mouselocation")) {

    CGPoint cgLoc = mouseLoc();
    printf("%.f %.f\n", cgLoc.x, cgLoc.y);

  } else if (IS_CMD(cmd, "mousewarp ")) {

    print_msg("Warping mouse to location.");
    sscanf(cmd, "mousewarp %d %d", &tmpx, &tmpy);
    mouseMove(tmpx, tmpy);

  } else if (IS_CMD(cmd, "mousemove ")) {

    print_msg("Moving mouse.");
    sscanf(cmd, "mousemove %d %d", &tmpx, &tmpy);
    mouseMoveTo(tmpx, tmpy, 0.7);

  } else if (IS_CMD(cmd, "mousedown")) {

    print_msg("Pressing mouse button.");
    sscanf(cmd, "mousedown %d", &btn);
    mousePress(btn, SINGLE_CLICK);

  } else if (IS_CMD(cmd, "mouseup")) {

    print_msg("Releasing mouse button.");
    sscanf(cmd, "mouseup %d", &btn);
    mouseRelease(btn, SINGLE_CLICK);

  } else if (IS_CMD(cmd, "mouseclick")) {

    print_msg("Clicking mouse.");
    sscanf(cmd, "mouseclick %d", &btn);
    mouseClick(btn, SINGLE_CLICK);

  } else if (IS_CMD(cmd, "mousedoubleclick")) {

    print_msg("Double-clicking mouse.");
    sscanf(cmd, "mousedoubleclick %d", &btn);
    mouseClick(btn, DOUBLE_CLICK);

  } else if (IS_CMD(cmd, "mousetripleclick")) {

    print_msg("Triple-clicking mouse.");
    sscanf(cmd, "mousetripleclick %d", &btn);
    mouseClick(btn, TRIPLE_CLICK);

  } else if (IS_CMD(cmd, "mousedrag ")) {

    print_msg("Dragging mouse.");
    sscanf(cmd, "mousedrag %d %d", &tmpx, &tmpy);
    mouseDrag(LEFT_MOUSE, tmpx, tmpy);

  } else if (IS_CMD(cmd, "press ")) {

    print_msg("Pressing key.");
    sscanf(cmd, "press %x", &tmpkc);
    keyPress((CGKeyCode)tmpkc, NULL);

  } else if (IS_CMD(cmd, "release ")) {

    print_msg("Releasing key.");
    sscanf(cmd, "release %x", &tmpkc);
    keyRelease((CGKeyCode)tmpkc, NULL);

  } else if (IS_CMD(cmd, "hit ")) {

    print_msg("Hitting key.");
    sscanf(cmd, "hit %x", &tmpkc);
    keyHit((CGKeyCode)tmpkc, NULL);

  } else if (IS_CMD(cmd, "type ")) {

    print_msg("Typing.");
    strncpy(str, &cmd[5], CMD_STRING_MAXLEN);
    typeString(str);

  } else if (IS_CMD(cmd, "wait")) {

    print_msg("Waiting.");
    sscanf(cmd, "wait %f", &tmpInterval);
    usleep(1000000 * tmpInterval);

  } else {

    print_msg("I don't know what you want to do.");

  }
}
示例#7
0
int main(void) {
	

	int r = 5; //player positions
	int c = 4;
	int r2 = 80; //first ball positions
	int c2 = 120;
	int human_speed = 2; //guess what this is?
	int width = 2; //dont bother, this is the frame width
	int human_size = 10; //duh
	int size = 10; //size of computer
	int dr = 3; //speed of player
	int dc = 3; //should = dr
	int agression; //not being used right now
	int inRange = 0; //a random count variable
	int human_health = 100; //human starting health
	int comp_health = 100; //computer starting health
	int newgame = 1; //another count var
	int loopCount = 0; 
	int numAttacks = 0; //number of times human attacks
	int justAttacked; //count var for computer attacks
	int result; //count var
	int death_radius = 4; //this is how many pixels the radius around the computer is that you have to be in to attack/be attacked
	int next_var1 = 0;
	int retreat = 0;
	int retreat_length = 100; //how long it is after going in to retreat mode that you win
	int next_var2 = 0;
	int junkVar = 0;

	//prebuild the binary search tree
	//make the data in each node be a pointer to a function, then the output of that function
	//decides which node is next

	
NaryNode *root = NULL;
root = createNaryNode(createIntData(0), 0); //make the root node (check health)
  appendChild(root, createNaryNode(createIntData(1), 0)); //make the first child (if health is ok)
  appendChild(root, createNaryNode(createIntData(2), 0)); //make the second child (if health is bad)
  appendChild(root->child[0], createNaryNode(createIntData(3), 0)); //treat the first child as the root and add another child
  appendChild(root->child[1], createNaryNode(createIntData(4), 0)); //treat the first child as the root and add another child
  appendChild(root->child[1]->child[4], createNaryNode(createIntData(5), 0)); //add another child on right parent

int *tree1;
int *tree2;
int *tree3;
tree1 = (int*)(root->child[1]);
(int*)(root->child[1]) = 4;
(int*)(root->child[0]) = 2;
(int*)(root->child[1]->child[4]) = 1;

//tree1 = root->child[1];

  /*
		[root]
		/	\
	[child1] ----------child 2]
	/	   \           \      \
 [child3]  [child4]	   [child5] [child6] 
  /			/	   \
[child7]   [child8] [child9]
			|			|
		  [child9]	   [child10]
  
  
  */
  

Junk first;
first.margin = 40; //the margin for death for the computer
first.comp_health_rate = 1; //how fast the you kill the computer
first.human_health_rate = 2; //how fast the computer kills you



	while(keepGoing()) {
		

		waitForVBlank(ON);
		switch (gameState) {
			case START:
				//start mode 4
				initializeGBA(MODE_4);
				FlipPage(ON);
				paintBackground(PressEnterBitmap);
				FlipPage(OFF);
				
				
				//in to mode 3
				GBASetup();
				initializeGBA(MODE_3);
				drawBackground(6);
				while(!keyHit(BUTTON_START)){
				
					while(keyHit(BUTTON_START)){
						break;}
				}
					
				//reset all the count vars and such
					newgame = 1;
					numAttacks = 0;
					loopCount = 0;
					justAttacked = 0;
					human_health = 100; //human starting health
					comp_health = 100; //computer starting health
					next_var1 = 0;
					next_var2 = 0;
					r = 5; //player positions
					c = 4;
					r2 = 80; //first ball positions
					c2 = 120;
					gameState = PLAY;
					retreat = 0;
				
				break;
			case PLAY:

				//start mode 3
				FlipPage(OFF);
				GBASetup();

				waitForVBlank(ON);
				loopCount++;
				drawRectDMA(0, 0, 160, 240, COLOR(0,0,0)); //the black background
				
				//nary tree usage
				tree3 = (int*)(root->child[1]);
				if(tree3){
					junkVar++;
				}


				if(comp_health < first.margin){
					gameState = WIN;
				}
				
				//frame
				drawRectDMA(1, 1, 240, 1, COLOR(0,0,31)); //left bar
				drawRectDMA(159, 1, 1, 240, COLOR(0,0,31));//bottom bar
				drawRectDMA(1, 1, 240, 1, COLOR(0,0,31));//bottom bar
				drawRectDMA(159, 1, 1, 240, COLOR(0,0,31));//bottom bar
				

				//draw health bars
				if(human_health == 100){
				drawRectDMA(5, 4, 1, 1, COLOR(0,0,31)); //human starting health
				drawRectDMA(5, 6, 1, 1, COLOR(0,0,31));
				drawRectDMA(5, 8, 1, 1, COLOR(0,0,31));
				}

				if(comp_health == 100){
				drawRectDMA(5, 230, 1, 1, COLOR(31,0,0)); //computer starting health
				drawRectDMA(5, 232, 1, 1, COLOR(31,0,0));
				drawRectDMA(5, 234, 1, 1, COLOR(31,0,0));
				//newgame = 0;
				}
				
				if((human_health < 100) && (human_health > 66)){
				drawRectDMA(5, 4, 1, 1, COLOR(0,0,31)); //human health 2/3
				drawRectDMA(5, 6, 1, 1, COLOR(0,0,31));
				drawRectDMA(5, 8, 1, 1, COLOR(0,0,0));
				}

				if((human_health < 66) && (human_health >33)){
				drawRectDMA(5, 4, 1, 1, COLOR(0,0,31)); //human health 1/3
				drawRectDMA(5, 6, 1, 1, COLOR(0,0,0));
				drawRectDMA(5, 8, 1, 1, COLOR(0,0,0));
				}

				if((human_health < 33) && (human_health >0)){
				drawRectDMA(5, 4, 1, 1, COLOR(0,0,0)); //human health 0/3
				drawRectDMA(5, 6, 1, 1, COLOR(0,0,0));
				drawRectDMA(5, 8, 1, 1, COLOR(0,0,0));
				}

				
				if((comp_health < 100) && (comp_health > 66)){
				drawRectDMA(5, 230, 1, 1, COLOR(31,0,0)); //computer health 2/3
				drawRectDMA(5, 232, 1, 1, COLOR(31,0,0));
				drawRectDMA(5, 234, 1, 1, COLOR(0,0,0));
				}

				if((comp_health < 66) && (comp_health > 33)){
				drawRectDMA(5, 230, 1, 1, COLOR(31,0,0)); //computer health 1/3
				drawRectDMA(5, 232, 1, 1, COLOR(0,0,0));
				drawRectDMA(5, 234, 1, 1, COLOR(0,0,0));
				}

				if((comp_health < 33) && (comp_health > 0)){
				drawRectDMA(5, 230, 1, 1, COLOR(0,0,0)); //computer health 0/3
				drawRectDMA(5, 232, 1, 1, COLOR(0,0,0));
				drawRectDMA(5, 234, 1, 1, COLOR(0,0,0));
				}

				waitForVBlank(ON);

			
			
				//player control
				//controls the boundries and the speed
				drawRectDMA( r, c, width, width, COLOR(0,0,0));
				
				if(keyHit(BUTTON_UP)) {
					r = r - human_speed;
					if(r <= 1) r = 2;
				}
				if(keyHit(BUTTON_DOWN)) {
					r = r + human_speed;
					if(r >= 159+human_size) r = 159;
				}
				if(keyHit(BUTTON_LEFT)) {
					c = c - human_speed;
					if(c <= 1) c = 2;
				}
				if(keyHit(BUTTON_RIGHT)) {
					c = c + human_speed;
					if(c >= 239+human_size) c = 239;
				}
			
						
				//start ball code (makes ball move)
				drawRectDMA( r2, c2, size, size, COLOR(0,0,0) );
				drawRectDMA( r2, c2, size, size, COLOR(0,0,31) );
				
				//collision detection
				//walls (make ball bounce)
			
				//computer bouncing
				
			if((r2+size) > 156) dr = -dr; //top
			if((c2+size) > 236) dc = -dc; //bottom and right
			if((c2+size) < 15) dc = -dc; //left
			if(((r2) <= 3) || ((r2) >= 158)) dr = -dr; //top and bottom
			

				
				//draw player square
				
				drawRectDMA( r, c, human_size, human_size, COLOR(0,0,0));
				
	
				drawRectDMA( r, c, human_size, human_size, COLOR(0,0,31) ); //the actual square

						
				//draw bouncing ball
				drawRectDMA( r2, c2, size, size, COLOR(31,0,0));
				

				//right wall
				drawRectDMA( 1, 238, 72 , width - 1, COLOR(0,0,31) ); 
				drawRectDMA( 87, 238, 73,  width - 1, COLOR(0,0,31) ); 
				
				//keep player in boundries
				if(r < 2) {
					r = 2;
				}
				if(r+size > (159)) {
					r = (148);
				}
				if((c+size > 239)) {
					c = 228;
				}

				if((c < 2)) {
					c = 2;
				}

				//keep computer in boundries
				//the computer boundry is smaller so he doesn't get stuck in corners
				if(r2 < 10) {
					r2 = 10;
				}
				if(r2+size >= (149)) {
					r2 = (138);
				}
				
				if((c2 < 10)) {
					c2 = 10;
				}
				
				if((c2+size > 229)) {
					c2 = 218;
				}


				//BEGIN AI
				

				//if the health is low	
				if((retreatCheck(comp_health,(first.margin)))){
					//retreat
					(int*)(root->child[1]) = 1;
	
				if(r < r2){
					r2 = r2 + 1;
				}

				if(r > r2){
					r2 = r2 - 1;
				}

				if(c < c2){
					c2 = c2 + 1;
				}

				if(c > c2){
					c2 = c2 - 1;
				}
				if(keyHit(BUTTON_A)){
			retreat = retreat + 1;
				}
			}


			//nary tree usage
			tree2 = (int*)(root->child[1]);
				if(tree2){
					junkVar++;
				}



				if(attackCheck(comp_health)){ //if health is ok
					//attack
						(int*)(root->child[0]) = 1;

					if(r < r2){
						r2 = r2 - 1;
					}

					if(r > r2){
						r2 = r2 + 1;
					}

					if(c < c2){
						c2 = c2 - 1;
					}

					if(c > c2){
						c2 = c2 + 1;
					}
				
				
					//see how aggressive the human is being
					agression = numAttacks/inRange;
					//see if the human is within striking distance
						if(inRadius(c2, death_radius, c, human_size, r2, r, size)){ //this function took forever to write

						inRange++;
						result = randGen();
						if(result){
						human_health = human_health - (first.human_health_rate);
						justAttacked++;
						}
					
						//If I ever get around to implementing this, this will allow the computer to retreat
						//when the human gets too aggressive

						/*
						if(agression > .15){
				

				//retreat
					if(r < r2){
						r2 = r2 + 1;
					}

					if(r > r2){
						r2 = r2 - 1;
					}

					if(c < c2){
						c2 = c2 + 1;
					}

					if(c > c2){
						c2 = c2 = 1;
					}

				}
				
			
*/
		
				//set up the health
				//computer (computer loses health under these conditions
					
				if(keyHit(BUTTON_A)){
						comp_health = (comp_health - (first.comp_health_rate));
						numAttacks++;
						
					}
				
			}
				}

				
				if(inRadius(c2, death_radius, c, human_size, r2, r, size)){
						if(retreat >= retreat_length){
					gameState = WIN;
				break;}
						if(human_health < 33){
							gameState = DIE;
							next_var2 = 1;
							break;
						}
				}
				
				break;

			case WIN: //if they make it past level 5, display a win screen and reset some variables
					drawBackground(7);
					if(junkVar){
						newgame = 1;
					}
				retreat = 0;
				if(keyHit(BUTTON_START)) {
					gameState = CREDITS; //next stop is the credits
				
				}
				while(keyHit(BUTTON_START)) {
					while(!keyHit(BUTTON_START)) {
						
					break; }
				next_var1 = 1;}
				
			
			break;

		case CREDITS: //display the Pony Shrapnel logo
				
			if(next_var1 == 1){
				
					drawBackground(8);
					
				
				if(keyHit(BUTTON_START)) {
					gameState = START; //next stop is the start screen
				
				}
				while(keyHit(BUTTON_START)) {
					while(!keyHit(BUTTON_START)) {
					break; }
				}
				}

			

		

		
			case DIE: //if they die, then display a death screen, reset some variables, and go back to the start screen
				
				if(next_var2){
				drawBackground(1);
					if(junkVar){
						newgame = 0;
					}
				
				if(keyHit(BUTTON_START)) {
					gameState = CREDITS2; //next stop is the credits2
				
				}
				while(keyHit(BUTTON_START)) {
					while(!keyHit(BUTTON_START)) {
						
					break; }
				}
				human_health = 100;}
				
			break;


		case CREDITS2: //display the Pony Shrapnel logo
				
			while(next_var2){
				
					drawBackground(8);
					
				
				if(keyHit(BUTTON_START)) {
					gameState = START; //next stop is the start screen
					next_var2 = 0;
				}
				while(keyHit(BUTTON_START)) {
					while(!keyHit(BUTTON_START)) {
					break; }
				}
				break;}

			



				//end switch statements


		
		}

	}
	return 0;
}