Exemplo n.º 1
0
    bool Tela::showGameOver() {
        bool quit = false, execute = true;
        char pontVetor[6];

        applySurface( 0, 0, telaGameOver, screen );
        sprintf(pontVetor,"%d",user->getPontuacao());
        pontosJogador = TTF_RenderText_Solid( font, pontVetor, textColor );
        applySurface( 330, 260, pontosJogador, screen );
        SDL_Flip( screen );

        while( execute ) {

            if( SDL_PollEvent( &event ) ) {
                Ponto tmp;

                if( event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
                    tmp.x = event.button.x;
                    tmp.y = event.button.y;
                    if((tmp.x >= 645 && tmp.x <= 725) && (tmp.y >= 490 && tmp.y <= 570)) {
                        execute = false; //Play again
                    } else if((tmp.x >= 90 && tmp.x <= 175) && (tmp.y >= 490 && tmp.y <= 575)) {
                        quit = true;
                        return quit;
                    }
                } else if( (event.type == SDL_QUIT)  || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
                    //Encerra o programa
                    quit = true;
                    return quit;
                }
            }
        }
        return execute;
    }
Exemplo n.º 2
0
void PlayerFigure::show(SDL_Rect* otherCamera) {
   if (numClips > 0) {
      if (v.x < 0) {
         status = LEFT;
         animationFrame += AFVALUE;
      }
      else if (v.x > 0) {
         status = RIGHT;
         animationFrame += AFVALUE;
      }
      if (v.x == 0 || animationFrame >= numClips)
         animationFrame = 0;

      if (status == LEFT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cl[static_cast<int>(animationFrame)]);
      else if (status == RIGHT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cr[static_cast<int>(animationFrame)]);

      if (particleEffects)
         showParticles(camera);

      cursor.show();
   }

   if (grabstate) {
      //TODO signal thread to perform A* algorithm
      SDL_CondSignal(canTest);
   }
}
Exemplo n.º 3
0
int cLevel::render(SDL_Surface* dst) {
    for (int i = 0; i < walls.size(); ++i) {
        dispWall(dst, &walls[i], &vp);
    }
    for (int i = 0; i < 4; ++i) {
        dispWall(dst, &borders[i], &vp);
    }

    if (dirOn) {
        switch (dir) {
            case enumDirLEFT:
                filledTrigonRGBA(dst, 100, 0, 0, 50, 100, 100, 255, 0, 0, 255);
                break;
            case enumDirRIGHT:
                filledTrigonRGBA(dst, 0, 0, 100, 50, 0, 100, 255, 0, 0, 255);
                break;
            case enumDirUP:
                filledTrigonRGBA(dst, 50, 0, 100, 100, 0, 100, 255, 0, 0, 255);
                break;
            case enumDirDOWN:
                filledTrigonRGBA(dst, 0, 0, 100, 0, 50, 100, 255, 0, 0, 255);
                break;
        }
    }

    coord tc;
    tc = toScreen(playerPOI[0]);
    applySurface(sEntrance, dst, tc.x - sEntrance->w/2, tc.y - sEntrance->h/2);
    tc = toScreen(playerPOI[1]);
    applySurface(sExit, dst, tc.x - sEntrance->w/2, tc.y - sEntrance->h/2);

    return 0;
}
Exemplo n.º 4
0
void PlayerFigure::show(SDL_Rect* otherCamera) {
   if (numClips > 0) {
      if (v.x < 0) {
         status = LEFT;
         animationFrame += AFVALUE;
      }
      else if (v.x > 0) {
         status = RIGHT;
         animationFrame += AFVALUE;
      }
      if (v.x == 0 || animationFrame >= numClips)
         animationFrame = 0;

      if (status == LEFT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cl[static_cast<int>(animationFrame)]);
      else if (status == RIGHT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cr[static_cast<int>(animationFrame)]);

      if (particleEffects)
         showParticles(camera);

      cursor.show();
   }
}
Exemplo n.º 5
0
void TempFigure::show(SDL_Rect* otherCamera) {
   if (marker == INACTIVE)
      return;
   else if (marker == REMOVE) {
      bool animationDone = true;
      marker = INACTIVE;

      if (animationDone) {
         if (Mix_PlayChannel(-1, scratch.getMix_Chunk(), 0) < 0) {
            printf("Mix_PlayChannel: %s\n", Mix_GetError());
            throw SoundException();
         }
      }
   }
   else if (marker == ACTIVE) {
      if (numClips > 0) {
         if (v.x < 0) {
            status = LEFT;
            animationFrame += AFVALUE;
         }
         else if (v.x > 0) {
            status = RIGHT;
            animationFrame += AFVALUE;
         }
         else
            animationFrame = 0;

         if (animationFrame >= numClips)
            animationFrame = 0;

         if (leader) {
            if (status == LEFT)
               applySurface((int) p.x - camera->x, (int) p.y - camera->y,
                     *image, screen, &cl[static_cast<int>(animationFrame)]);
            else if (status == RIGHT)
               applySurface((int) p.x - camera->x, (int) p.y - camera->y,
                     *image, screen, &cr[static_cast<int>(animationFrame)]);

            if (particleEffects)
               showParticles(camera);
         }
         else {
            if (status == LEFT)
               applySurface((int) p.x - otherCamera->x,
                     (int) p.y - otherCamera->y, *image, screen,
                     &cl[static_cast<int>(animationFrame)]);
            else if (status == RIGHT)
               applySurface((int) p.x - otherCamera->x,
                     (int) p.y - otherCamera->y, *image, screen,
                     &cr[static_cast<int>(animationFrame)]);

            if (particleEffects)
               showParticles(otherCamera);
         }
      }
   }
   else
      throw InvalidMarkerException();
}
Exemplo n.º 6
0
  void Slider::paint(Surface& to_where)
  {        
    
    applySurface( box.x, box.y, bg, to_where, nullptr);
    applySurface( box.x + btn_box.x,
		  btn_box.y+box.y, btn, to_where, nullptr);
    
  }
