且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

DirectX C ++向下移动精灵

更新时间:2023-12-02 22:18:28

不,您不应该使用计时器.通常,您要做的就是拥有一个代表实体的类(对于俄罗斯方块,则代表一个块).此类的职责是管理块的移动并在屏幕上绘制块的图像.
您的主循环会不断更新代码中的所有元素,它们会根据位置是否在移动而更新位置.
如果您有兴趣,可以在此处 [ ^ ](第二部分可能会让您感兴趣).这是特定于OpenGL的,但也涵盖了运动.
No, you shouldn''t use a timer. Typically, what you will have to do is have a class that represent an entity (in the case of the tetris, a class representing a block). It is the responsability of this class to manage the movement of the block and to draw the image of the block on the screen.
Your main loop constantly update all elements of your code and they update their positions depending if they are in movement or not.
If you are interested, you can have a look at a tutorial I made about openGL here[^] (the second part is more likely to interest you). This is specific to OpenGL but movement is also covered.


您的意思是我将创建该类并具有一个将x,y坐标更新为1或2 ...的函数.每个速率都会发生这种循环吗?

Kyriakos
You mean I will create the class and have a function that will update the x,y coordinates to 1 or 2 ... and in the loop in every rate this will happen?

Kyriakos


能给我一个示例代码吗?

谢谢
基里亚科斯(Kyriakos)
Can you give me a sample code?

Thank you
Kyriakos