For details of the project, please click
First, download the latest version and double-click the jar package to run, or
java -jar crazyalpha.jar
the code was built on openjdk8, notice that there is no javafx support in jdk11, so if you want to run or build the code, please use jdk8!
Game.Engine：Self-implemented game engine package
Annotation：engine annotation package with engine-defined annotations
GameEventHandler：Event Processor Annotations
GameManager：Annotations on various managers in the game
GameObject： Game Object Annotations
GameView：View annotations for implementing MVVM layered design
Base：Basic class package, contains various abstract base classes defined by the engine
ImageModel：Basic graphic model
ShapeModel：Basic shape model
TextModel：Basic text model
Enum：definition of various enumerations (omitted)
Utils：Other tools (omitted)
GameObject：Game object base class, all objects are derived from this class
GameView：Other interfaces besides the main game interface are derived from the view base class
Game.EventHandler：Contains all event handlers
Game.Manager：Contains various managers, maps, resources, data, models, events, etc.
Game.Object：contains definitions of all game objects
Model：contains definitions of all game models
GameMap：Game Map Object
Generator：Game Event Generator
Game.View：view package, which contains definitions for all views
Game：Global game object, created using singleton mode
Main：Game main class
Render：Core renderer, responsible for rendering the game
In order to develop this game, I first developed a game engine based on JavaFX. The engine implements a series of functions from game resource management, model definition, to screen rendering, and is designed according to the design ideas of existing commercial game engines on the market. "The sparrow is small and complete," although it can't match other mature game engines, it is fully functional and can meet the development needs of most 2D games.
The top left is the logo of the game, the bottom left corner shows the highest score, and the following is the author information and version. In the lower right corner are two buttons, one to launch the game button and the other to exit the button.
The top left corner is the player's avatar, the current score, and the health value; directly above is the current level; the center of the picture is the big windmill, the big windmill emits letters following the music rhythm, the player needs to press the corresponding letter before the letters fly out of the screen to score.
The bottom left shows the game scores and whether to break the highest score. The return to the main interface button is displayed in the lower right corner.
This is my first time using Java to do game development. Previously, the understanding of Java language was limited to JavaEE. I recently learned about JavaFX. After using it for a while, I found out that JavaFX is so easy to use. GUI design framework, just use less people, I encountered a lot of problems in the development process, basically can not find domestic information, but also have a versatile StackOverFlow, in addition, Oracle official website documentation is quite detailed, thanks ~
For people like me who write a dynamic language like Python, the feeling of writing a lot of Java code is very cumbersome, but it is very worry-free, no need to brainstorm, no need to entangle the type of this parameter, you do not need to force Type checking, everything is clearly arranged by the IDE and JVM, I don't need to worry about the type of problem, and because the Java syntax is relatively rigid, there is not so much flexible writing, which is both a disadvantage and an advantage. The disadvantage is that for me. For those who like to show off their skills, writing Java code doesn't have much pleasure, but the advantage is the same function. The code that is implemented is basically the same. Different people will not have much difference in implementation. This ensures the code. Maintenance, you may now write a big project in Python, the code is all elegant, eclectic, very cool when writing, but when you refactor after the completion, you can't read the previous code, even though there are comments, but not every line of code has a comment, flexible writing increases the difficulty of understanding, so Java is absolutely dominant in large projects. The position is not a hole in the wind.
This game development has also deepened my understanding of the Java language, such as reflections, such as events. When I started doing event processing, I was a bit confused. Java is neither trusted nor really The concept of "event", everything is implemented with interfaces and classes. The implementation of interface functions is generally passed to the anonymous class that implements an event interface (of course, lambda expressions can be used in Java8), but this is not what it is. Big problems, these problems have other methods to solve, but it is more complicated to write. Maybe I used to write to C# before, so when I write Java code, I can't help but compare it, but in fact, the contrast between these two languages is not high, because the age of birth is different, C# is indeed better than language design. Java is much more sophisticated. In recent years, new versions of Java have been or are not mimicking the features of C# many years ago, such as Java8 lambda expressions, Java11 var definition variables, and so on.
In addition, this development of the small game makes me realize that the syntax is very simple, not as complicated and complicated as C# and C++, so it is especially friendly for beginners, because one will match the best IDE. : IDEA, it is easy to write a variety of projects, there is a saying that because the Java language itself has too few functions, so there are various design patterns to complement the Java language.