mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
example/airship: Add comments
This commit is contained in:
parent
a0ad4710f7
commit
3ee42c0c1e
@ -56,6 +56,7 @@ func init() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
groundImage, _ = ebiten.NewImage(groundWidth, screenHeight*2/3+50, ebiten.FilterNearest)
|
groundImage, _ = ebiten.NewImage(groundWidth, screenHeight*2/3+50, ebiten.FilterNearest)
|
||||||
|
|
||||||
const repeat = 5
|
const repeat = 5
|
||||||
w, h := gophersImage.Size()
|
w, h := gophersImage.Size()
|
||||||
repeatedGophersImage, _ = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
|
repeatedGophersImage, _ = ebiten.NewImage(w*repeat, h*repeat, ebiten.FilterNearest)
|
||||||
@ -159,6 +160,7 @@ func (p *player) Angle() int {
|
|||||||
|
|
||||||
func updateGroundImage(ground *ebiten.Image) {
|
func updateGroundImage(ground *ebiten.Image) {
|
||||||
ground.Clear()
|
ground.Clear()
|
||||||
|
|
||||||
x16, y16 := thePlayer.Position()
|
x16, y16 := thePlayer.Position()
|
||||||
a := thePlayer.Angle()
|
a := thePlayer.Angle()
|
||||||
gw, gh := ground.Size()
|
gw, gh := ground.Size()
|
||||||
@ -171,7 +173,23 @@ func updateGroundImage(ground *ebiten.Image) {
|
|||||||
ground.DrawImage(repeatedGophersImage, op)
|
ground.DrawImage(repeatedGophersImage, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scaleForLine calculates the scale to render at y-th line of the ground image.
|
||||||
func scaleForLine(y int) float64 {
|
func scaleForLine(y int) float64 {
|
||||||
|
// c |
|
||||||
|
// |\ |
|
||||||
|
// | \|
|
||||||
|
// | s
|
||||||
|
// | |\
|
||||||
|
// | | \
|
||||||
|
// A--B--C (plane)
|
||||||
|
//
|
||||||
|
// c: camera
|
||||||
|
// s: intersection of the ray and the screen
|
||||||
|
// B-s: horizon height
|
||||||
|
// A-C: far point on the plane
|
||||||
|
// A-B: the distance from the camera to the screen
|
||||||
|
//
|
||||||
|
// The ground image is on the plane, and the head of the ground image is on 'C'.
|
||||||
const (
|
const (
|
||||||
horizonHeight = screenHeight * 2.0 / 3.0
|
horizonHeight = screenHeight * 2.0 / 3.0
|
||||||
cameraHeight = horizonHeight + 200.0
|
cameraHeight = horizonHeight + 200.0
|
||||||
|
Loading…
Reference in New Issue
Block a user