Skip to content

Instantly share code, notes, and snippets.

@Mouq
Created March 23, 2014 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mouq/a12b912ecbd7999bd5c4 to your computer and use it in GitHub Desktop.
Save Mouq/a12b912ecbd7999bd5c4 to your computer and use it in GitHub Desktop.
diff --git a/ThroughTheWindow b/ThroughTheWindow
index 8161553..7180fc3 100755
--- a/ThroughTheWindow
+++ b/ThroughTheWindow
@@ -64,15 +64,22 @@ class Game is Steroids::Game {
$!last-cloud = $!distance;
}
- if self.is_pressed("Space") and $!runner.y == GROUNDLEVEL - $!runner.h {
- $!runner.velocity[1] = -22;
- unless $!jumped {
- $!jumped = True;
- my $b = self.add_sprite('banner2', self.width, GROUNDLEVEL);
- $b.y += $b.h;
- $b.velocity[0] = -5;
+ state $in-jump = False;
+ if self.is_pressed("Space") {
+ if $!runner.y == GROUNDLEVEL - $!runner.h or $in-jump {
+ $in-jump = True;
+ $!runner.velocity[1] = -22;
+ unless $!jumped {
+ $!jumped = True;
+ my $b = self.add_sprite('banner2', self.width, GROUNDLEVEL);
+ $b.y += $b.h;
+ $b.velocity[0] = -5;
+ }
}
+ } else {
+ $in-jump = False;
}
+
$!distance++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment