[英]Mapping coordinates to screen in PyGame
Ok, lots of explaining to follow, so bear with me. 好的,很多解释要遵循,所以请耐心等待。
I'm making a 2D top-down game in PyGame, and I have a "chunk loading" system set up. 我在PyGame中制作了一个2D自上而下的游戏,我设置了一个“chunk loading”系统。 The system is as follows...
系统如下......
I have a "world" object, made up of "chunks". 我有一个“世界”的对象,由“块”组成。 Each chunk is 16x16 "tiles" and contains data for each one of those tiles.
每个块是16x16“瓦片”并包含每个瓦片的数据。 In the world object, I have a system for generating these chunks as needs be, and storing them in a dictionary, like
{(x, y):"grass"} etc...
Each tile in the chunk is a 10px image, that needs to be drawn to the screen in PyGame, given the position of the camera ( counted in tiles ). 在world对象中,我有一个系统可以根据需要生成这些块,并将它们存储在字典中,如
{(x, y):"grass"} etc...
块中的每个tile都是10px图像,考虑到相机的位置( 以瓷砖计算 ),需要在PyGame中绘制到屏幕。 I want the camera to be able to pan around over the top of these images, and move around. 我希望相机能够在这些图像的顶部平移,然后四处移动。 How on earth can I make this work?
我怎么能做这个工作?
A quick diagram... 快速图表......
diagram http://williamgardner.noip.me/files/chunks 图http://williamgardner.noip.me/files/chunks
I hope this makes sense, thanks! 我希望这是有道理的,谢谢!
If I understand your problem right, TomTsagk explained it really good: 如果我理解你的问题,TomTsagk解释说它非常好:
Pygame camera follow in a 2d tile game Pygame相机在2d平铺游戏中跟随
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.