当前位置:网站首页>5 minutes to make a bouncing ball game
5 minutes to make a bouncing ball game
2022-06-28 15:52:00 【51CTO】
hi ! Hello everyone , The ant is me . Many novice friends who want to learn how to play games suffer from having no way to start , I don't know what I can do , Where to start . In fact, start with a simple game , It's a very good way .
First of all , This will let you really start to participate in the production of the game ( Of course, you need to play games , You can't just look with your eyes ), second , You can get good feedback from the games you make , There is no better feedback than playing your own game .
This feedback is important , It will definitely tell you , See? ! It is not difficult to play a game , Just do it , You can do it . This kind of feedback will be the motivation to support you to continue .
Okay , Get down to business . Today we will try to use 5 Minutes of time , Quickly make a complete bouncing ball game . If you are a novice, Xiaobai , I don't know about some of them , It doesn't matter , Let's start with the gourd , Imitate the game , The most important thing is to do it . As for many things you don't understand , It can be supplemented by systematic learning in the future .
remember , Now the most important thing for you is to play the game first , Make it out , There will be feedback .
Open the wechat game making tool ( Official website ), New works , Create a “ Bouncing ball ” Empty project for .

Click on “ newly build ” After the button , You will enter into an empty project .

next , Click on “ Add material ” Button , Add the materials needed in the game , a square , A white number , And a basic text .


After importing , Will you be in Explorer See the game added 3 New resources , At the same time Hierarchical management in , You can also see the increase 3 A new level .

next , Let's adjust the name of the resource , Make it correspond to what you represent in the game .

Pictured , There are several elements in the game :
Bouncing ball : It represents the balls bouncing around in the game .
The player : It represents the platform that players can control to move and catch the ball in the game .
score : Represents the score of the player in the game .
Basic text : Used to display prompts in the game .
Next , Let's adjust the layout of various elements in the game .

The game includes 5 Elements , The whole process of the game is like this : Players click on the screen , Start the game , The rebound ball will pop up , Touch the left side of the screen , On the right side , Or the upper side will bounce , Players can control the white platform below to move left and right , Catch the falling rebound ball , Every time I catch it , Can get 1 branch , If not , The bouncing ball fell off the bottom of the screen , Then the game is over , Show “ GAME OVER” Tips .
The game material is ready , The interface is also arranged , Next , Let's implement the logic of the game !
Before you start writing logic , Prepare the data first , These data will be used in the game logic .

3 individual Global variables :“ Movement speed ” Used to set the speed of the bouncing ball ,“ Game begins ” Used to set whether the game starts ,0 Indicates that... Has not started ,1 To begin ;“ Game score ” Used to record the scores obtained by players in the game .
1 individual notice :“ Refresh score ” Used to notify the number of scores recorded in the game to refresh .
next , We will implement the building block logic of each element in the game in turn .
First , Realization “ The player ” Building block logic .

For the player's operation , Just one “ Set your own horizontal drag ” Building blocks for , You can realize the drag and drop function in the horizontal direction . in addition , Players here also deal with the logic of the beginning of the game , Click on the screen game to start , Hide text prompts , Reset game score , Set the game start variable , Finally, set a direction for the bouncing ball to start moving .
next , Realization “ score ” Building block logic .

“ score ” The building block logic of is very simple , Just receive “ Refresh score ” The notice of , Just change your value to the latest “ Game score ” The number .
Last , Realization “ Bouncing ball ” Building block logic . Want to achieve a rebound effect , You can make direct use of the “ rebound ” Behavior .
Choose “ Bouncing ball ”, stay “ layer properties ” Below , Click on “ Management behavior ” Button .

Find and turn on “ rebound ” Behavior .

In the open “ rebound ” After the act , There are two changes , One is to add attributes related to bounce behavior at the bottom of the attribute area , The other is the addition of and in the building block area “ rebound ” Behavior related building blocks .

Will bounce the properties of “ Speed of motion ” and “ Movement orientation ” Set to 0, We will use building blocks in the game logic to set the movement speed and direction of the bouncing ball .

Last , Let's take a look at the building block logic of the bouncing ball .

The building block logic of the rebound ball is divided into 3 Parts of , One is the movement of the ball after the game starts ; One is the end of the game when the ball moves out of the lower edge ; The other is the score processing when the player catches the ball .
such , The logical part of the whole game is completed , Let's click on “ Preview scene ” Button , Take a look at the final effect of the game .


What about? , Is it easy to play a game ? what ? You said it was difficult ? That's because you're first in a new field , Naturally, it will be difficult , It's like a child learning to walk for the first time , Clumsy , Even fall . however , Just practice hard , Soon you will find it easy .
Simplicity comes from proficiency , And proficiency comes from automatic hands . No matter what , Make the first game hard , In this way, you can really take your first step on the road of game development . otherwise , You can only be one “idea guys”( It refers to those who only have ideas ) 了 .
I am a little ant who can play games and teach you to play games , Welcome to WeChat official account. 【 Little ants teach you to play games 】, Get the most complete wechat game development original tutorial materials in the whole network , Learn some game development knowledge every day .

边栏推荐
- VS2013 帮助文档中没有 win32/com
- 讲师征集令 | Apache DolphinScheduler Meetup分享嘉宾,期待你的议题和声音!
- R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses regression coefficients and their standard errors to calculate the
- MIPS汇编语言学习-01-两数求和以及环境配置、如何运行
- 使用openpyxl操作Excel
- Spark SQL generate JSON
- 【MySQL】官网文档学习之查询语句sql注意事项
- What useful supplier management systems are available
- Longest continuous sequence
- 一种跳板机的实现思路
猜你喜欢

MIPS assembly language learning -02- logic judgment - foreground input

The Web3.0 era is coming. See how Tianyi cloud storage resources invigorate the system to enable new infrastructure (Part 1)

Qt5.5.1 configuring msvc2010 compiler and WinDbg debugger

MIPS汇编语言学习-03-循环

SAP MTS/ATO/MTO/ETO专题之九:M+M模式前后台操作,策略用50,提前准备原材料和半成品

Facebook! Adaptive gradient defeats manual parameter adjustment

Xinchuang operating system -- kylin kylin desktop operating system (project 10 security center)

教育行业SaaS应用管理平台解决方案:助力企业实现经营、管理一体化
![[recommendation system] esmm model of multi task learning (updating)](/img/21/8e38d3903eb1110efc4773edb2d09c.png)
[recommendation system] esmm model of multi task learning (updating)

5分钟的时间制作一个反弹球游戏
随机推荐
PostgreSQL 存储结构浅析
Summary of language features of fluent dart
Go zero micro Service Practice Series (VII. How to optimize such a high demand)
Innovation and upgrading of supply chain system driven management mode in petrochemical industry and strengthening internal management of enterprises
R language ggplot2 visualization: the patchwork package is used to customize and combine the three ggplot2 visualization results to form a composite graph. After the horizontal combination of two sub
信创操作系统--麒麟Kylin桌面操作系统 (项目十 安全中心)
Fleet | background Discovery issue 3: Status Management
北京有哪些牛逼的中小型公司?
See how the interface control devaxpress WinForms creates a virtual keyboard
What! 一条命令搞定监控?
MongoDB 在腾讯零售优码中的应用
部门新来了个字节25K出来的,让我见识到了什么是天花板
What! One command to get the surveillance?
Complete model training routine (I)
Gbase Nantah General Motors appears at the 6th World Intelligence Conference
石油化工行业供应链系统驱动管理模式创新升级,强化企业内部管理
厨卫电器行业S2B2C系统网站解决方案:打造S2B2C平台全渠道商业系统
Talking about open source - Linus and Jim talk about open source in China
Fleet |「后台探秘」第 3 期:状态管理
R language ggplot2 visualization: use the patchwork package (directly use the plus sign +) to horizontally combine a ggplot2 visualization result and a piece of text content to form a final result gra