DirectX C ++向下移动精灵 [英] directx c++ move down sprite

查看:75
本文介绍了DirectX C ++向下移动精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想移动插入到Directx窗口中的位图,例如俄罗斯方块,但只有下降部分(自由下降方向),我认为它需要一个计时器,并且坐标可以有人给我一个示例代码吗?(我是新手).到目前为止,我已经创建了一个插入主位图的窗口,但是我需要使动画下降.

谢谢
Kyriakos

I want to give movement to a bitmap inserted in a directx window, like tetris but only the falling part (free fall down direction), I supose it needs a timer and the coordinates can someone give me a sample code?(I am a newbie). So far I have created the window inserted the main bitmap but I need the animation falling.

Thank you
Kyriakos

推荐答案

不,您不应该使用计时器.通常,您要做的就是拥有一个代表实体的类(对于俄罗斯方块,则代表一个块).此类的职责是管理块的移动并在屏幕上绘制块的图像.
您的主循环会不断更新代码中的所有元素,它们会根据位置是否在移动而更新位置.
如果您有兴趣,可以在此处 [ ^ ](第二部分可能会让您感兴趣).这是特定于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


这篇关于DirectX C ++向下移动精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