ok! im on the 2nd lesson...finally X-D
k back to topic i get this mesage:
my_game.rb:34:in 'update': undefined method 'update' for #<Ball:
0x283aa78) (NoMethodError)
from my_game.rb:54:in 'show'
from my_game.rb:54:in '<main>'
i know it has something to do with my update method maybe because
there is no else in the if statement? anyways heres my code:
my_game.rb:
$: << File.expand_path(File.dirname(__FILE__))
require 'rubygems'
require 'gosu'
require 'player'
require 'ball'
class MyGame < Gosu::Window
def initialize
super(300, 300, false)
@player = Player.new(self)
@ball = Ball.new(self)
@running = true
end
def update
if @running
if button_down? Gosu::Button::KbLeft
@player.move_left
end
if button_down? Gosu::Button::KbRight
@player.move_right
end
if button_down? Gosu::Button::KbUp
@player.move_up
end
if button_down? Gosu::Button::KbDown
@player.move_down
end
@ball.update
if @player.hit_by? @ball
stop_game!
end
end
end
def draw
@player.draw
@ball.draw
end
def stop_game!
@running = false
end
end
window = MyGame.new
window.show
player.rb:
class Player
def initialize(game_window)
@game_window = game_window
@icon = Gosu::Image.new(@game_window, "images/player1.png",
true)
@x = 50
@y = 150
def hit_by?(ball)
Gosu::distance(@x,@y,ball.x,ball.y) <50
end
end
ball.rb:
class Ball
def initialize(game_window)
@game_window = game_window
@icon = Gosu::Image.new(@game_window, "images/ball.png", true)
@x = rand(@game_window.width)
@y = 0
end
def updtae
if @y >@game_window.height
@y = 0
@x = rand(@game_window.width)
else
@y = @y + 10
end
end
def draw
@icon.draw(@x,@y,2)
end
def x
@x
end
def y
@x
end
end
soooo thats all the code that i have and thank you all the ppl out
there for helping me out :-)