This is a creation in Article, where the information may have evolved or changed.
Flappy source code can be seen in Https://github.com/golang/mobile. Specifically in Https://github.com/golang/mobile/tree/master/example/flappy
Processing of picture material
Flappy's picture footage uses a PNG image of 1408*128 pixels, such as:
This is actually a picture of 11 side-by 128*128 pixels of footage merging.
The footage of these textures is loaded into the corresponding Subtex, as shown in the code:
For example, avoid black bars, and take 1 pixels on each side.
Http://stackoverflow.com/questions/19611745/opengl-black-lines-in-between-tiles
The switch of Sprite picture
Specific to each sprite, when to display that footage, because of the time-related, is encapsulated in the frame function defined.
The argument of the frame function is t when D each graph shows how long, frames the list of graphs to be displayed in turn.
Drawing of picture size
When drawing, it is to draw the ground map of 128*128 pixels in the area of 16pt*16pt, (Gopher is plotted in the area of 32pt*32pt, the plot of the Underground is plotted in the area of 16pt*256pt)
The map of the underground is drawn so large that it is used for the maximum value, depending on the coordinate position, a part will be drawn outside the screen.
Audio The game is to draw 368*307 pixels in the 72pt*60pt area.
The full plot area for these games is 400*400 pixels (351.22pt*351.22pt, 1.1388888 pixels per PT), (when running on Mac)
Screen size default 400*400 pixels is the default configuration for Android and can be seen in the following address:
Http://developer.android.com/reference/android/R.attr.html#configChanges
In go, this default setting is also set in the configchanges of the Gomobile/binary_xml.go file, such as:
Note that the 400*400 unit above is PX;
The relationship between PT and PX
- Px:pixel, pixels, the smallest unit displayed on the screen
- Pt:point, is a standard unit of length, 1pt=1/72 inches
My Huawei Glory 6 Plus pe-tl10 screen size is 5.5 inches and 5.5 inches refers to the length of the diagonal of the phone screen, such as:
Supplementary data:
1 feet = 12 inches = 0.3048 meters
1 yards = 3 Feet = 0.9144 meters
1 miles = 1760 yards =1.6093 km area
1 square inches = 6.4516 square centimeters
1 square yards = 9 square feet = 0.8361 sqm
1 acres = 4840 square yards
1 "= 2.5400 cm, i.e. 5.5" = 13.97 cm (cm)
Ratio is traditional 16:9, display resolution is 1080*1920 pixels
Assuming that the screen is x, the screen width is 9x/16, according to the 16:9 ratio, and then the Pythagorean formula:
x+ (9X/16) =13.97
256x+81x=49961.19
337x=49961.19
x≈12.18
Width: 9x12.18÷16≈6.85
So, the 5.5-inch screen is roughly the size of a 12.18-centimetre-wide, 6.85-centimetre-long rectangle. Reference: http://g.93ku.com/article/30284.html
Glory 6plus is measured by the 1080*1776 px, the value of pt is 162.00pt*266.40pt ,
This value is not hidden from the virtual key bar test.
Note that this is written in PT instead of PX.
Func (img *image) Draw (sz size. Event, TopLeft, TopRight, Bottomleft Geom. Point, srcbounds image. Rectangle) {