简体   繁体   English

在2D游戏中的运动(blitting时的圆形位置?)

[英]Movement in 2D Games (round position when blitting?)

I use Python 2.x and Pygame to code games. 我使用Python 2.x和Pygame来编写游戏代码。 Pygame has a built-in rect (Rectangle) class that only supports ints instead of floats. Pygame有一个内置的rect(Rectangle)类,它只支持int而不是float。 So I have made my own rect class (MyRect) which supports floats. 所以我创建了自己的rect类(MyRect)来支持浮点数。 Now my question is as follows: 现在我的问题如下:

A 2D platformer char moves its position (x, y -> both floats). 2D平台变形器char移动其位置(x,y - >两个浮动)。 Now when I blit the char onto the screen, is the position rounded to an int (int(round(x))) or just converted into an int (int(x))? 现在当我将焦点blit到屏幕上时,是否将位置四舍五入为int(int(round(x)))或者只是转换为int(int(x))? I know this might sound a bit stupid, but I've got an issue with this and I'd like to know how this is usually handled. 我知道这可能听起来有点愚蠢,但我有一个问题,我想知道这通常是如何处理的。

你应该假设在pygame.Surface一个pygame.Surface ,位置通过int()转换为int

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM