The beginning of this year to learn Android, but do modify the source, their own in the bedroom to learn the next to do the app, because it is just beginning to learn, this game only focus on the implementation of the game, the realization of the general function, but also did not realize the details of the game, such as the display of fractional pictures, there is no attention to the Leave it to the people to perfect the changes ~ ~ ~
Code: download.csdn.net/detail/a624731186/7594383
If it is perfect, I'll send an email when I'm free, [email protected]
The following are the official game effects:
Here is the effect of my game: the resource picture is downloaded on the Internet, a little different
The code mainly uses the Surfaceview control to refresh the picture
There are 5 main parts, refresh the background, refresh the grass below, refresh the pillars, refresh the birds, calculate the score
1: Refresh Background
Refresh the background image every 50 milliseconds, note that the background is full screen, and the purpose of refreshing the background is to mask the remaining dynamic effects of other pictures.
2: Refresh the Pillars
Pillars are only up and down 2 pictures, but on the screen looks different, seems to have a lot of, the realization is to produce a random number each time to determine the length of the next column display, the middle of the interval fixed to 3 birds height
3: Refreshing grass
The grass looks like a moving effect, which is actually a picture that is reset to the x, Y coordinates on the screen every 50 milliseconds, so there's a moving effect
4: Refreshing the birds
The bird has 3 pairs of pictures, respectively, on the wings, in the next, turns to show on it.
5: Calculate Score
When the birds hit the pillars and the ground, the birds to determine the death, mainly to calculate the pictures of birds and pillars of pictures and or grass pictures, there is no intersection, if there is intersection, think of death, the game is over
The score is calculated when the bird leaves the pillar 5 pixels, it is considered this passage, the score plus a
5 steps above, corresponding to the following 5 functions
public void Mydraw () {
try {
Mcanvas = Msfh.lockcanvas ();
if (Mcanvas! = null) {
Mcanvas.drawcolor (Color.White);
Drawbackground ();
Drawpillar ();
DRAWMOVEBG ();
Drawbird ();
Calcuscore ();
}
} catch (Exception e) {
Todo:handle exception
} finally {
if (Mcanvas! = null)
Msfh.unlockcanvasandpost (Mcanvas);
}
}
Probably said under the realization of ideas, hope don't mislead new!!!