Speaking, self-study computer also has more than 2 years of time, I have not from design to coding, finished a full design of an object-oriented software experience. 囧
So, there is this series. The first choice of language is Java, no other reason, headfirst design mode is written in Java, and Java package management is relatively simple, suitable for small projects. followed by the theme of nature is the game, the recent wikioi in the results of the time there is a flappybird of the small game, when thinking if the birds into the wall of the father of teachers, may not have some fun:)
From the drawing class diagram to the completion of the various modules, it took a total of 2 days, after the completion of the discovery decoupling is OK, share with you.
The first part is the class diagram:
There are 5 main classes.
Game class: Overview Global, invoke other classes of work.
Bing class: (Fang teacher version of the bird, Nature called Bing) is actually an interface, responsible for playing the role of birds, usually automatically down, press a bit up to fly.
Obstacle class: interface. Flappybird in the middle of the obstacle, and then die
Drawboard class: interface. Be responsible for drawing Bing and obstacle to the interface.
Judge class: interface. Be responsible for judging whether the score, or whether the small foreshore death problem. Does "bin" look like a nasal post? Wipe
To define an action:
1, mouse click: Because the end is on the Drawboard click, so, Drawboard implementation needs to integrate JPanel class. The game class is going to listen to the mouse pressed event of the Drawboard implementation class (clicked requires the original location to be put in place, sometimes not responding because of a user misoperation, not suitable as an action response event), and sends it to the Bing implementation to make it rise.
Well, the first part is over, and the next article will implement each part of the game separately.
"Original" Pure oo: Write a flappybird from design to coding (i)