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

[4.x] TileMap: Horizontal Wrapping #422

Merged
merged 14 commits into from
Sep 17, 2023

Conversation

pcen
Copy link
Contributor

@pcen pcen commented Aug 2, 2023

No description provided.

@pcen pcen marked this pull request as ready for review August 3, 2023 19:33
@pcen pcen force-pushed the pcen/use-tilemaps-render-cities branch from 5fdd5b3 to b5521ec Compare August 7, 2023 12:24
@pcen pcen force-pushed the pcen/use-tilemaps-horizontal-wrapping branch from 696bd81 to 96b3b62 Compare August 7, 2023 12:31
@WildWeazel
Copy link
Member

WildWeazel commented Aug 10, 2023

Seems to work well after several circumnavigations. I'm still wrapping my head around how this works, pun intended, but is there any potential issue with scrolling indefinitely?

@pcen
Copy link
Contributor Author

pcen commented Aug 10, 2023

Seems to work well after several circumnavigations. I'm still wrapping my head around how this works, pun intended, but is there any potential issue with scrolling indefinitely?

The camera never goes more than one full map-width beyond the "main" map. Once it reaches that point, the camera's location is translated one map-width back towards the origin, so in terms of infinite scrolling it will just keep wrapping back towards the origin

public bool isTileInView(Tile tile, MapView map) {
Rect2 visible = getVisibleWorld();
Vector2 target = map.tileToLocal(tile);
float size = 30;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this number? Can it be derived from something, and it not made a constant somewhere? I think we'd discussed having a class to hold all map related constants.

Comment on lines +78 to +82
if (atEdgeOfRightWrap(visibleWorld)) {
Translate(Vector2.Left * map.pixelWidth);
} else if (atEdgeOfLeftWrap(visibleWorld)) {
Translate(Vector2.Right * map.pixelWidth);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessarily needed right now, but Civ has a gradient where the scroll speed increases as the cursor approaches and pushes into the map edge

@WildWeazel
Copy link
Member

If nothing else let's merge this :)

@pcen pcen changed the base branch from pcen/use-tilemaps-render-cities to pcen/use-tilemaps September 17, 2023 19:17
pcen added 13 commits September 17, 2023 15:34
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
@pcen pcen force-pushed the pcen/use-tilemaps-horizontal-wrapping branch from 96b3b62 to 0d14b81 Compare September 17, 2023 19:39
@pcen pcen merged commit 34e78b2 into pcen/use-tilemaps Sep 17, 2023
@pcen pcen deleted the pcen/use-tilemaps-horizontal-wrapping branch September 17, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants