• 【自用14.2】C++俄罗斯方块


    该系列文章会根据项目的编写步骤来出

    实现游戏场景的背景

    由于设备问题,暂时出的代码是未进行运行检验的,后期会补上运行后的版本

    1. #include //C语言形式的输入输出
    2. #include //图形库的头文件
    3. int score = 0;//总分
    4. int rank = 0;//等级
    5. //实现欢迎界面
    6. void welcome(void);
    7. //初始化游戏场景
    8. void initGameScene(void);
    9. int main(void){
    10. welcome();
    11. initGameScene();
    12. system("pause");
    13. colsegraph();
    14. return 0;
    15. }
    16. void welcome(void){
    17. //初始化画布
    18. initgraph(550,660);
    19. //设置窗口标题
    20. HWND window=GetHWnd();//获取窗口
    21. SetWindowText(window,_T("俄罗斯方块 .远_"))//设置窗口标题
    22. //设置文本的字体样式
    23. setfont(40,0,_T("微软雅黑"));//0代表自适应宽度
    24. setcolor(WHITE);
    25. outtextxy(205,200,_T("俄罗斯方块"));//在指定位置输出文本
    26. setfont(20,0,_T("楷体"));//0代表自适应宽度
    27. outtextxy(175,300,_T("编程,从俄罗斯方块开始!"));//在指定位置输出文本
    28. Sleep(3000);//暂停3秒钟
    29. }
    30. void initGameScene(void){
    31. char str[16];
    32. //清除屏幕
    33. cleardevice();
    34. rectangle(27,27,336,635);
    35. rectangle(29,29,334,633);
    36. rectangle(370,50,515,195);
    37. setfont(24,0,_T("楷体"));
    38. setcolor(LIGHTGRAY);
    39. outtextxy(405,215,_T("下一个"));
    40. setcolor(RED);
    41. outtextxy(405,280,_T("分数"));
    42. sprintf(str,"%d",score);
    43. outtextxy(415,310,str);
    44. //这里需要修改项目属性,操作方法如下
    45. //右击项目名称-》选择属性-》配置属性-》字符集-》使用多字节字符集
    46. outtextxy(405,375,_T("等级"));
    47. sprintf(str,"%d",rank);
    48. outtextxy(425,405,rank);
    49. //操作说明
    50. setcolor(LIGHTBLUE);
    51. outtextxy(390,475,_T("操作说明"));
    52. outtextxy(390,500,_T("↑:旋转"));
    53. outtextxy(390,525,_T("↓:下降"));
    54. outtextxy(390,550,_T("←:左移"));
    55. outtextxy(390,575,_T("→:右移"));
    56. outtextxy(390,600,_T("空格:暂停"));
    57. }

  • 相关阅读:
    汇率查询接口
    Springboot+网上投资借贷中介服务 毕业设计-附源码221506
    JS垃圾回收
    TS的类型编程
    嵌入式(驱动开发)(中断处理)
    1084 外观数列
    第7章 - 多无人机系统的协同控制 --> 多无人机协同控制
    linux-log系统日志输出等级
    【纯手工打造】时间戳转换工具(python)
    python读取CSV格式文件,遇到的问题20231007
  • 原文地址:https://blog.csdn.net/m0_57667919/article/details/141234546