当前位置:网站首页>[plaything determination scratch children programming] ride a small motorcycle (dynamic background + camera control operation)
[plaything determination scratch children programming] ride a small motorcycle (dynamic background + camera control operation)
2022-07-26 00:41:00 【A a a Feng】
Preface
Blogger Homepage : A Feng's homepage _CSDN
Programming tools :scratch Web version
Resources related to this procedure : Picture material and program source code
scratch It is a programming tool mainly for children , There are also many big friends like it , Because it does Simple and interesting , By building blocks , You can build some fun little programs . This record is a Parkour ( Low profile version ) Mode games , however , We manipulate characters by facing the camera !
List of articles
One . Program demonstration

The direction of the arrow in the upper right corner of the figure is the direction of the detected video motion , The number represents the range of motion ( The unit is the coordinate unit of the stage )
Two . Dynamic background production
We only use a simple way here , To simulate the effect of dynamic background .
First , We need one The connection between the beginning and the end is natural Background image of .
The principle of dynamic background simulation is to place two pictures connected end to end in the stage :
- One moves left from the center of the stage , Go to the far left of the stage
- One starts from the far right side of the stage , To the center of the stage
Once the picture moves to the specified position , Immediately return to the original position , Keep moving .

Implementation code : Because the stage cannot use sports building blocks , We implement the background image as a character 
Be careful : Why here x Used to judge coordinates Less than instead of be equal to ? Because the smallest unit of background motion is 10, Probably There is no equal situation appear .
3、 ... and . Video detection and motion control
| Building blocks | function |
|---|---|
![]() | Take the stage as the reference system , The distance the object moves in the video ( The unit is the stage coordinate unit ) |
![]() | Take the stage as the reference system , The direction of motion of the object in the video |
In order to make the game a little more difficult , We can limit it only in A certain range of motion direction and distance To make the roles in the program react .
Implementation code :
Four . obstacle —— Little stone
Simplicity , There is always only one small stone in our program , It is constantly from the stage Far right Moving to the stage Leftmost , Then return to the far right , You can simulate a kind of rock that constantly appears illusion .
Implementation code ( stone ):
In order to make the game better , We can also let the little motorcycle emit when it meets a stone The alarm goes off .
Implementation code ( Lead ):
how Fast and accurate Get the color of the character or background , I'm in another article Tips Mentioned in , You can click on the : The cat walks in a maze
Conclusion
🪐 Optimization assumption :
1) You can use the variable module , add Health value and fraction attribute
2) Optimize the jumping action of the character , Simulate the effect of projectile motion , More beautiful
🪐 our “ Get on a scooter ” The program will be finished here ! Some might wonder : EH , The arrow in the upper right corner hasn't said yet ? But arrows are not a major part of our program , Just to see the data collected by video detection more vividly .
🪐 If the article helps you , Remember Support Check out the blogger !
边栏推荐
- ShardingSphere数据分片
- LCA three postures (multiplication, tarjan+ joint search set, tree chain dissection)
- PC website realizes wechat code scanning login function (II)
- Practical exercise | find customers who buy more than n products within a given time range
- P4047 [jsoi2010] tribal Division
- Find the single dog (Li Kou 260)
- HCIP第十三天
- 【零基础玩转BLDC系列】基于反电动势过零检测法的无刷直流电机控制原理
- 【oops-framework】界面管理
- Hcip - republish
猜你喜欢

How to open the Internet and ask friends to play together?

Nodejs surface longitude

HNOI2012矿场搭建

Preparation of bovine erythrocyte superoxide dismutase sod/ folic acid coupled 2-ME albumin nanoparticles modified by bovine serum albumin

【计算一个字符串和另一个字符串相等的次数】

In order to grasp the redis data structure, I drew 40 pictures (full version)

DC-6--vulnhub靶场

Find the single dog (Li Kou 260)

Azure synapse analytics Performance Optimization Guide (1) -- optimize performance using ordered aggregate column storage indexes

8个小妙招调整数据库性能优化,yyds
随机推荐
Verilog grammar basics HDL bits training 05
【oops-framework】网络模块WebSocket
Leetcode notes 121. the best time to buy and sell stocks
Tarjan finds the strongly connected component o (n+m), shrinking point
[directory] nodejs, NPM, yarn, bug
Jmeter之用户自定义变量和抽离公共变量
JDBC实现MySQL8.0数据库的增删改查
LCA 三种姿势(倍增,Tarjan+并查集,树链剖分)
Research on the influence of opinion leaders based on network analysis and text mining
Getting started with D3D calculation shaders
Find the single dog (Li Kou 260)
Verilog grammar basics HDL bits training 06
SQL server failed to send mail, prompting that the recipient must be specified
找出单身狗(力扣260)
SQL time splicing problem, splicing recovery automatically truncated by the system
Nodejs learning resources
Redis Command Reference Manual - key
BGP 综合实验
2022/7/24 examination summary
8 tips to adjust database performance optimization, yyds

