Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 107 Merge River Deltas into Tilemaps #433

Draft
wants to merge 60 commits into
base: pcen/use-tilemaps
Choose a base branch
from

Conversation

benskywalker
Copy link
Contributor

This PR will merge the river deltas into tilemaps. It also fixed a problem where the tilemaps branch never showed any rivers. There's still work to be done; currently the deltas will often show up in the ocean or on a land tile. I should check for river directionality, which will be somewhat more complex

pcen and others added 19 commits September 17, 2023 15:47
add Camera2D

test drawing units in word coordinates

wip

simplify unit sprite test demo - AnimationManager could be simpler but trying to keep diff small

enable pixel snapping - removes world seams

render roads in tilemap

add logic for drawing rails on tilemap - missing separate layer

working rails layer

simple abstraction for loading atlas sources

add resources and clear cells when empty

track net lines changed

working rivers

separate notion of layer and atlas in MapView

add mountains

get rid of incorrect y offsets (tiles are already centered)

offset is necessary for oversized tiles...

add volcanos

single terrain overlay

add full left skirt to terrain layer

detect edges of map in world space

fix bad bounds for forest tiles and use full resource tileset

wip

tile set loader so specific assets can be overwritten in the future

add marsh to tilemap terrain overlay layer

camera can center on tiles

buildings on tilemap

remove ported code

load goodyhut pcx

pixel perfect transforms

dedupe code

enable Y sort for each tilemap layer

kinda working animations

wip

wip

working sprite animations

render best defender on top of unit stack

significantly faster animation loop when only doing visible tiles

draw cursor

remove ported code
@benskywalker
Copy link
Contributor Author

benskywalker commented Sep 23, 2023

image
This delta is showing up in the ocean. Also the rivers are always rendered in the middle of tiles, which is a problem since you can't easily tell what edge they're on (bad for debugging but also for playing).

This delta needs to be forward a bit
image
I've got to find out how to render rivers on the edge of tiles in this new system

@pcen
Copy link
Contributor

pcen commented Sep 23, 2023

The way the TileMap renders terrain is terrainTilemap is offset such that it renders the base terrain at the intersection of 4 tiles, so it is offset from tilemap which renders everything else such as hills and forests that fall on a tile. This is done because the terrain that should be rendered on each tile is 4 corners from terrain pcx tiles. I'm not sure how rivers are rendered but it's likely that they could be added as another layer in terrainTilemap?

@benskywalker
Copy link
Contributor Author

benskywalker commented Sep 23, 2023

Ok, thanks for the info. In that case I think we just need to make it rivers are not offset from the base grid. That way they'll start at corners of tiles like (I think) they do in the base game. Here's an example from the base game:
image

And C7
image

Slight differences are normal, but these rivers consistently pass through the middle of every tile, rather than mainly sticking to the edge

@benskywalker
Copy link
Contributor Author

This is proving more difficult than expected. Rivers are currently marked as a layer in the tilemap, but making them show up at the corner of tiles (or at least shifted a bit) is tricky.
image
Whenever I mess with setCell in mapView to try and offset rivers there, they don't show up properly. I tried to offset them by half a tile width in x, y, or both, but none of that worked. It might be possible to offset them and I'm just doing it wrong, so I'll keep looking into this

@pcen
Copy link
Contributor

pcen commented Sep 24, 2023

I don't think it's really possible to set the offset of a tile in a TileMap - the stackedCoords are coordinates that index into a tile. We can set an offset for a particular atlas texture in the TileMap. This is done in the TileSetLoader in TileSetLoader.cs. You can trace the code, but for example:

{Atlas.JungleVolcano, new AtlasLoader("Art/Terrain/Volcanos jungles.pcx", 4, 4, mountainSize, 12)},

The last parameter is passed into the loader, and eventually gets assigned to TextureOrigin, which gives that texture a relative offset to the tile it's in. I'm pretty sure rivers are rendered on tile edges they lay along. I'd suggest adding the river tiles to terrainTileset since the entire terrain tilemap is offsest half a tile in both x and y, so if we render a river overtop of base terrain on the terrainTilemap I think the river texture will line up perfectly with tile boundaries. This thread gives a decent explanation of how terrain is rendered: https://forums.civfanatics.com/threads/terrain-editing.622999/

@WildWeazel
Copy link
Member

@benskywalker have you or can you check the selection logic against the Java code linked to in #107 ? I think that's the best reference we have.

@benskywalker
Copy link
Contributor Author

@benskywalker have you or can you check the selection logic against the Java code linked to in #107 ? I think that's the best reference we have.

I haven't, but I'll get on that once I've got some more dev time

@QuintillusCFC QuintillusCFC added the tilemap PRs targeting Tilemaps on Godot 4 label Mar 22, 2024
@pcen pcen force-pushed the pcen/use-tilemaps branch from 62c2795 to 4f78192 Compare October 1, 2024 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tilemap PRs targeting Tilemaps on Godot 4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants