-
Notifications
You must be signed in to change notification settings - Fork 11
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
No zoom supported when drawing #1
Comments
The drawing functionality of the library is the most primitive part, kind of on purpose. The kind of global scaling operation you're talking about is best accomplished at a layer above, setting some sort of transformation matrix on the batch of sprites to be drawn. I would suggest trying that before trying to plug scaling-specific code into Tiled.cs. I took ownership of this project since it was effectively abandoned, and left all the drawing code alone because it's so simple. But I think that most people will want to reimplement that part for their own game, and I didn't want to try to make it extensible before understanding how people would want to extend it. As a matter of fact, I've made extensive domain-specific modifications to this project, including the drawing aspect, for my own game: https://github.com/zachmu/escape-from-enceladus/blob/master/Arena/Arena/Map/Tiled.cs#L356 |
The drawing appears to do simple culling to the actual viewport (which is a good idea). Won't that all break if I apply the scaling afterwards? It seems more clean to me to handle this inside the drawing code of tiled-xna itself to handle culling correctly. |
Yes, you're correct. You would need to compensate for the culling when you do scaling. In my fork, I'm actually calculating which parts of the world are visible every time I draw the map: https://github.com/zachmu/escape-from-enceladus/blob/master/Arena/Arena/Map/Tiled.cs#L545 So if you wanted to scale up or down, you would just need to take the scaling factor into effect when you computed the boundary of the visible world. Hope that helps, Zach |
Can that be done without modifying the draw function itself as you initially suggested? If I already have to modify it, I'm not sure why I should even use matrix stuff afterwards when I could scale right in there (replacing the 1f with the proper scaling factor etc). |
I would have to read the docs or maybe experiment to say for sure, but I think that the scale factor on SpriteBatch.Draw() is independent of any transformation matrix used in SpriteBatch.Begin(). I can't say for sure because I'm only doing translation, not scaling, in my implementation. But I do think that, as much as possible, you want to keep your map classes drawing in game-space and allow a transformation matrix to translate that to screen-space; I don't see why scaling should be an exception to this rule. But as I said, I haven't actually tried this. I've seen SpriteBatch do some counter-intuitive things before, and I would believe you if you said that you have to set the scaling factor in every call to Draw(). Myself, I would try using a matrix first and see where that gets you. |
Since the culling is handled in Draw and it needs to know about the zoom, I On Mon, May 6, 2013 at 7:56 PM, Zach Musgrave [email protected]:
|
Please add zoom (with zoom factor for 1 normal size, 0.5 half the size etc... should allow any arbitrary zoom factor >0) to the drawing functionality.
While really old-style RPG maker games probably won't use it, it's very useful for more modern games and especially realtime strategy games with more fast-paced gameplay where you'd want to have large camera movement freedom.
If it's already in there then I apologize, but from examining the code it seems this is not possible right now.
The text was updated successfully, but these errors were encountered: