本文介绍了如何在C ++中对蛇游戏有所了解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在游戏中遇到困难,就像我按1轻松按2并按中等中等键一样,随着级别的提高,蛇会加快速度
... tnx
how to have difficulties in this game like if I press 1 for easy and press 2 for medium and as the level goes up the snake gains speed
...tnx
推荐答案
- 您将不得不使用一段时间或循环播放的定时器,直到您死了,否则它不会被取消. (count生活在变量中).
- 您将必须学习如何捕获击键. (getchar,getc).
- 您将必须学习如何建立计时器. (可能您必须在主循环中入睡).
- 您将必须学习如何绘制屏幕.
- 您将必须了解如何知道这条蛇是什么,以及它是否与墙壁或自身相撞.
- You''ll have to loop using a while or a timer that is not cancelled until you are dead. (count lives in a variable).
- You''ll have to learn how to capture keystrokes. (getchar, getc).
- You''ll have to learn how to establish a timer. (Probably you''ll have to put a sleep inside the main loop).
- You''ll have to learn how to draw the screen.
- You''ll have to learn how to know were the snake is and if it is colliding with a wall or with itself.
一个有趣的好项目...
祝你好运!
A nice project to get some fun...
Good luck!
Snake.Speed = Snake.Speed*(1+scalar*(Snake.difficulty));
现在您可以根据级别设置蛇的速度.
另外,只需更改标量值,就可以更改速度的变化率.
希望对您有帮助. :-)
Now you can set the speed of snake according to the level.
Also, Just by changing the scalar value, you can change the rate with which the speed changes.
Hope it helps you. :-)
这篇关于如何在C ++中对蛇游戏有所了解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!