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 use function to realize bouncing Ball and eliminating Brick in C language

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to use functions to realize bouncing balls and eliminating bricks in C language". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Project description and final results presentation

This is a series of optimization and encapsulation on the last bounce project. Event: bouncing ball

There was no encapsulation with functions last time. This time on the basis of the last package and some functional optimization.

The final effect is as follows:

Second, the encapsulated bouncing ball

The code is as follows:

# include#include#include#include// global variable int high,width; / / the coordinate of the int ball_x,ball_y;// ball in the game screen size void gotoxy (int x camera int y) / / move the cursor to the (x STD_OUTPUT_HANDLE y) position {HANDLE handle = GetStdHandle (STD_OUTPUT_HANDLE); COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition (handle,pos) Initialization of} void startup () / / data {high = 15; width = 20; ball_x = 0; ball_y = width/2; ball_vx = 1; ball_vy = 1;} void show () / / display screen {gotoxy (0d0); / / move the cursor to the origin position, the following redraw the screen int iMaging j; for

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