How "accurate" are the screencasts?

22 views
Skip to first unread message

Trent

unread,
Jul 31, 2012, 5:17:31 PM7/31/12
to ruby...@googlegroups.com
I've done everything exactly as shown in the screencasts and get this error.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': ./player.rb:28: syntax error, unexpected $end, expecting kEND (SyntaxError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from my_game.rb:3


MY_GAME.RB file
require 'rubygems'
require 'gosu'
require 'player'

class MyGame < Gosu::Window
def initialize
super(300, 400, false)
@player1 = Player.new(self)
end

def update
if button_down? Gosu::Button::KbLeft
@player1.move_left
end

if button_down? Gosu::Button::KbRight
@player1.move_right
end

end

def draw
@player1.draw
end

end

window = MyGame.new
window.show

PLAYER.RB file
class Player
def initialize(game_window)
@game_window = game_window
@icon = Gosu::Image.new(@game_window, "images/player1_icon.png", true)
@x = 50
@y = 50
end

def draw
@icon.draw(@x,@y,1)
end

def move_left
if @x < 0
@x = 0
else
@x = @x - 10
end
end

def move_right
if @x > (@game_window.width - 50)
@x = @game_window.width - 50
else
@x = @x + 10

end


Lovell McIlwain

unread,
Jul 31, 2012, 5:21:05 PM7/31/12
to ruby...@googlegroups.com
Trent,

If I am reading your code right, it looks like your missing 2 "ENDS" in your player class. See my insertion below and see if that helps with your issue.

Thanks,
END MISSING HERE FOR YOUR IF STATEMENT
END MISSING HERE FOR YOUR MOVE RIGHT STATEMENT
> end
>
>

Trent

unread,
Jul 31, 2012, 6:51:14 PM7/31/12
to ruby...@googlegroups.com
Thank you!
Reply all
Reply to author
Forward
0 new messages