Write in front
The program is written five or six years ago when reading, there will be some irregular, I have put the code on GitHub, there is time to optimize the changes.
Program operating mechanism
Defines a jpanel, and then redraws it once every other short period of time.
The redraw content is as follows:
- Map information;
- Enemy tanks;
- our tanks;
- The right game basic information;
- The bomb exploded.
involves some logic:
- overlapping judgment;
- When does the tank change direction;
- When does the tank shoot;
- The handling of tanks after being shot;
- Bricks, iron blocks, rivers are shot, collision logic;
- 。。。 Wait a minute
How to execute a program
Download Source:
- Execute the MAVEN command clean package to generate jar packages in the target directory and execute the jar package directly;
- or import the source code directly with Eclipse, find the Startgame class, right-click Run as Java application. If you find that the main class cannot be found or cannot be loaded, clean up the project.
Program run
Program source Code
Https://github.com/peterchenhdu/tankbattle
Share the Java-written tank war game, I believe many people played in childhood