Пример #1
0
void GuiTilemap::drawTileEx( const Tile& tile, const int depth )
{
    if( tile.is_flat() )
    {
        return;  // tile has already been drawn!
    }

    Tile* master = tile.get_master_tile();

    if( master==NULL )
    {
        // single-tile
		drawTile( tile );
    }
    else
    {
        // multi-tile: draw the master tile.
        int masterZ = master->getJ() - master->getI();
        if( masterZ == depth )
        {
            // it is time to draw the master tile
            if (std::find(_multiTiles.begin(), _multiTiles.end(), master) == _multiTiles.end())
            {
                // master has not been drawn yet
                _multiTiles.push_back(master);  // don't draw that multi-tile again
				drawTile( *master );
            }
        }
    }
}
Пример #2
0
/* Call to render the next GL frame */
static void nativeRender(
		JNIEnv*  env,
		jobject thiz,
		jfloat cameraX,
		jfloat cameraY,
		jfloat cameraZ,
		jfloat lookAtX,
		jfloat lookAtY,
		jfloat lookAtZ,
		jboolean useTexture,
		jboolean useColor,
		jboolean cameraDirty) {
	//LOGI("render");

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (cameraDirty) {
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		gluLookAt(cameraX, cameraY, cameraZ,
				lookAtX, lookAtY, lookAtZ,
				0.0f, 1.0f, 0.0f);
    }
	glEnableClientState(GL_VERTEX_ARRAY);

	if (useTexture) {
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glEnable(GL_TEXTURE_2D);
	} else {
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisable(GL_TEXTURE_2D);
	}

	if (useColor) {
		glEnableClientState(GL_COLOR_ARRAY);
	} else {
		glDisableClientState(GL_COLOR_ARRAY);
	}

	if (sSkybox != -1) {
		glDepthMask(false);
		glDisable(GL_DEPTH_TEST);
		drawTile(sSkybox, cameraX, cameraY, cameraZ, useTexture, useColor);
		glDepthMask(true);
		glEnable(GL_DEPTH_TEST);
	}

	for (int x = 0; x < sTileCount; x++) {
		if (x != sSkybox) {
			drawTile(x, cameraX, cameraY, cameraZ, useTexture, useColor);
		}
	}

    glDisableClientState(GL_VERTEX_ARRAY);

    //LOGI("render complete");


}
Пример #3
0
void drawText(Game* game, int fontId, char* string, Pointf position, int depth)
{
	Pointi offset = {0};
	Font* font = &game->font; // TODO: Implement multiple fonts
	
	for(int i = 0; i < strlen(string); ++i)
	{
		if(font->characterMap[string[i]] >= 0)
		{
			drawTile(
				game, font->texture, 
				createPointf(position.x + offset.x, position.y + offset.y), 
				font->characterSize, 
				font->characterMap[string[i]], depth);
		}
		
		offset.x += font->characterSize.x;
		
		if(string[i] == '\n')
		{
			offset.x = 0;
			offset.y += font->characterSize.y;
		}
	}
}
Пример #4
0
void GsTilemap::drawTile(GsWeakSurface &dst,
                         const int x,
                         const int y,
                         const Uint16 t)
{
    drawTile(dst.getSDLSurface(), x, y, t);
}
Пример #5
0
TilePoint Tile::pat_herring(Point3 p, TileParam& t) {
	float s = t.tileWidth * 2.f;	
	float h = t.tileWidth * .5f;
	float x = p.x / s;
	float y = p.y / s;
	int xi = FASTFLOOR(x);
	int yi = FASTFLOOR(y);
	x = xi * s;
	y = yi * s;
	int x_id = (int)((p.x - x) / h) % 4;
	int y_id = (int)((p.y - y) / h) % 4;	
	int id = x_id + 4 * y_id;

	//Point3 center = Point3(pat_herring_x[id]*h+x, pat_herring_y[id]*h+y, p.z);

	float edges[4];

	if (!pat_herring_dir[id]) {
		edges[0] = (pat_herring_x[id]-1.f) * h + x;
		edges[2] = edges[0] + t.tileWidth;
		edges[3] = (pat_herring_y[id]-.5f) * h + y;
		edges[1] = edges[3] + h;
	} else {
		edges[0] = (pat_herring_x[id]-.5f) * h + x;
		edges[2] = edges[0] + h;
		edges[3] = (pat_herring_y[id]-1.f) * h + y;
		edges[1] = edges[3] + t.tileWidth;	
	}

	int tid = generateID(xi*4 + (pat_herring_dir[id] ? 0 : pat_herring_id[id]),
						 yi*4 + (pat_herring_dir[id] ? pat_herring_id[id] : 0));			
	
	return drawTile(p, edges, t, tid, pat_herring_dir[id]);
}
Пример #6
0
TilePoint Tile::pat_xBond(Point3 p, TileParam& t) {
	TilePattern* pat = t.pattern;

	if (!pat) return TilePoint();

	float edges[4];
	int id = 0;
	int id2 = 0;
	
	// Tile top and bottom
	float rand = 3.14f;
	int row = rowcol(edges[3], edges[1], id, p.y, pat->totalHeight, pat->heights, t.tileHeight, t.tileHeightVar, rand);
	if (row == -1) return TilePoint();

	// Tile sides
	rand = edges[3] * 1.325f + 31.41213f;
	float offset = pat->rows[row].offset * t.tileWidth;
	if (offset < 0) offset *= -id;

	row = rowcol(edges[0], edges[2], id2, p.x + offset, pat->rows[row].totalWidth, pat->rows[row].tiles, t.tileWidth, t.tileWidthVar, rand);		
	if (row == -1) return TilePoint();

	edges[0] -= offset;
	edges[2] -= offset;

	id = generateID(id2, id);

	// Draw it
	return drawTile(p, edges, t, id);	
}
Пример #7
0
void drawMap(){
    for(int x = 0; x < mapArrayWidth; x++){
        for(int y = 0; y < mapArrayHeight; y++){
            drawTile(x, y, mapArray[x][y]);
        }
    }
}
void GeneratedImage::drawPattern(GraphicsContext* destContext, const FloatRect& srcRect, const FloatSize& scale,
    const FloatPoint& phase, SkXfermode::Mode compositeOp, const FloatRect& destRect,
    const IntSize& repeatSpacing)
{
    FloatRect tileRect = srcRect;
    tileRect.expand(repeatSpacing);

    SkPictureBuilder builder(tileRect, nullptr, destContext);
    builder.context().beginRecording(tileRect);
    drawTile(&builder.context(), srcRect);
    RefPtr<const SkPicture> tilePicture = builder.endRecording();

    AffineTransform patternTransform;
    patternTransform.translate(phase.x(), phase.y());
    patternTransform.scale(scale.width(), scale.height());
    patternTransform.translate(tileRect.x(), tileRect.y());

    RefPtr<Pattern> picturePattern = Pattern::createPicturePattern(tilePicture);
    picturePattern->setPatternSpaceTransform(patternTransform);

    SkPaint fillPaint = destContext->fillPaint();
    picturePattern->applyToPaint(fillPaint);
    fillPaint.setColor(SK_ColorBLACK);
    fillPaint.setXfermodeMode(compositeOp);

    destContext->drawRect(destRect, fillPaint);
}
Пример #9
0
void GeneratedImage::drawPattern(GraphicsContext& destContext,
                                 const FloatRect& srcRect,
                                 const FloatSize& scale,
                                 const FloatPoint& phase,
                                 SkBlendMode compositeOp,
                                 const FloatRect& destRect,
                                 const FloatSize& repeatSpacing) {
  FloatRect tileRect = srcRect;
  tileRect.expand(FloatSize(repeatSpacing));

  std::unique_ptr<PaintController> paintController = PaintController::create();
  GraphicsContext context(*paintController);
  context.beginRecording(tileRect);
  drawTile(context, srcRect);
  sk_sp<SkPicture> tilePicture = context.endRecording();

  SkMatrix patternMatrix = SkMatrix::MakeTrans(phase.x(), phase.y());
  patternMatrix.preScale(scale.width(), scale.height());
  patternMatrix.preTranslate(tileRect.x(), tileRect.y());

  RefPtr<Pattern> picturePattern =
      Pattern::createPicturePattern(std::move(tilePicture));

  SkPaint fillPaint = destContext.fillPaint();
  picturePattern->applyToPaint(fillPaint, patternMatrix);
  fillPaint.setColor(SK_ColorBLACK);
  fillPaint.setBlendMode(compositeOp);

  destContext.drawRect(destRect, fillPaint);
}
void LevelVisualGraphicSceneLayer::drawTileIfSamePriority(
                            Graphic& dst,
                            const VRAMCache& vramCache_,
                            TileReference tileRef,
                            int drawX,
                            int drawY,
                            PriorityLevel tilePriority) {
  switch (tilePriority) {
  case priorityBG:
    if (tileRef.priorityOption() != TileReference::priorityBG) {
      return;
    }
    break;
  case priorityFG:
    if (tileRef.priorityOption() != TileReference::priorityFG) {
      return;
    }
    break;
  default:
    break;
  }
  
  drawTile(dst,
           vramCache_,
           tileRef,
           drawX,
           drawY);
}
Пример #11
0
void Engine::drawTileInViewport(int x, int y, int tilenum, int fgcolor, int bgcolor)
{
    if(posInViewport(x,y))
    {
        drawTile(x - m_Viewport.left, y - m_Viewport.top, tilenum, fgcolor, bgcolor);
    }
}
void cScene::render() {
	// Draw model
	if (data->front == 1) {
		for (int i = 0; i < (int)map.size(); i++) {
			int k = (int)map.size() - 1 - i;
			for (int j = 0; j <= i; j++) {
				drawTile(j, k);
				if (objmap[j][k] != 0) drawObject(j, k);
				k++;
			}
		}

		for (int i = 1; i < (int)map.size(); i++) {
			int k = 0;
			for (int j = i; j < (int)map.size(); j++) {
				drawTile(j, k);
				if (objmap[j][k] != 0) drawObject(j, k);
				k++;
			}
		}
	} else {
		for (int i = 0; i < (int)map.size(); i++) {
			int j = (int)map.size() - 1;
			for (int k = i; k >= 0; k--) {
				drawTile(j, k);
				if (objmap[j][k] != 0) drawObject(j, k);
				j--;
			}
		}

		for (int i = 1; i < (int)map.size(); i++) {
			int k = (int)map.size() - 1;
			for (int j = (int)map.size() - 1 - i; j >= 0; j--) {
				drawTile(j, k);
				if (objmap[j][k] != 0) drawObject(j, k);
				k--;
			}
		}
	}

	if (DEBUG_MODE) {
		drawHighlightTile((int)playerx,-(int)playerz);
		drawHighlightTile((int)playerx +1,-(int)playerz);
		drawHighlightTile((int)playerx,-(int)playerz +1);
		drawHighlightTile((int)playerx +1,-(int)playerz +1);
	}
}
Пример #13
0
void displayLevel(struct level *lvl){
	int x = 0, y = 0;
	for(x = 0; x < lvl->w; x++){
		for(y = 0; y < lvl->h; y++){
			drawTile(&lvl->lvl[x][y], x, y);
		}
	}
}
Пример #14
0
void drawMap(){
    clear();
	for(int y = 0; y < mapHeight; y++){
		for(int x = 0; x < mapWidth; x++){
			drawTile(y, x);
		}
	}
}
Пример #15
0
bool playGame(Affichage A, Damier *map, Snake *snake, Sound sound)
{
	int end = 0;
	bool win = FALSE;
	Position newPos = initPosition();
	Input input = initInput();
	Chrono chrono = initChrono();
	Timer timer = initTimer();
	
	
	setProiesToMap(map);
	
	drawTile(A, TILE_TITLE);
	drawTextChrono(chrono, A);
	drawMap(A, *map, newPosition(MAXCASES/2 + 3,MAXCASES/2), *snake);

	startChrono(&chrono);
	while (1)
	{
		
		setTimer(&timer);
		newPos = updatePositions(map, snake, &input);
		
		if (input.end)
			break;

		if (testPosMap(newPos))
		{
			end = addPositionSnake(map, snake, newPos, sound);
			if (end)
			{
				win = FALSE;
				break;
			}
		}
		
		setPositionsToMap(map, snake);
		drawChrono(chrono, A);
		drawMap(A, *map, newPos, *snake);
		
		if(endChrono(chrono))
		{
			win = FALSE;
			break;
		}
		
		if (endGame(map))
		{
			win = TRUE;
			break;
		}
		
		reguleFPS(&timer);
	}
	
	deleteChrono(&chrono);
	return win;
}
Пример #16
0
void GameEngineMap::draw()
{
	LoaderParameters* tile = nullptr;

	int startX = map->getCharacterPosition().x - 10;
	int startY = map->getCharacterPosition().y - 7;
	for (int i = 0; i < 15; i++)
	{
		for (int j = 0; j < 21; j++)
		{
			tile = new LoaderParameters(16 + j*32 , 16 + i*32 , CELL_SIZE, CELL_SIZE, 0, 0, "tile_empty");

			if ((startX > -1 && startX < map->getWidth() && startY > -1 && startY < map->getHeight())) {
				//drawTile(tile);

				switch (map->getType(Position(startX, startY)))
				{
				case EMPTY:
					tile->setId("tile_empty");
					drawTile(tile);
					break;
				case GRASS:
					tile->setId("tile_grass");
					drawTile(tile);
					break;
				case DARKGRASS:
					tile->setId("tile_darkgrass");
					drawTile(tile);
					break;
				case STONEWALL:
					tile->setId("tile_stonewall");
					drawTile(tile);
					break;
				}

				// start or end
				if (map->getEndPosition().x == startX && map->getEndPosition().y == startY)
				{
					tile->setId("misc_end");
					drawTile(tile);
				} else if (map->getBeginPosition().x == startX && map->getBeginPosition().y == startY)
				{
					tile->setId("misc_start");
					drawTile(tile);
				}

				// draw character
				if (i == 7 && j == 10) {
					tile->setId("char_default");
					drawTile(tile);
				}
			}
			startX++;
		}
		startY++;
		startX = map->getCharacterPosition().x - 10;
	}

	delete tile;
}
Пример #17
0
void ProgressBar::render() {
    float percent = (float)m_value / m_max;

    for (unsigned int ii = 0; ii < getWidth() * percent && ii < getWidth();
         ii++) {
        // drawString(ii, 0, "=");
        drawTile(ii, 0, 178);
    }
}
Пример #18
0
void drawAllTiles(void){int i, value;
	for (i=1; i<17; i++){
		// get value of tile
		value = getValue(i);
		if (value != 0){
			drawTile(value, i);
		}
	}
}
Пример #19
0
int Tilemap::drawTile(SDL_Renderer* render, terrachess::TileNames name, int renderX, int renderY)
{
	if (tilemap.count(name) > 0)
	{
		return drawTile(render, tilemap[name], renderX, renderY);
	}
	
	return -1;
}
Пример #20
0
int Tilemap::drawTile(SDL_Renderer* render, char chr, int renderX, int renderY)
{
	if (charmap.count(chr) > 0)
	{
		return drawTile(render, charmap[chr], renderX, renderY);
	}
	
	return -1;
}
Пример #21
0
void renderBoard() {
    SDL_RenderClear(ren);
    for (int col = 0; col < col_s; col++)  {
        for (int row = 0; row < row_s; row++) {
            drawTile(row, col , board[col][row]);
        }
    }
    SDL_RenderPresent(ren);
}
Пример #22
0
Файл: map.cpp Проект: faod/ld33
void Map::drawswampgrass()
{
    for(int y = 0; y < tiles_.size(); y++)
    {
        for(int x = 0; x < tiles_[y].size(); x++)
        {
            drawTile(tiles_[y][x], nullptr);
        }
    }
}
Пример #23
0
Файл: map.cpp Проект: faod/ld33
void Map::updatevoisins(int x, int y)
{
    BIOME b = tiles_[y][x].getBiome();
    if(x >= 1 && y >= 1)
    {
        tiles_[y - 1][x - 1].setVoisins(8, b);
        if(tiles_[y - 1][x - 1].getBiome() == SWAMP)
            drawTile(tiles_[y - 1][x - 1], nullptr);
    }
    if(y >= 1)
    {
        tiles_[y - 1][x].setVoisins(7, b);
        if(tiles_[y - 1][x].getBiome() == SWAMP)
            drawTile(tiles_[y - 1][x], nullptr);
    }
    if(x < tiles_[y].size() - 1 && y >= 1)
    {
        tiles_[y - 1][x + 1].setVoisins(6, b);
        if(tiles_[y - 1][x + 1].getBiome() == SWAMP)
            drawTile(tiles_[y - 1][x + 1], nullptr);
    }
    if(x >= 1)
    {
        tiles_[y][x - 1].setVoisins(5, b);
        if(tiles_[y][x - 1].getBiome() == SWAMP)
            drawTile(tiles_[y][x - 1], nullptr);
    }
    if(x < tiles_[y].size() - 1)
    {
        tiles_[y][x + 1].setVoisins(3, b);
        if(tiles_[y][x + 1].getBiome() == SWAMP)
            drawTile(tiles_[y][x + 1], nullptr);
    }
    if(x >= 1 && y < tiles_.size() - 1)
    {
        tiles_[y + 1][x - 1].setVoisins(0, b);
        if(tiles_[y + 1][x - 1].getBiome() == SWAMP)
            drawTile(tiles_[y + 1][x - 1], nullptr);
    }
    if(y < tiles_.size() - 1)
    {
        tiles_[y + 1][x].setVoisins(1, b);
        if(tiles_[y + 1][x].getBiome() == SWAMP)
            drawTile(tiles_[y + 1][x], nullptr);
    }
    if(x < tiles_[y].size() - 1 && y < tiles_.size() - 1)
    {
        tiles_[y + 1][x + 1].setVoisins(2, b);
        if(tiles_[y + 1][x + 1].getBiome() == SWAMP)
            drawTile(tiles_[y + 1][x + 1], nullptr);
    }
}
Пример #24
0
void MainWindow::drawBlock(const block &b)
{
	for (int i = 0; i<4; i++) {
		for (int j = 0; j<4; j++) {
			if (b.shape.b[i][j]) {
				drawTile (j + b.start_point.y,
					i + b.start_point.x, b.shape.color);
			}
		}
	}
}
Пример #25
0
///draws level to screen using drawTile and level.txt doc
void SoftFox::drawLevel()
{
	for (int y = 0; y < level->getHeight(); y++) //goes through coloumns
	{
		for (int x = 0; x < level->getWidth(); x++)//goes through rows
		{
			if (level->isWall(x, y)) //checks for wall
			{
				if (level->isWall(x,y-1) && y!=0)//if wall is above current
				{
					drawTile(x, y, platformSprite_Dirt); //no grass sprite
				}
				else
				{
					drawTile(x, y, platformSprite);// else grass
				}
			}
		}
	}
}
void LevelVisualGraphicSceneLayer::drawMetatileVisual(
                               Graphic& metatileGraphic,
                               const VRAMCache& src,
                               MetatileStructure metatileStructure) {
  drawTile(metatileGraphic,
           src,
           metatileStructure.upperLeft(),
           0, 0);
  drawTile(metatileGraphic,
           src,
           metatileStructure.upperRight(),
           GGTile::width, 0);
  drawTile(metatileGraphic,
           src,
           metatileStructure.lowerLeft(),
           0, GGTile::height);
  drawTile(metatileGraphic,
           src,
           metatileStructure.lowerRight(),
           GGTile::width, GGTile::height);
}
void PathfindingApp::drawMap()
{
	for (int y = 0; y < map->getHeight(); y++)
	{
		for (int x = 0; x < map->getWidth(); x++)
		{
			if (map->isWall(x, y))
			{
				drawTile(x, y, spriteWall);
			}

			if (map->getStartX() == x && map->getStartY() == y)
			{
				drawTile(x, y, spriteMouse);
			}

			if (map->getEndX() == x && map->getEndY() == y)
			{
				drawTile(x, y, spriteExit);
			}
		}
	}
}
Пример #28
0
void Engine::drawWindow( int x, int y, int width, int height, int fgcolor, int bgcolor,
                int tl, int hor, int tr, int vert, int bl, int br, int filltile)
{
    //2d array for width/height
    std::vector< std::vector< int> > tbox;
    tbox.resize(height);
    for(int i = 0; i < height; i++) tbox[i].resize(width);

    //set window tiles
    for(int i = 0; i < height; i++)
    {
        for(int n = 0; n < width; n++)
        {
            //top
            if(i == 0)
            {
                //top left
                if(n == 0) tbox[i][n] = tl;
                //top right
                else if(n == width-1) tbox[i][n] = tr;
                //top line
                else tbox[i][n] = hor;
            }
            //bottom
            else if(i == height-1)
            {
                //top left
                if(n == 0) tbox[i][n] = bl;
                //top right
                else if(n == width-1) tbox[i][n] = br;
                //top line
                else tbox[i][n] = hor;
            }
            //sides
            else if(n == 0) tbox[i][n] = vert;
            else if(n == width-1) tbox[i][n] = vert;
            else tbox[i][n] = filltile;

        }
    }

    //draw window tiles
    for(int i = 0; i < height; i++)
    {
        for(int n = 0; n < width; n++)
        {
            drawTile(x+n, y+i, tbox[i][n], fgcolor, bgcolor);
        }
    }
}
Пример #29
0
void MainWindow::drawBoard(const board &b)
{
	scene->clear();
	scene->addRect(0, 0, BOARD_WIDTH * BOARD_TILE_SIZE,
		BOARD_HEIGHT * BOARD_TILE_SIZE, QPen(),
		QBrush(QColor(Qt::black)));
	int row = BOARD_HEIGHT - 1;
	for (board::row r : b.map) {
		for (size_t i = 0; i<BOARD_WIDTH; i++) {
			if (r.size() > i && r[i]) {
				drawTile (i,row, r[i]);
			}
		}
		row--;
	}
}
Пример #30
0
Файл: map.cpp Проект: faod/ld33
void Map::drawrock()
{
    al_set_target_bitmap(bm_);
    for(int y = 0; y < tiles_.size(); y++)
    {
        for(int x = 0; x < tiles_[y].size(); x++)
        {
            BIOME b = tiles_[y][x].getBiome();

            if(b == ROCK)
            {
                drawTile(tiles_[y][x], nullptr);
            }
        }
    }
    al_set_target_backbuffer(al_get_current_display());
}