Exemplo n.º 7
0
// paints a specific tile, using the empty tile if it hasn't been assigned graphics
void Map::paintTile(int indexX, int indexY, int locX, int locY)
{
	// paint elsewhere than the default location?
	if(locX == -1)
		locX = limit.x+(indexX-x)*tileSize;
	if(locY == -1)
		locY = limit.y+(indexY-y)*tileSize;

	applySurface(locX,locY,g->image,screen,&g->clip[ts[indexX][indexY].b]);
	if(ts[indexX][indexY].f != -1)
		applySurface(locX,locY,g->image,screen,&g->clip[ts[indexX][indexY].f]);
}
Exemplo n.º 8
0
    bool Tela::showIDscreen() {
        bool quit = false, execute = true, nameEntered = false;
        std::string temp = "";

        SDL_EnableUNICODE( SDL_ENABLE );

        applySurface( 0, 0, telaIdentificacao, screen );
        SDL_Flip( screen );

        while( execute ) {

            if( SDL_PollEvent( &event ) ) {
                Ponto tmp;

                if( event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
                    tmp.x = event.button.x;
                    tmp.y = event.button.y;
                    if((tmp.x >= 660 && tmp.x <= 730) && (tmp.y >= 520 && tmp.y <= 600)) {
                        execute = false;
                    }
                } else if( (event.type == SDL_QUIT)  || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
                    //Encerra programa
                    quit = true;
                    return quit;
                }

                if( event.type == SDL_KEYDOWN && nameEntered == false )
                {
                    //Recebe info do usuario
                    if((nomeJogador = user->handleInput(event, font, textColor)) != NULL) {
                        applySurface( 0, 0, telaIdentificacao, screen );
                        applySurface( 295, 350, nomeJogador, screen );
                        SDL_Flip( screen );
                    }

                    //Tecla ENTER
                    if( ( event.type == SDL_KEYDOWN ) && ( event.key.keysym.sym == SDLK_RETURN ) )
                    {
                        nameEntered = true;
                        execute = false;
                    }
                }

            }
        }

        SDL_EnableUNICODE( SDL_DISABLE );
        
        return execute;
    }
