Beispiel #1
0
void drawGame(Game* game)
{
	setDrawColor(game, game->clearColor);
	SDL_RenderClear(game->renderer);
	
	drawBackground(game);
	
	for(int i = 0; i < MAX_ENTITIES_PER_GAME; ++i)
		if(game->entities[i].alive)
			drawEntity(game, &game->entities[i]);
			
	drawBehaviorPools(game, &game->behaviorPools);
	drawParticles(game);
	
	sortRenderQueue(game);
	flushRenderQueue(game);

	SDL_RenderPresent(game->renderer);
	
	game->frameTimer += game->delta;
	game->frameCounter++;
	if(game->frameTimer > 1)
	{
		game->frameTimer -= 1;
		if(game->frameTimer > 1)
			game->frameTimer = 0;
			
		game->fps = game->frameCounter;
		game->frameCounter = 0;
	}
}
Beispiel #2
0
void drawEntities(void)
{
	int i;
	Entity *e, **candidates;
	
	candidates = getAllEntsWithin(battle.camera.x, battle.camera.y, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
	
	/* counting entities to draw */
	for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) {};
	
	qsort(candidates, i, sizeof(Entity*), drawComparator);

	for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
	{
		self = e;

		if (e->draw)
		{
			e->draw();
		}
		else
		{
			drawEntity(e);
		}
		
		drawHealthBar(e);
		
		drawTargetRects(e);
		
		drawRope(e);
	}
}
Beispiel #3
0
void RS_GraphicView::drawLayer2(RS_Painter *painter)
{
	drawEntity(painter, container);	//	Draw all entities.

	//	If not in print preview, draw the absolute zero reference.
	//	----------------------------------------------------------
	if (!isPrintPreview())
		drawAbsoluteZero(painter);
}
Beispiel #4
0
/**
 * Deletes an entity with the background color.
 * Might be recusively called e.g. for polylines.
 */
void RS_GraphicView::deleteEntity(RS_Entity* e) {

	// RVT_PORT When we delete a single entoty, we can do this but we need to remove this then also from containerEntities
	RS_DEBUG->print("RS_GraphicView::deleteEntity will for now redraw the whole screen instead of just deleting the entity");
	setDeleteMode(true);
	drawEntity(e);
	setDeleteMode(false);
	redraw(RS2::RedrawDrawing);
}
Beispiel #5
0
void GameProcessState::draw(sf::RenderWindow &window)
{
	window.draw(polygonBackground_);

	for (auto i = planes_.begin(); i != planes_.end(); i++)
	{
		drawEntity(*i, window);
	}
}
Beispiel #6
0
/**
 * Draws the entities within the given range.
 */
void RS_GraphicView::drawWindow_DEPRECATED(RS_Vector v1, RS_Vector v2) {
	RS_DEBUG->print("RS_GraphicView::drawWindow() begin");
	if (container) {
		for(auto se: *container){
			if (se->isInWindow(v1, v2)) {
                drawEntity(nullptr, se);
			}
		}
	}
	RS_DEBUG->print("RS_GraphicView::drawWindow() end");
}
/**
 * Draws the entities within the given range.
 */
void RS_GraphicView::drawWindow_DEPRECATED(RS_Vector v1, RS_Vector v2) {
    RS_DEBUG->print("RS_GraphicView::drawWindow() begin");
    if (container!=NULL) {
        for (RS_Entity* se=container->firstEntity(RS2::ResolveNone);
             se!=NULL;
             se = container->nextEntity(RS2::ResolveNone)) {
            if (se->isInWindow(v1, v2)) {
                drawEntity(NULL, se);
            }
        }
    }
    RS_DEBUG->print("RS_GraphicView::drawWindow() end");
}
Beispiel #8
0
/**
 * Envoie une entité tant que sont état n'est pas final.
 * @param game L'état du jeu
 * @param hero Le héros
 * @param entity L'entité à envoyer
 * @param board Le plateau de jeu
 */
void throwEntity(GameState* game, Eceman* hero, Entity* entity, char board[ROWS][COLS]) {
    unsigned int i;

    i = 0;

    while (entity->state != FINAL) {
        i++;

        if (i % 20000000 != 0)
            continue;

        clearEntity(board, entity);
        moveEntity(game, hero, entity, board);
        drawEntity(board, entity);
    }
}
Beispiel #9
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);
    }
}
Beispiel #10
0
void RS_GraphicView::drawEntity(RS_Painter *painter, RS_Entity* e) {
	double offset(0.);
	drawEntity(painter,e,offset);
}
Beispiel #11
0
    /**
     * Public-facing overload
     */
    void Instance::drawEntity() {
      updateAnimationPose();

      drawEntity( false, *this );
    }
Beispiel #12
0
void TileMap::draw(BITMAP* dest, int scrollX, int scrollY, unsigned int layer)
{
    if (!mShowForegroundLayer && layer == FOREGROUND_LAYER)
    {
        return;
    }

    if (!mShowBackgroundLayer && layer == BACKGROUND_LAYER)
    {
        return;
    }

    if (!mShowEntities && layer == ENTITY_LAYER)
    {
        return;
    }

    int tileMapX = scrollX / 16;

    if (tileMapX < 0)
    {
        tileMapX = 0;
    }

    int tileMapY = scrollY / 16;

    // We ignore the first line as it's not a part of the tilemap.
    if (tileMapY < 0)
    {
        tileMapY = 0;
    }

    int tileMapEndX = scrollX / 16 + dest->w / 16 + 1;

    if (tileMapEndX > getWidth())
    {
        tileMapEndX = getWidth();
    }

    int tileMapEndY = scrollY / 16 + dest->h / 16 + 1;

    if (tileMapEndY > getHeight())
    {
        tileMapEndY = getHeight();
    }

    int y;
    for (y = tileMapY; y < tileMapEndY; y++)
    {
        int x;
        for (x = tileMapX; x< tileMapEndX; x++)
        {
            if (layer == ENTITY_LAYER)
            {
                int g = getTileEntity(x, y);

                if (g != 0)
                {
                    drawEntity(dest,
                               x * 16 - scrollX,
                               y * 16 - scrollY,
                               g);
                }
            }
            else
            {
                int r = getTile(x, y);

                int b = getTileFlags(x, y);

                bool drawInLayer = (layer == FOREGROUND_LAYER && !(b & BACKGROUND)
                                    || (layer == BACKGROUND_LAYER && (b & BACKGROUND)));

                if (r != 0 && drawInLayer)
                {
                    drawTile(dest,
                             x * 16 - scrollX,
                             y * 16 - scrollY,
                             r);
                }

                if (mShowSolidity)
                {
                    drawFlags(dest,
                              x * 16 - scrollX,
                              y * 16 - scrollY,
                              b);
                }
            }
        }
    }
}
Beispiel #13
0
/**
 * Lance l'action de la tondeuse à la fin de son déplacement.
 * @param game L'état du jeu
 * @param hero Le héros
 * @param mower La tondeuse
 * @param board Le plateau de jeu
 */
void mowerFinalActionStrategy(GameState* game, Eceman* hero, Entity* mower, char board[ROWS][COLS]) {
    game->levelScore++;

    drawEntity(board, mower);
    drawToolbar(game);
}