Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize bouncing Ball and eliminating Brick with Array in C language

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "how C language uses array to realize bouncing ball eliminating brick". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how C language uses an array to achieve bouncing ball eliminating bricks" can help you solve your doubts. Let's follow the editor's ideas to learn new knowledge.

First, the effect display:

2. The code is as follows: # include#include#include#include#include#define High 24 / / Game screen size # define Width 36 define Width / global variable int ball_vx,ball_vy;// ball coordinates int ball_vx,ball_vy;// ball speed int canvas [High] [Width] = {0}; int position_x,position_y;// bezel center coordinate int ridus;// bezel radius size int left,right;// bezel left and right size int score=0 / / score / / two-dimensional array stores the corresponding element / / 0 in the game canvas for spaces, 1 for balls, 2 for baffles, 3 for bricks (1 point), 4 for bricks (2 points), 5 for bricks (3 points) void gotoxy (int x STD_OUTPUT_HANDLE int y) / / move the cursor to the (x STD_OUTPUT_HANDLE) position {HANDLE handle=GetStdHandle (STD_OUTPUT_HANDLE); COORD pos; pos.X=x; pos.Y=y; SetConsoleCursorPosition (handle,pos) } void startup () / / initialization of data {int krecoveri; ridus=5; position_x=High-1; position_y=Width/2; left=position_y-ridus; right=position_y+ridus; ball_x=position_x-1; ball_y=position_y; ball_vx=-1; ball_vy=1; canvas [ball _ x] [ball_y] = 1; for (kumbleftmitk)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report