Merge pull request #86 from svera/update-image

Update image
This commit is contained in:
Michal Štrba 2018-01-12 12:57:11 +01:00 committed by GitHub
commit 0183f7fbbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -3,3 +3,5 @@
Created by [Sergio Vera](https://github.com/svera)
This example shows how to implement an infinite side scrolling background.
Credits to [Peter Hellberg](https://github.com/peterhellberg) for the improved background image.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -5,7 +5,7 @@ import (
"os"
"time"
_ "image/jpeg"
_ "image/png"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
@ -43,7 +43,7 @@ func run() {
}
// Pic must have double the width of the window, as it will scroll to the left
pic, err := loadPicture("gamebackground.jpg")
pic, err := loadPicture("gamebackground.png")
if err != nil {
panic(err)
}
@ -54,8 +54,8 @@ func run() {
// In the beginning, vector1 will put background1 filling the whole window, while vector2 will
// put background2 just at the right side of the window, out of view
vector1 := pixel.V(windowWidth/2, (windowHeight/2)+1)
vector2 := pixel.V(windowWidth+(windowWidth/2), (windowHeight/2)+1)
vector1 := pixel.V(windowWidth/2, windowHeight/2)
vector2 := pixel.V(windowWidth+(windowWidth/2), windowHeight/2)
i := float64(0)
last := time.Now()