Hello,
I´m working on a rect wie Ruby/Shoes, the rect should move right, left,
top and down. The methods should be in the Class Quadrat. This is what I
got so far, but I don´t know how to move on. I´m working on it since
hours, but nothing changes.
This is the methode I should involve also, but I don´t know where and
how:
Shoes.app do
@info = para “NO KEY is PRESSED.”
keypress do |k|
@info.replace “#{k.inspect} was PRESSED.”
end
end
And this is my code so far:
class Quadrat < Shoes::Widget
@x
@y
@a
@colour
@objekt
def initialize(x,y,a,colour)
@x=x
@y=y
@a =a
@colour=colour
@objekt=rect(x,y,a,a) #gibt Größe und Standpunkt des Quadrates an
end
def top ()
@y=@y-10 #verschiebt das Quadrat um 10 auf der Y-Achse nach oben
@objekt.move(@x,@y)
end
def down()
@y=@y+10 # verschiebt das Quadrat um 10 auf der y-Achse nach unten
@object.move(@x,@y)
end
def left()
@x=@x-10 # verschiebt das Quadrat um 10 auf der x-Achse nach links
@object.move(@x,@y)
end
def right()
@x=@x+10 #verschiebt das Quadrat um 10 auf der y-Achse nach rechts
@object.move(@x,@y)
end
end
Shoes.app width: 200, height: 200 do
Shoes.show_log
background black
a=Quadrat.new(100,150,30,green)
end