Exemplo n.º 9
0
    bool Tela::showInstrucoes() {
        bool quit = false, execute = true;

        applySurface( 0, 0, telaInstrucoes, screen );
        SDL_Flip( screen );

        while( execute ) {

            if( SDL_PollEvent( &event ) ) {
                Ponto tmp;

                if( event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
                    tmp.x = event.button.x;
                    tmp.y = event.button.y;
                    if((tmp.x >= 590 && tmp.x <= 645) && (tmp.y >= 100 && tmp.y <= 160)) {
                        execute = false;
                    }
                } else if( (event.type == SDL_QUIT)  || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
                    //Encerra programa
                    quit = true;
                    return quit;
                }
            }
        }
        return execute;
    }
Exemplo n.º 10
0
// paints all the graphic tiles, including the highlighting of the selected tile
void SelectableMap::paint(int highlightTileX, int highlightTileY)
{
	SDL_Rect windowClip;

	windowClip.x = x*tileSize;
	windowClip.y = y*tileSize;
	windowClip.w = limit.w;
	windowClip.h = limit.h;

	applySurface(limit.x,limit.y,g->image,screen,&windowClip);

	if(highlightTileX != -1 && highlightTileY != -1 && isOnScreen(highlightTileX,highlightTileY))
	{
		applySurface(limit.x+(highlightTileX-x)*tileSize,limit.y+(highlightTileY-y)*tileSize,highlightTile,screen);
	}
}
Exemplo n.º 11
0
void menuDraw()
{
	int i;
	int drawPos = curMenu->menuDrawPos;

	if(curMenu == &mainMenu)
	{
		applySurface(screenWidth/2 - 56 , 5, gameLogoIMG, screen, NULL);
	}

	if(menuState == MENU_STATE_NORMAL)
	{
		for(i = 0; i < curMenu->count; i++)
		{
			int multipleChoiceIndex = curMenu->menuItems[i]->curMultipleChoiceIndex;
			dTextCentered(curMenu->menuItems[i]->text[multipleChoiceIndex], 0, 9 * i + drawPos);
		}
		dText(">", screenWidth / 2 - ((strlen(curMenu->menuItems[curMenu->selectedIndex]->text[0]) + 2) * 7) / 2, curMenu->selectedIndex * 9 + drawPos);
		dText("<", screenWidth / 2 + ((strlen(curMenu->menuItems[curMenu->selectedIndex]->text[0]) + 2) * 7) / 2 - 7, curMenu->selectedIndex * 9 + drawPos);
		//dText("*", 40, curMenu->selectedIndex * 9 + drawPos); // this is a quick hack and should be changed later
	}
	else if(menuState == MENU_STATE_REDEFINE_KEYS)
	{
		char *keyName[] = {"UP", "DOWN", "LEFT", "RIGHT", "ACTION", "JUMP", "OK", "BACK", "MENU"};
		char dialog[30];

		sprintf(dialog, "Press key for *%s*", keyName[remapCurKey]);
		dTextCentered(dialog, 0, screenHeight/2);
	}
}
Exemplo n.º 12
0
        // Função para começar o jogo
            void Tela::showGame() {
                fillUndo(); // guarda as telas em um pilha para uso da função Undo
    		    applySurface( 0, 0, fundo, screen );
                if( SDL_Flip( screen ) == -1 )
                    return;
                std::string str = user->getNome();
                const char *c = str.c_str(); //Transforma a string em um vetor de char

                switch(level) {
                	case 1:
						applySurface( 57.938, 184.812, fase1, screen );
                        nomeJogador = TTF_RenderText_Solid( font, c, textColor );
                        applySurface( 20, 120, nomeJogador, screen );
                        showPontuacao();
						break;                	
                	case 2:
						applySurface( 57.938, 184.812, fase2, screen );
                        nomeJogador = TTF_RenderText_Solid( font, c, textColor );
                        applySurface( 20, 120, nomeJogador, screen );
                        showPontuacao();
						break;                	
                	case 3:
						applySurface( 57.938, 184.812, fase3, screen );
                        nomeJogador = TTF_RenderText_Solid( font, c, textColor );
                        applySurface( 20, 120, nomeJogador, screen );
                        showPontuacao();
						break;                	
                	case 4:
						applySurface( 57.938, 184.812, fase4, screen );
                        nomeJogador = TTF_RenderText_Solid( font, c, textColor );
                        applySurface( 20, 120, nomeJogador, screen );
                        showPontuacao();
                }
				if( SDL_Flip( screen ) == -1 ) return;
                SDL_Rect my_rects[8];
                int qtd;
                for(int i = 0; i < linhasMatriz; i++) {
                    qtd = 0;
                    for(int j = 0; j < colunasMatriz; j++) {
                        apply_surface(i, j, gems, screen);
                        my_rects[qtd].x = matriz[i][j].celula.x;
                        my_rects[qtd].y = matriz[i][j].celula.y;
                        my_rects[qtd].w = matriz[i][j].celula.w;
                        my_rects[qtd++].h = matriz[i][j].celula.h;
                    }
                    SDL_UpdateRects(screen, 8, my_rects);
                    SDL_Delay(100);
                }
	            getBonus();
                if( SDL_Flip( screen ) == -1 )
                    return;
            }
