"Original" Pure oo: Write a flappybird from design to coding (i)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.