找回密码
 立即注册
C#编程 2022-09-23 101 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
通过制作这个坦K游戏,我开始掌握了一些小游戏的制作方法,如今总结如下:1要学好C言语的基本言语,理解基本算法和过程控制;2学会制作基本图形;图型模式的启动请参看该版斑竹置顶贴《给我一个点我能勾画全S界》,基本图形的函数可以多参看别的程序,我在这儿只提几个最基本的函数:1)矩形:rectangle(intx,inty,intex,intey);其间x是起始点横坐标,y是起始点纵坐标,ex是停止点横坐标,ey是停止点纵坐标;2)圆:circle(intx,inty,intr);x,y是圆心坐标,r是半径;3)设置背景色:setbkcolor(intc);c是你想设置的颜色,详细内容参看该版斑竹置顶贴《函数查阅器》;3这些你都掌握后就可以进行你第一个游戏的尝试了;1)首要你要理解自己C言语掌握状况,构思符合实际的游戏设想,可以稍稍逾越自己的水平,但是要清理技术瓶茎在哪里;2)多看看别的人的程序,找到管理或绕过瓶颈的方法;3)制作游戏详细进程(我以坦K为例):(1)切割屏幕:即是设定好游戏范围,和用方格将屏幕切割,这样方便。定位你的图形方位,我是制作了一个表格函数放到了。include文件夹里,你可以直接把代码放到程序里也可以;(2)绘画静态图形:以你的网格为规范,制作你的游戏主人公,我的即是制作坦K,详细方法请参看我的原代码中。voidtank(intx,inty,intc)函数,还有炮弹函数和爆/破函数;(3)让你的图形动起来:A我是先编辑我控制的坦K:a用到了键盘控制:详细行为是先定义你要用的键位,如坦K最初。定义的那几行#define,后边的值是与键一对一对应的,如:up0x4800down0x5000left0x4b00;right0x4d00esc0x011b等;b依据输入的键,改动主人公(坦K)的坐标,参看原程序主函数结束部分;c循环依据坐标制作主人公(坦K);B让对方的坦K动起来:a仅仅把键盘控制用随机数控制替代,我用random()函数生成4个随机数,顺次替代4个按键;b,c和上述的A样;(4)同步动作:把一切的工具放在一个大循环傍边,每循环顺次就改动一次坐标,并依据新坐标绘图,这儿我要着重keyhit()函数的重要性,详细用法请参看附件中的贪吃蛇比如;至次,你的游戏就应该开始成型了,以后的工作不过是怎样完善他装修他,这个要依据个人的喜欢自己搞定了;由于我也是新手,所以我的总结难免有不对的当地,还请各位高手多多指点
20070610192300108\登录窗口\HZK16
c案例\C1.C
c案例\C10.C
c案例\C11.C
c案例\C12.C

(By making this tank game, I began to master the production methods of some mini-games, which are summarized as follows: 1. Learn the basic language of C language, understand basic algorithms and process control; 2. Learn to make basic graphics; please refer to the start of the graphics mode. This version of Bamboo sticks to the top of the post "Give me a point and I can draw the whole world". For the functions of basic graphics, you can refer to other programs. I will only mention a few basic functions here: 1) Rectangle: rectangle(intx, inty, intex, intey); where x is the abscissa of the starting point, y is the ordinate of the starting point, ex is the abscissa of the stopping point, and ey is the ordinate of the stopping point; 2) Circle: circle(intx, inty, intr); x, y is the coordinate of the center of the circle, r is the radius; 3) Set the background color: setbkcolor(intc); c is the color you want to set, for details, please refer to the "Function Viewer" posted on the top of this version of Bamboo; 3 After you master these, you can proceed Your first game attempt; 1) First of all, you need to understand your C language mastery, and the idea of ??the game is in line with the actual game design, you can slightly exceed your own level, but you need to clear up where the technical bottle stem is; 2) Look at other Find a way to manage or bypass bottlenecks; 3) Make a detailed process of the game (I take a tank as an example): (1) Cut the screen: that is, set the game range, and cut the screen with squares, So convenient. To locate your graphic orientation, I made a table function and put it there. In the include folder, you can directly put the code into the program; (2) draw static graphics: use your grid as the norm to make your game hero, mine is to make a tank, please refer to me for details in the original code. voidtank(intx, inty, intc) function, as well as cannonball function and blasting function; (3) Make your graphics move: A I edit the tank I control first: a Use keyboard control: The detailed behavior is to define you first The keys to be used, such as tanks initially. The defined lines #define, the values ??behind are one-to-one correspondence with the keys, such as: up0x4800down0x5000left0x4b00; right0x4d00esc0x011b, etc.; b According to the input keys, change the coordinates of the protagonist (tank), see the end of the main function of the original program; c The cycle makes the protagonist (tank) based on the coordinates; B makes the opponent's tank move: a just replace the keyboard control with random number control, I use the random() function to generate 4 random numbers, and replace the 4 buttons in sequence; b, c Same as above A; (4) Synchronous action: put all the tools in a big loop, change the coordinates one by one in each loop, and draw according to the new coordinates, here I want to focus on the importance of the keyhit() function, For detailed usage, please refer to the example of greedy snake in the attachment; at the end, your game should begin to take shape, and the future work is just how to improve him and decorate him, which should be done according to personal preference; since I am also a novice, Therefore, my summary is inevitably wrong, and please give pointers from experts.
20070610192300108\Login window\HZK16
ccase\C1.C
ccase\C10.C
ccase\C11.C
ccase\C12.C)

[下载]23102539254.rar




上一篇:C语言函数大全
下一篇:仿真windows登录(C语言代码+超棒)