<> preface

Really convinced , Two times in a row, the page suddenly collapses , Cause to override , I am so depressed

Back to the point , This time I use processing Realize a small game of police car chase , This little game is inspired by a popular wechat game on the Internet ——COPCHASE, I believe a lot of friends have played . Its game effect is like this :
Are you familiar with the pictures ? Now I'll introduce a brief version of my implementation of this game .

<> Effect display

Prior instructions ! Because everything in my picture is used by myself processing Painted , So it's going to look a lot worse !
however , I don't think the game is much less playful .

<> How to play the game

The game uses the mouse to control the direction of the blue and yellow car , The police car will chase the car controlled by the player . Players have three lives , Every police car has two lives . Players need to control the blue and yellow cars to rotate at the right time , So that the police cars are also following the blue and yellow cars to collide with each other , Finally get rid of the chase of police cars .

<> Introduction to game implementation

first , The mouse and the blue and yellow car are connected by vectors , We define the maximum velocity and the maximum angular velocity for this vector . Make the blue and yellow car under the control of the mouse .
after , Establish the same relationship between the police car and the blue and yellow car as between the mouse and the blue and yellow car . Make the police car chase the blue and yellow car .
then , Particle effects are added to the rear of each car , To be more realistic , And it can reflect the sense of urgency between vehicle chases . Enhance gameplay .
last , Most of the rest of the code is about gameplay , Game balance adjustment code .

<> Key code display

Due to a small amount of code , It's not convenient to put it all in the blog , I'll take some of the codes for a brief introduction .

1. part ui function
void endui()// End screen void my_background()// Game background void ui(int a,int b)// Interface score and life display
2. Players and enemies
class Vehicle class Enemy
The main application here is 《 Code color 》 In this chapter, we will build two types of players and enemies .
There are attributes in the class , Corresponding property parameters , And how to realize the game mechanism
3. particle system
class ParticleSystem
Particle system reference here 《 Code color 》 Particle system Chapter , Combine the position attributes of players and enemies , Paint exhaust particle effect .
4. Death determination and call of main function
void draw()
<> reference material

[1]《 Code color 》
[2]COPCHASE Game Ontology

©2019-2020 Toolsou All rights reserved,
JAVA Detailed explanation of anomalies MySQL An interview is a must ! How to use it quickly html and css Write static page R Language cluster analysis case Dialogue between apple and Nissan suspended ,Apple Car How's it going ?java Realize the function of grabbing red packets SpringBoot practice ( five ):mybatis-plus In BaseMapper,Iservice and ServiceImpl Google says home office affects work efficiency !2021 Return to offline office in 2010 about keras use fit_generator Encountered in StopIteration Programmer Tanabata Valentine's Day confession code