Exemplo n.º 13
0
int main(int argc, char *argv[])
{

	//Initialize
	if( init() == false ){
		printf("Initialization failed!");
		return -1;
	}

	SDL_FillRect(screen,NULL,0xffffff);

	// load image
	//bgImg = loadOptimizedImage("/home/rps/Pictures/SDL/bg-red.bmp");


	// load font
	font = TTF_OpenFont( "/usr/share/fonts/liberation/"
			"LiberationMono-Regular.ttf", 28 );

	if(font == NULL)
		{
			printf("font is null");
			return -1;
		}


	// render text
	message = TTF_RenderText_Solid(font,"Hey! I'm rendering TTF! Awesome!!!"
			,textColor);


	if(message == NULL){
		printf("\n Image (message) loaded is null!\n");
		return -1;
	}


	// blit rendered message to screen
	 applySurface(50,50,message,screen);

	// update window
	SDL_Flip(screen);

	while(1){
    	while(SDL_PollEvent(&event)){
			if(event.type == SDL_QUIT)
			{
				goto the_end;
			}
    	}
	}

	the_end:

	clean_up();

	return 0;

}
Exemplo n.º 14
0
Figure::Marker CircFigure::show(SDL_Rect* otherCamera) {
   if (numClips > 0) {
      if (v.x < 0) {
         status = LEFT;
         animationFrame += AFVALUE;
      }
      else if (v.x > 0) {
         status = RIGHT;
         animationFrame += AFVALUE;
      }
      else
         animationFrame = 0;

      if (animationFrame >= numClips)
         animationFrame = 0;

      if (leader) {
         if (status == LEFT)
            applySurface((int) p.x - r - camera->x, (int) p.y - r - camera->y,
                  *image, screen, &cl[static_cast<int>(animationFrame)]);
         else if (status == RIGHT)
            applySurface((int) p.x - r - camera->x, (int) p.y - r - camera->y,
                  *image, screen, &cr[static_cast<int>(animationFrame)]);

         if (particleEffects)
            showParticles(camera);
      }
      else {
         if (status == LEFT)
            applySurface((int) p.x - r - otherCamera->x,
                  (int) p.y - r - otherCamera->y, *image, screen,
                  &cl[static_cast<int>(animationFrame)]);
         else if (status == RIGHT)
            applySurface((int) p.x - r - otherCamera->x,
                  (int) p.y - r - otherCamera->y, *image, screen,
                  &cr[static_cast<int>(animationFrame)]);

         if (particleEffects)
            showParticles(otherCamera);
      }
   }

   return marker;
}
Exemplo n.º 15
0
int cDetector::render(SDL_Surface* dst, int x, int y) {
    if (state == STATE_DETECT) {
        applySurface(sDetector[count], dst, x, y);
    } else if (state == STATE_NOISE) {
        int c = ((SDL_GetTicks() - noiseTime) % 150) / 30;
        applyClipped(sNoise, dst, x, y, &clip[c]);
    }

    return 0;
}
Exemplo n.º 16
0
    bool Tela::showConfScreen() {
        bool quit = false, execute = true;

        if(audio) {
            applySurface( 0, 0, telaConfigSound_ON, screen );
            SDL_Flip( screen );
        } else {
            applySurface( 0, 0, telaConfigSound_OFF, screen );
            SDL_Flip( screen );
        }

        while( execute ) {

            if( SDL_PollEvent( &event ) ) {
                Ponto tmp;

                if( event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
                    tmp.x = event.button.x;
                    tmp.y = event.button.y;
                    if((tmp.x >= 590 && tmp.x <= 645) && (tmp.y >= 100 && tmp.y <= 160)) {
                        execute = false;
                    } else if((tmp.x >= 140 && tmp.x <= 660) && (tmp.y >= 60 && tmp.y <= 580)) {
                        if(audio) {
                            applySurface( 0, 0, telaConfigSound_OFF, screen );
                            SDL_Flip( screen );
                            audio = false;
                            Mix_PauseMusic();
                        } else {
                            applySurface( 0, 0, telaConfigSound_ON, screen );
                            SDL_Flip( screen );
                            audio = true;
                            Mix_ResumeMusic();
                        }
                    }
                } else if( (event.type == SDL_QUIT)  || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
                    //Encerra programa
                    quit = true;
                    return quit;
                }
            }
        }
        return execute;
    }
