Skip to content

Commit

Permalink
collision on side borders
Browse files Browse the repository at this point in the history
  • Loading branch information
regb committed Sep 10, 2016
1 parent 2983603 commit 41d70b1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/scalavator/core/src/main/scala/MainScreen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ trait MainScreenComponent {
if(characterPosition.y.toInt < WindowHeight/2)
scrollUp(WindowHeight/2 - characterPosition.y.toInt)
}
case Some(platform) =>
case Some(platform) => {
characterPosition = characterPosition + Vec(1,0)*platform.speed*(dt/1000d)
if(characterPosition.x < 0)
characterPosition = characterPosition.copy(x = 0)
if(characterPosition.x + CharacterWidth > WindowWidth)
characterPosition = characterPosition.copy(x = WindowWidth-CharacterWidth)
}
}
val newCharacterFeet = characterPosition.y
if(newCharacterFeet > originalCharacterFeet) { //if falling
Expand Down

0 comments on commit 41d70b1

Please sign in to comment.