Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FIxing code samples, adding another image

  • Loading branch information...
commit 79cd3b57908922386a87404c6038d0bc42de42ae 1 parent 34d57ea
@deadprogram deadprogram authored
View
BIN  gosu/asteroid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  public/help/shared/ruby4kids/code4_1.rb
@@ -1,4 +1,5 @@
def move_left
if @x < 0
@x = 0
-
+ end
+end
View
2  public/help/shared/ruby4kids/code4_3.rb
@@ -1,5 +1,4 @@
require 'gosu'
-require 'player'
class MyGame < Gosu::Window
def initialize
@@ -10,6 +9,7 @@ def initialize
def update
if button_down? Gosu::Button::KbLeft
@player1.move_left
+ end
end
def draw
View
1  public/help/shared/ruby4kids/code5_2.rb
@@ -5,4 +5,3 @@ def move_right
@x = @x + 10
end
end
-
View
2  public/help/shared/ruby4kids/code5_3.rb
@@ -1,3 +1,3 @@
if @x > (@game_window.width - 75)
@x = @game_window.width - 75
-
+end
View
2  public/help/shared/ruby4kids/code5_4.rb
@@ -1,3 +1,3 @@
if button_down? Gosu::Button::KbUp
@player1.move_up
-
+end
View
1  public/help/shared/ruby4kids/code5_5.rb
@@ -5,4 +5,3 @@ def move_up
@y = @y - 10
end
end
-
View
1  public/help/shared/ruby4kids/code5_6.rb
@@ -1,4 +1,3 @@
if button_down? Gosu::Button::KbDown
@player1.move_down
end
-
View
1  public/help/shared/ruby4kids/code5_7.rb
@@ -5,4 +5,3 @@ def move_down
@y = @y + 10
end
end
-
View
5 public/help/shared/ruby4kids/code5_8.rb
@@ -1,5 +1,4 @@
require 'gosu'
-require 'player'
class MyGame < Gosu::Window
def initialize
@@ -51,10 +50,10 @@ def move_left
end
def move_right
- if @x > @game_window.width - 100)
+ if @x > (@game_window.width - 100)
@x = @game_window.width - 100
else
- @x = x + 10
+ @x = @x + 10
end
end
View
2  public/help/shared/ruby4kids/code6_3.rb
@@ -1 +1 @@
-@y = @y -1
+@y = @y - 1
View
2  public/help/shared/ruby4kids/code6_6.rb
@@ -1,5 +1,5 @@
if @player1.hit_by? @ball
stop_the_game
end
-if Gosu::distance(@x, @y, star.x, star.y) &lt; 35
+ if Gosu::distance(@x, @y, star.x, star.y) < 35
end
View
17 public/help/shared/ruby4kids/code6_7.rb
@@ -1,6 +1,4 @@
require 'gosu'
-require 'player'
-require 'ball'
class MyGame < Gosu::Window
def initialize
@@ -31,6 +29,7 @@ def update
def draw
@player1.draw
+ @ball.draw
end
end
@@ -43,7 +42,7 @@ def initialize(game_window)
end
def draw
- @icon.draw(@x,@y,1)
+ @icon.draw(@x, @y, 1)
end
def move_left
@@ -55,10 +54,10 @@ def move_left
end
def move_right
- if @x > @game_window.width - 100)
+ if @x > (@game_window.width - 100)
@x = @game_window.width - 100
else
- @x = x + 10
+ @x = @x + 10
end
end
@@ -82,7 +81,7 @@ def move_down
class Ball
def initialize(game_window)
@game_window = game_window
- @icon = Gosu::Image.new(@game_window, "Images/ball.png", true)
+ @icon = Gosu::Image.new(@game_window, "gosu/asteroid.png", true)
@x = rand(@game_window.width)
@y = 0
end
@@ -92,13 +91,9 @@ def update
end
def draw
- @icon.draw(@x,@y,2)
+ @icon.draw(@x, @y, 2)
end
-
end
window = MyGame.new
window.show
-
-
-
Please sign in to comment.
Something went wrong with that request. Please try again.