Exemplo n.º 17
0
int cSleeperGuard::render(SDL_Surface* dst, cLevel* level, bool los) {
    coord tc = {x, y};
    tc = level->toScreen(tc);

    switch (state) {
        case SleeperGuardStates_ALARM:
            drawLOS(dst, level, x, y, angle, GUARD_FOV, 100);

            applySurface(sGuard, dst, tc.x - sGuard->w/2, tc.y - sGuard->h/2);

            break;
        case SleeperGuardStates_SLEEP:
            circleRGBA(dst, tc.x, tc.y, range, 255, 0, 0, 255);
            filledCircleRGBA(dst, tc.x, tc.y, range, 255, 0, 0, 80);

            applySurface(sGuard, dst, tc.x - sGuard->w/2, tc.y - sGuard->h/2);

            break;
    }
    return 0;
}
Exemplo n.º 18
0
int cLight::render(SDL_Surface* dst) {
    if (state != STATE_CRASHED && state != STATE_DONE) {
        float d = (SDL_GetTicks() - animTime) / 10000.0;

        if (state == STATE_MOVINGLEFT) {
            applySurface(light, dst, 435 * d + 620 * (1 - d), 388);
        } else {
            applySurface(light, dst, 435 * (1 - d) + 620 * d, 388);
        }
    } else if (state == STATE_DONE) {
        SDL_Rect t;
        t.x = 455;
        t.y = 320;
        t.w = 30;
        t.h = t.w;

        SDL_FillRect(dst, &t, SDL_MapRGB(dst->format, 255, 255, 255));
    }

    return 0;
}
Exemplo n.º 19
0
void Map::draw()
{
	for (int i = 0; i < MAP_HEIGHT; i++)
	{
		for (int j = 0; j < MAP_WIDTH; j++)
		{
			if (get(j, i) != 0)
			{
				applySurface(j*TILE_WIDTH, i*TILE_HEIGHT, tiles[get(j, i)], screen);
			}
		}
	}
}
Exemplo n.º 20
0
void Player::drawObject(SDL_Surface* dst){
    if(!(invincibility && (fmod(timer, 0.3) > 0.15)) && !exploding){
        //convert to radians to degrees
        double rotAngleDegree = ((direction - M_PI/2) * 180/M_PI);
         //kill offset
        if(rotAngleDegree < 0){
                rotAngleDegree += 360;
        }
        int i = (int) (rotAngleDegree / (360 / SPRITE_ROTATIONS));
        applySurface(rotatedSprites[i], dst,
                         (int) (xPos - rotatedSprites[i]->w/2 + rotatedSprites[0]->w/2), 
                         (int) (yPos - rotatedSprites[i]->h/2 + rotatedSprites[0]->h/2));
    }
    else if(exploding)
        applySurface(explosion, dst, (int) xPos, (int) yPos);
    
    //draw bullets
    for(int i = 0; i < MAX_BULLETS; i++){
                if(bullets[i] != NULL)
                        bullets[i]->drawObject(dst);
    }   
}
Exemplo n.º 21
0
int main(int argc, char *argv[])
{
	isExit = 0;

	if(argc < 2)
	{
		fprintf(stderr, "USAGE:\nviewimg [IMAGE_FILE]\n");
		return 1;
	}
	else
	{
		int posX = 0;
		int posY = 0;

		if(initSDL())
		{
			return 1;
		}
		image = loadImage(argv[1]);
		if(image == NULL)
		{
			cleanSDL();
			return 1;
		}

		if(image->w < screen->w)
		{
			posX = screen->w / 2 - image->w / 2;
		}
		if(image->h < screen->h)
		{
			posY = screen->h / 2 - image->h / 2;
		}

		SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0, 0, 0));
		applySurface(image, screen, posX, posY, NULL);
		updateScreen();
	}

	while(!isExit)
	{
		input();
		SDL_Delay(1);
	}

	cleanSDL();

	return 0;
}
Exemplo n.º 22
0
int cPointGuard::render(SDL_Surface* dst, cLevel* level, bool los) {
    coord tc;
    tc.x = x;
    tc.y = y;

    tc = level->toScreen(tc);

    if (los) {
        drawLOS(dst, level, x, y, angle, GUARD_FOV, 200);
    }

    applySurface(sGuard, dst, tc.x - sGuard->w / 2, tc.y - sGuard->h / 2);

    return 0;
}
Exemplo n.º 23
0
void Bullet::draw() {
	positon.x += xSpeed;
	positon.y += ySpeed;
	//draw sprite
	if (positon.x < 0-spriteSurface->w) {
		//destory();
	}
	if (positon.x > wWindow) {
		//destory();
	}
	if (positon.y > hWindow) {
		//destory();
	}
	if (positon.y < 0-spriteSurface->h) {
		//destory();
	}
	if (alive) {
		//applySurface(positon.x, positon.y, spriteSurface, screen, clip);
		applySurface(positon.x, positon.y, spriteSurface, screen, NULL);
	}else {
		//applySurface(positon.x, positon.y, spriteSurface, screen, clip);
		applySurface(positon.x, positon.y, NULL, screen, NULL);
	}
}
Exemplo n.º 24
0
void makeMoveComp( board *gameBoard )
{

	//Call the function that sets the priority value for each element
	//of the gameBoard array
	originalPriority(gameBoard);

	//Declare loop variables i & j
	//square is the index of the square that will be changed
	//max is the highest priority, used to randomize the actual
	//move when many squares have the max priority
	int i, j = 0, max = 0, square;
	//maxSquares is used to keep track of the squares that have
	//the highest priority for randomization
	int *maxSquares = malloc(sizeof(int) * 9);

	//Cycle through and find highest priority
	for(i = 0; i < 9; i++)
		if(gameBoard->squares[i].priority > max)
			max = gameBoard->squares[i].priority;

//	printf("Max is: %i\n", max);

	//Track all squares that have the max priority
	for(i = 0; i < 9; i++)
	{
		if(gameBoard->squares[i].priority == max)
		{
			maxSquares[j] = i;
			j++;
//			printf("Square %i has priority %i\n", i, gameBoard->squares[i].priority);
		}
	}

	//And randomly choose one
	srand(time(NULL));
	square = maxSquares[rand() % j];

//	printf("j = %i\nComp will make move at square %i\n", j, square);

//	getchar();

	//And actually make the move :D
	gameBoard->squares[square].player = gameBoard->computer;
    applySurface(gameBoard->squares[square].x, gameBoard->squares[square].y, gameBoard->computer, gameBoard->screen, NULL);

	return;
}
Exemplo n.º 25
0
void GraphicsEngine::drawSquares()
{
	SDL_Surface* toDraw = 0;

	for(int i = 0; i < 8; ++i){

		for(int j = 0; j < 8; ++j){

			if( (i+j)%2 == 0 ){
				toDraw = squareSrfW;
			}else{
				toDraw = squareSrfB;
			}
				applySurface(toDraw, screen, j*width/8, i*height/8);
		}
	}
}
void JM_RenderComponent::render(SDL_Surface* screen)
{
    if(m_owner != NULL){
        JM_PositionComponent* pc = static_cast<JM_PositionComponent*>(m_owner->getComponent(TYPE_POSITION));

        if(pc){
            int xpos = pc->m_collisionBox.x;// - (pc->m_collisionBox.w /2 );
            int ypos = pc->m_collisionBox.y;// - (pc->m_collisionBox.h / 2);
            applySurface(xpos, ypos,m_GFX,screen);
        }

        else
            printf("Position Component is null!! JM_RenderComponent %d\n", m_owner);
    }

    else
        printf("Owner is null!! JM_RenderComponent %d\n", this);
}
Exemplo n.º 27
0
// full layered paint of the map editor and all of its inner sections
void MapEditor::paint()
{
	applySurface(0,0,background,screen);

	if(isLoaded)
	{
		customMap->paint();
		tileSet->paint(selectedTileX,selectedTileY);

		// paint the 4 directional buttons for each scrolling window
		for(int i=0;i<4;i++)
		{
			customMapBtns[i].paint();
			tileSetBtns[i].paint();
		}

		paintInfoPanel();
	}
}
Exemplo n.º 28
0
void StartScreen::paint()
{
	if(state == STATE_SHOW_SCREEN)
	{
		//start music
		if (!musicStarted)
		{
			Mix_PlayMusic( startMusic,-1 );
			musicStarted=true;
		}

		// apply background image
		applySurface(0,0,background,screen);
	}
	else if(state == STATE_MAP_EDITOR)
	{
		mapEditor->paint();
	}
}
Exemplo n.º 29
0
    bool Tela::showTelaInicial() {
        bool quit = false, execute = true;

        while( execute && (quit == false) ) {

        applySurface( 0, 0, telaInicial, screen );
        SDL_Flip( screen );

            if( SDL_PollEvent( &event ) ) {

                Ponto tmp;

                if( event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) {
                    tmp.x = event.button.x;
                    tmp.y = event.button.y;
                    if((tmp.x >= 50 && tmp.x <= 175) && (tmp.y >= 400 && tmp.y <= 530)) {
                        if(showIDscreen())
                            quit = true;
                        else
                            if(playGame())
                                quit = true;
                            else
                                execute = false;
                    } else if((tmp.x >= 50 && tmp.x <= 180) && (tmp.y >= 115 && tmp.y <= 355)) {
                        if(showInstrucoes())
                            quit = true;
                    } else if((tmp.x >= 65 && tmp.x <= 150) && (tmp.y >= 545 && tmp.y <= 623)) {
                        if(showConfScreen())
                            quit = true;
                    }
                } else if( (event.type == SDL_QUIT)  || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
                    //Encerra programa
                    quit = true;
                }
            }
        }
    if(quit) {
        clean_up();
        return execute;
    } else {
        return quit;
    }
}
Exemplo n.º 30
0
void TetrisScreen::drawPiece(TetrisPiece* piece, SDL_Surface* dest,
    const int offx, const int offy)
{
    std::vector<Point> pblocks = piece->getBlocks();

    int yblocks, xblocks, ypix, xpix;
    int color = getColor(piece->getPieceType());

    for(std::vector<Point>::iterator it = pblocks.begin(),
        end = pblocks.end() ; it != end ; ++it)
    {
        yblocks = it->y + 1;
        ypix = offy - (yblocks * blocksize);

        xblocks = it->x;
        xpix = offx + (xblocks * blocksize);

        applySurface(xpix, ypix, blocks[color], dest);
    }
}