示例#1
0
void
renderPlayState(PlayState *playState, GameContext *gameContext, SDL_Renderer *renderer) {

    drawScrollingBackground(playState->scrollingBackground, gameContext, renderer);

    for (int i = 0; i < playState->currentLives; ++i) {
        drawTextureFrame(renderer, playState->liveTexture, i * 30, 0, 32, 30, 0, 0);
    }
    for (int i = 0; i < playState->player->health; ++i) {
        SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
        int partWidth = 8;
        SDL_Rect rect = {(i * 4 * partWidth) + 1, 40, partWidth * 3, 5};
        SDL_RenderFillRect(renderer, &rect);
        SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
    }

    for (EntityNode *node = playState->entityList; node; node = node->next) {
        drawEntity(&node->entity, gameContext, renderer);
    }
}
示例#2
0
文件: raad.c 项目: pasoev/praxis
void render(GameState *game){
  SDL_SetRenderDrawColor(game->renderer, 0, 0, 255, 255);
  SDL_RenderClear(game->renderer);

  /* draw the hero */
  drawTextureFrame(game->man.texture, game->man.position.x, game->man.position.y,
		   128, 82, 1, game->man.currentFrame, game->renderer);

  /********  draw ravens */
  int i;
  for(i = 0; i < 10; i++){
    SDL_Rect ravenRect = {game->ravens[i].x, game->ravens[i].y, 64, 64};
    SDL_RenderCopy(game->renderer, game->raven, NULL, &ravenRect);
  }

  /* draw other game objects */
  /* ravens */
  for(i = 0; i < 100; i++){
    drawTexture(game->brick, game->ledges[i].x, game->ledges[i].y, game->ledges[i].w, game->ledges[i].h, game->renderer);
  }
  SDL_RenderPresent(game->renderer);
}