Пример #1
0
Файл: draw.c Проект: zear/g-ball
void drawMenu()
{
	drawBackground(8, 56, 8);
	//drawText("G-Ball", 130, 20, &FontLarge);
	//drawText("a g-sensor ball game", 110, 40, &FontSmall);
	logoDraw();

	menuDraw(CurrentMenu, 150, 100);
}
Пример #2
0
void draw()
{

    glColor4f(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT);

    switch(appState)
    {
    case APPSTATE_INTRO:
        drawImage(&images[IMG_INTRO], SCRW/2-images[IMG_INTRO].w/2,
                  SCRH/2-images[IMG_INTRO].h/2, NULL);
        break;

    case APPSTATE_MENU:
        menuDraw();
        break;

    case APPSTATE_GAME:

        levelDrawAllTheRest();

        itemsDraw();
        portalDraw();
        bulletDraw(1); /* bullets shot by player */
        playerDraw();
        idiotDraw();
        drunkenbotDraw();
        bulletDraw(0); /* all the rest */
        turretDraw();
        bossDraw();

        levelDrawForeground();

        /* Darkness layer here */
        if(currentLevel.flags & IS_DARK_LEVEL)
            drawImage(&images[IMG_DARKNESS], player.posX-(SCRW+STEP/2), player.posY-(SCRH+STEP/2), NULL);

        /* Boss' HP bar */
        bossDrawHPBar();

        break;

    case APPSTATE_GAMEOVER:

        gameoverDraw();
        break;
    }

    /* Text line */
    textDraw();

    SDL_GL_SwapBuffers();

}
Пример #3
0
void menu()
{
	int s = enter;
	if (!s)
		menuDraw();
	if(s)
	{
		if (!xs)
			plansza();
		if (xs)
			opcjeDraw();
	}
}
Пример #4
0
Файл: scn.c Проект: bqv/ntris
/** Main drawing function. */
void scnDisplay(tEngGame *pEngGame, tScnSet *pScnSet)
{
    /*  Local variables: */
    int n, x, y, z;        /*  loop counter; */

    /*  mask indicates which block space */
    /*  hidden by upper blocks */
    int mask[SPACESIZE][SPACESIZE][SPACESIZE];

    double camx, camy, camz;
    int pic, maxpic;

    maxpic = (pScnSet->viewMode > eScnViewMono) ? 2 : 1;

    for (pic = 0; pic < maxpic; pic++)
    {
        for (x = 0; x < pEngGame->size[0]; x++)
            for (y = 0; y < pEngGame->size[1]; y++)
                for (z = 0; z < pEngGame->size[2]; z++)
                {
                    mask[x][y][z] = 0;
                }

        if (pScnSet->viewMode == eScnViewStereogram)
        {
            camx = (pic == 0) ? 2 : -2;
            camy = scnCamera.c[1];
            camz = 2.0 * scnCamera.c[2];
        }
        else
        {
            camx = scnCamera.c[0];
            camy = scnCamera.c[1];
            camz = scnCamera.c[2];
        }

        g3dBeginDraw(camx, 0, camz, pic, pScnSet->viewMode == eScnViewAnaglyph);

        if ((pic == 0)
                || (pScnSet->viewMode == eScnViewAnaglyph))
        {
            scnDrawBG();
        }

        scnDrawGamespace(pEngGame, pScnSet, mask);

        scnDrawBottomLevel(mask, 1, pEngGame);

        scnDrawObject(pEngGame, pScnSet, 1);

        g3dSetTransparentMode(1);

        scnDrawGrid(pScnSet->enableGridDraw, pEngGame);

        scnDrawBottomLevel(mask, 0, pEngGame);

        scnDrawObject(pEngGame, pScnSet, 0);

        scnDrawCompass(pEngGame);

        scnDrawRotAxis(pScnSet->axle, pEngGame);

        g3dSetTransparentMode(0);

        if ((pic == maxpic-1)
                || (pScnSet->viewMode == eScnViewAnaglyph))
        {
            /*  Write out the game score. */
            scnWriteScore(pEngGame->score);

            /*  draw the menu */
            if (menuIsActived())
            {
                menuDraw();
            }
        }

        if (pic == maxpic-1)
        {
            for (n = 0; n < maxpic; n++)
            {
                g3dEndDrawPic();
                g3dEndDraw();
            }
        }
    }
}
Пример #5
0
void drawall(gamedata &g){

  int ypos;
  int ypos2;

  // Set screenheight
  int screenheight = 0;
  if (g.players == 1){
    screenheight = limit(GAME_HEIGHT,GAME_HEIGHT,240); //464);
  }else{
    screenheight = limit(GAME_HEIGHT,GAME_HEIGHT,120);
  }

  if(!g.scoreBarPos) // top
  {
	ypos = 0;
	ypos2 = 8;
  }
  else // bottom
  {
	ypos = screenheight - 16;
	ypos2 = screenheight - 8;
  }

  // Player 1
//  int x1 = limit(int(g.player1->x)-308, 0, GAME_WIDTH-320);
  int x1 = limit(int(g.player1->x)-160, 0, GAME_WIDTH-320);
  int y1 = limit(int(g.player1->y)-54, 0, GAME_HEIGHT-screenheight);
  SDL_Rect srcrect;
    srcrect.x = x1;
    srcrect.y = y1;
    srcrect.w = 320;
    srcrect.h = screenheight;
  SDL_BlitSurface(g.gamescreen, &srcrect, g.virtualscreen, NULL);
  SDL_Rect cliprect;
    cliprect.x = 0;
    cliprect.y = 0;
    cliprect.w = 320;
    cliprect.h = screenheight;
  SDL_SetClipRect(g.virtualscreen, &cliprect);
  drawblits(g,x1,y1);
  SDL_SetClipRect(g.virtualscreen, NULL);

  if (g.players == 1){
  if(GameState == STATE_GAME)
//	  display_playinfo(g.virtualscreen, 1, *g.player1, screenheight - 16, g.images, g.mission,
//                   g.targetscore, g.whitefont, g.greenfont, g);
	  display_playinfo(g.virtualscreen, 1, *g.player1, ypos, g.images, g.mission,
                   g.targetscore, g.whitefont, g.greenfont, g);
  }else{
  if(GameState == STATE_GAME)
	  display_playinfo(g.virtualscreen, 1, *g.player1, screenheight - 8, g.images, g.mission,
                   g.targetscore, g.whitefont, g.greenfont, g);
  }

/*
  display_playinfo(g.virtualscreen, 1, *g.player1, screenheight, g.images, g.mission,
                   g.targetscore, g.whitefont, g.greenfont, g);
*/

  // Player 2
  if (g.players == 2){
    int x2 = limit(int(g.player2->x)-160, 0, GAME_WIDTH-320);
    int y2 = limit(int(g.player2->y)-54, 0, GAME_HEIGHT-screenheight);//-208); //224);
    SDL_Rect srcrect;
      srcrect.x = x2;
      srcrect.y = y2;
      srcrect.w = 320;
      srcrect.h = screenheight;
    SDL_Rect desrect;
      desrect.x = 0;
      desrect.y = 120;
      desrect.w = 320;
      desrect.h = screenheight;
    SDL_BlitSurface(g.gamescreen, &srcrect, g.virtualscreen, &desrect);
    SDL_Rect cliprect;
      cliprect.x = 0;
      cliprect.y = 120;
      cliprect.w = 320;
      cliprect.h = screenheight;
    SDL_SetClipRect(g.virtualscreen, &cliprect);
    drawblits(g,x2,y2-120);
    SDL_SetClipRect(g.virtualscreen, NULL);

    if(GameState == STATE_GAME)
  	  display_playinfo(g.virtualscreen, 2, *g.player2, 240 - 8, g.images, g.mission,
                     g.targetscore, g.whitefont, g.greenfont, g);
/*
    display_playinfo(g.virtualscreen, 2, *g.player2, 464, g.images, g.mission,
                     g.targetscore, g.whitefont, g.greenfont, g);
*/
  }

  if(GameState == STATE_INTRO || GameState == STATE_MENU)
  {
	if(CurrentMenu == MenuMainIntro)
		menuDraw(CurrentMenu, 140, 100, g);
	else if(CurrentMenu == MenuMain)
		menuDraw(CurrentMenu, 120, 100, g);
	else if(CurrentMenu == MenuOptions)
		menuDraw(CurrentMenu, 110, 100,g);
	else if(CurrentMenu == MenuGameOptions)
		menuDraw(CurrentMenu, 20, 80, g);
	else
		menuDraw(CurrentMenu, 140, 100, g);
  }
  else if(GameState == STATE_MENU_PLANE_SELECT)
  {
	menuPlanesDraw(20, 10, g);
  }
  else if(GameState == STATE_MENU_PLAYER_CONTROL_SELECT)
  {
	menuSelectPlayerDraw(g);
  }

  // Best AI Score
  if (g.planes > g.players){
    plane bestp;
    bool found = false;
    g.p.reset();
    while (g.p.next()){
      if ((g.p().control == 0) && (g.p().side > 0)){
        if (!found){
          bestp = g.p();
          found = true;
        }else{
          if ((g.mission == 0) || (g.mission == 1)){
            if (g.p().score > bestp.score){
              bestp = g.p();
            }
          }else{
            if (g.p().targetscore < bestp.targetscore){
              bestp = g.p();
            }          
          }
        }
      }
    }
    // Display AI
    if(GameState == STATE_GAME){
	    SDL_Rect rect;
	    char compstring[] = "Plane x";
	    compstring[6] = '0' + bestp.side;

	    if (g.players == 1){
	        rect.x = 304;
	        rect.y = ypos;
	        rect.w = 16;
	        rect.h = 16;
	        SDL_FillRect(g.virtualscreen,&rect,16);
	        g.images[bestp.image+13].blit(g.virtualscreen,304,ypos);
		g.whitefont.write(g.virtualscreen, 24, ypos2, compstring);
	    }
	    else{
		// TODO: display the best player score
	    }
	    // Display score
	    if (g.players == 1){
	    display_score(g.virtualscreen, bestp, 112, ypos2, g.mission, g.targetscore,
		          g.whitefont, g.greenfont);
	    }else{
	    display_score(g.virtualscreen, bestp, 112, screenheight-8, g.mission, g.targetscore,
		          g.whitefont, g.greenfont);
	    }
    }

  }

  // Update screen display
  SDL_Rect rect;
    rect.x = 0;
    rect.y = 0;
    rect.w = 320;
    rect.h = 240;
  SDL_BlitSurface(g.virtualscreen, &rect, g.physicalscreen, NULL);

  //SDL_Flip(g.physicalscreen);
	if(SDL_MUSTLOCK(ScreenSurface)) SDL_LockSurface(ScreenSurface);
		SDL_Surface *p = SDL_ConvertSurface(g.physicalscreen, ScreenSurface->format, 0);
		SDL_SoftStretch(p, NULL, ScreenSurface, NULL);
	if(SDL_MUSTLOCK(ScreenSurface)) SDL_UnlockSurface(ScreenSurface);
		SDL_Flip(ScreenSurface);
		SDL_FreeSurface(p);
  //SDL_UpdateRect(g.physicalscreen, 0, 0, 0, 0);

  g.sound.update();

}