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

Thought/Feature Request - Create method to draw Tile Map with user passed in function #75

Open
kaltinril opened this issue Jun 28, 2022 · 3 comments
Assignees
Labels
feature New feature or request

Comments

@kaltinril
Copy link

I haven't started using TiledCS yet but plan on trying it out instead of Monogame.extended. I've run into a few issues with trying to get extended to work with Monogame 3.8 related to content pipeline.

Thought Setup: In your example, and tameez example, both are showing different ways to iterate over the tiles in a map so they can be drawn. These are great, and a user of TiledCS can just take those and toss them in their project/game/etc.

Thought: What if TiledCS had it's own map.draw method that took (as input) functions that it would use to draw the tiles. Then your library could house the mechanisms to do all the heavy lifting, leaving the users with just creating a method that would be passed in for drawing the individual tile. Things like the camera position (world offset), zoom, could all be passed in along with the function.

Just a thought, I didn't see a discord or other option for discussions.

@TheBoneJarmer
Copy link
Owner

Hey @kaltinril

Thanks a lot for your idea! I do not have a Discord for TiledCS indeed as I honestly didn't think I was gonna need one. And I'm not planning to open up one in the future. But perhaps who knows? Anyhows, about your idea. If I understand correctly you wish to hides the Tiled specific logic for figuring out what tile to render and where so only the rendering has to be done, right?

I think that is a great idea as it makes sense. I mean, you don't really wanna bother with that stuff anyways. But I am afraid cannot do it without having to use some of MonoGame's classes. And I don't want to because I pledged to keep TiledCS independent as not everyone uses MonoGame including me. Also, I have seen the state of MonoGame's documentation and I think it is lacking big time.

Which is why I said to others requesting similar features that the MonoGame community should come up with an example on how to use TiledCS in MonoGame. And it so happens Tameez did exactly that. The best I can do and what I already do is providing helper methods that give you the necessary input you need for rendering a tile and therefore a map.

That said, what I could and should do is provide some code sample. Someone mentioned the lack of it and rightfully so. I cannot give a whole working project obviously but only the rendering and loading part should suffice.

@kaltinril
Copy link
Author

I'm so sorry, I saw your response in my email, and then I completely spaced it until a random thought triggered my memory I never replied to you!

Correct, hide the tiled specific logic.

I don't think you'd need MonoGame specific classes in your library. Your class would just expect a DrawTile method to be provided to it somehow.

One way, when creating the tiled map object, perhaps there can be a method called DrawMethod(). This would be called by the user, and they would pass in an object (class, method). This method would be what you draw with. The user would be responsible for creating this object. If it's a class, you could provide an interface. Inside they'd have to define a DrawTile() method. This would take as input the high level details like tileID, etc, then they'd call similar methods as the example to pull back the texture, and draw it with (whatever their specific engine is, monogame, whatever).

But essentially, you just need the user to provide you with how to draw a single tile, and the inputs to it need to be library agnostic (only relate to your library) and they need to use those in their method to draw the tile based on the source texture/sprite and the destination.

Just thoughts.

@TheBoneJarmer
Copy link
Owner

Hey

Sorry for the absolute late reply!! I understand what you mean now and I actually think that is a good idea. But how it would look like, I don't know. Many options to choose from here. I could go for an interface, a delegate, virtual void, ... Will have to give it some thoughts. But thanks for the ideas!

@TheBoneJarmer TheBoneJarmer self-assigned this Jul 26, 2022
@TheBoneJarmer TheBoneJarmer added the feature New feature or request label Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants