FreshRSS

Normální zobrazení

Jsou dostupné nové články, klikněte pro obnovení stránky.
PředevčíremHlavní kanál
  • ✇Recent Questions - Game Development Stack Exchange
  • Why pallete and grid cell sizes differsRheinmetallSkorpion
    I created a tile map with default cell size 1,1. Then I created a palette with the same cell size but they are not the same. In the palette they do not fill the entire cell and changing the pixels per units does not affect the palette. I have the problem that the floor tiles are not the same size with the tiles that should go under so I tried to resize them in palette to fill the whole cell but in the game it was way bigger then 1 cell
     

Why pallete and grid cell sizes differs

I created a tile map with default cell size 1,1. Then I created a palette with the same cell size but they are not the same. In the palette they do not fill the entire cell and changing the pixels per units does not affect the palette. I have the problem that the floor tiles are not the same size with the tiles that should go under so I tried to resize them in palette to fill the whole cell but in the game it was way bigger then 1 cell enter image description here

  • ✇Recent Questions - Game Development Stack Exchange
  • How to make a tilemap in pygame?Joshua Carlson
    so I have some Python code to generate a random 10x10 grid in which a mine will be or won't be placed, I am having trouble trying to convert this list into a use-able set of coordinates. Any help would be appreciated fieldx = 10 fieldy = 10 objecs = 20 Field = [] for i in range(fieldy): Field.append([]) for j in range(fieldx): Field[i].append([0]) for i in range(objecs): x = random.randint(0,fieldx-1) y = random.randint(0,fieldy-1) if Field[y][x] == [0]: Field[y][x] =
     

How to make a tilemap in pygame?

so I have some Python code to generate a random 10x10 grid in which a mine will be or won't be placed, I am having trouble trying to convert this list into a use-able set of coordinates. Any help would be appreciated


fieldx = 10
fieldy = 10
objecs = 20
    
Field = []
for i in range(fieldy):
  Field.append([])
  for j in range(fieldx):
    Field[i].append([0])



for i in range(objecs):
  x = random.randint(0,fieldx-1)
  y = random.randint(0,fieldy-1)
  if Field[y][x] == [0]:
    Field[y][x] = [1]

How can I instantiate an object on all tiles of a hexagonal tilemap?

On startup, I want to instantiate a text object on each tile (displaying its info). How can I accomplish this for a hexagonal tilemap?

Here's my poorly written code that doesn't work. It seems to create the right number of objects but I'm not sure how to get the correct positioning.

for (int x = 0; x < cellBounds.size.x; x++) {
        for (int y = 0; y < cellBounds.size.y; y++) {
            TMP_Text tileText = Instantiate(tileTextPrefab, tileUI.transform);
            tileText.text = dict[new Vector3(x,y,0)].getName();
            float hexOffset = 0f;
            if(y %2 != 0) hexOffset = cellSize.x * 0.5f;
            tileText.transform.position = new Vector3(x * cellSize.x + hexOffset, y * cellSize.y, 0);
        }
    } 
  • ✇Recent Questions - Game Development Stack Exchange
  • Tilemap.SetTile results in no visible change in buildCrafik
    I have an issue with how the Tilemap works in build, using version 2022.3. I update my Tilemap with Tilemap.SetTile(Vector3Int pos, null) and it works just fine in Editor. But in build, it won't update visually. It updates the collider, and player can move through virtually inexistent tiles, while they still being visible. Neither editor nor build throws any errors. Attaching screenshots of Inspector window for Tileset in question and Hierarchy window for Grid. As well as video demonstrating the
     

Tilemap.SetTile results in no visible change in build

I have an issue with how the Tilemap works in build, using version 2022.3.

I update my Tilemap with Tilemap.SetTile(Vector3Int pos, null) and it works just fine in Editor.

But in build, it won't update visually. It updates the collider, and player can move through virtually inexistent tiles, while they still being visible. Neither editor nor build throws any errors. Attaching screenshots of Inspector window for Tileset in question and Hierarchy window for Grid. As well as video demonstrating the issue.

Videos:

Editor - https://youtu.be/O5R-vt5KMAo

Build - https://youtu.be/pGal2Bpk7L4

Code snippet:

void Update(){
    if (isUnlocking){
        if (unlockCounter < 0f){
            for (int i = 0; i < sizeX; ++i){
                gates.SetTile(new Vector3Int(startTilePos.x + i, startTilePos.y - rowCounter, startTilePos.z), null);
            }
            rowCounter++;

            unlockCounter = unlockSpeed;
            Vector2 impDir = Random.insideUnitCircle.normalized;
            impulser.m_DefaultVelocity.x = impDir.x * 0.1f;
            impulser.m_DefaultVelocity.y = impDir.y * 0.1f;
            impulser.GenerateImpulse();
            audioplayer.clip = door_open;
            audioplayer.Play();
        }
        unlockCounter -= Time.deltaTime;
        if (rowCounter == sizeY && unlockCounter < 0f){
            Destroy(gameObject);
        }
    }
}

Editor inspector

Grid hierarchy

How to attach a sprite to a TMXTiledMap at a particular coordinate, in AndEngine?

I am trying to add a sprite at a "grid" location on the tiled map. The TMX tiled Map is like a grid, and you can access the size of the grid by calling mTMXtiledMap.getTileRows() and mTMXtiledMap.getTileColumns().

I want to add an object at grid location, say (2, 5). My tileMap is of size (10,10).

How can I do that? There is no function like mTMXTiledMap.addChild(int x, int y, Entity mEntity).

I would appreciate any suggestions!

How do I place the local center of my tilemap at 0,0?

If I have a tilemap that is 4x8, positioned at 0,0 in the editor as follows:

4x8 tilemap positioned at 0,0

What code would I use such that it ends up "centered" when my game runs?

I'm hoping for an end result that would look like this:

Demonstration of 4x8 tilemap centered by moving the tilemap to -24x-24

As you can see, the tilemap has been moved left 24 pixels and up 24 pixels. This example is manually done, but I'd like to be able to do it using the Godot APIs so that tilemaps of different dimensions can be centered.

  • ✇Recent Questions - Game Development Stack Exchange
  • Depth sorting issueTheDBeetle
    I've been working on a custom tile-based map editor for a while now, and everything works as expected, or so I thought until I've tried rendering the actual map including the dynamic objects as well. As it currently works, it's saving data into a buffer in a format of: [ground layer] [on-ground layer] (flowers/rocks) [wall layer] [on-wall layer] (windows/torches/bookshelves) So basically there's a total of 4 layers. The tiles are rendered from top left corner to bottom right corner in the fol
     

Depth sorting issue

I've been working on a custom tile-based map editor for a while now, and everything works as expected, or so I thought until I've tried rendering the actual map including the dynamic objects as well.

As it currently works, it's saving data into a buffer in a format of: [ground layer] [on-ground layer] (flowers/rocks) [wall layer] [on-wall layer] (windows/torches/bookshelves)

So basically there's a total of 4 layers. The tiles are rendered from top left corner to bottom right corner in the following order: [ground layer] -> All tiles [on-ground layer] -> All tiles [wall layer] Does an instance exists on that spot? in case it does the instance gets rendered first, and then the tile itself. [on-wall layer] renders normally right after that.

This system seems perfectly fine it the game has a grid-based movement, as well as if all the dynamic sprites are the same size like the tile size. Why? Well, you'd just walk anywhere and get covered with a certain tile or be drawn over a certain tile. On the other hand, if any of the dynamic instances has let's say a sprite height which is bigger than the actual tile size the depth sorting issues appear.

Example: We've got a pillar which is 16x48 in size. The very bottom of the pillar has a collider of 16x16 and it can't be stepped on, but the mid and top part don't have any colliders. Now if a player for example steps on the topmost tile of the pillar everything gets rendered normally. On the other hand if the steps on the mid tile, the "player's head" would be rendered over the topmost tile..

Screenshot of tile map sorting problem

I'm wondering if there's an actual solution for depth ordering in a case like this.

❌
❌