Merge pull request #87 from svera/parallax-scroll

Parallax scroll
This commit is contained in:
Michal Štrba 2018-01-12 12:59:03 +01:00 committed by GitHub
commit c1a222d84b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -40,13 +40,13 @@ func NewScrollingBackground(pic pixel.Picture, width, height, speed float64) *Sc
func (sb *ScrollingBackground) positionImages() { func (sb *ScrollingBackground) positionImages() {
if sb.speed > 0 { if sb.speed > 0 {
sb.positions = [2]pixel.Vec{ sb.positions = [2]pixel.Vec{
pixel.V(sb.width/2, (sb.height/2)+1), pixel.V(sb.width/2, sb.height/2),
pixel.V((sb.width/2)-sb.width, (sb.height/2)+1), pixel.V((sb.width/2)-sb.width, sb.height/2),
} }
} else { } else {
sb.positions = [2]pixel.Vec{ sb.positions = [2]pixel.Vec{
pixel.V(sb.width/2, (sb.height/2)+1), pixel.V(sb.width/2, sb.height/2),
pixel.V(sb.width+(sb.width/2), (sb.height/2)+1), pixel.V(sb.width+(sb.width/2), sb.height/2),
} }
} }
} }