2010-11-23 13:59:28 +08:00
|
|
|
require 'sfml/system'
|
|
|
|
require 'sfml/window'
|
|
|
|
require 'sfml/graphics'
|
|
|
|
|
2010-11-23 23:00:23 +08:00
|
|
|
app = SFML::RenderWindow.new
|
|
|
|
app.create( [800, 600], "My Ruby SFML" )
|
2010-11-23 13:59:28 +08:00
|
|
|
app.framerate = 100
|
|
|
|
app.position = [300, 300]
|
|
|
|
input = app.input
|
|
|
|
|
|
|
|
shape = SFML::Shape.rectangle( [-10, -10, 20, 20], SFML::Color::White )
|
|
|
|
|
|
|
|
while app.open?
|
|
|
|
while event = app.get_event
|
|
|
|
if event.type == SFML::Event::Closed
|
|
|
|
app.close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
app.clear
|
|
|
|
shape.position = [input.mouseX, input.mouseY]
|
2010-11-23 23:00:23 +08:00
|
|
|
app.draw shape
|
2010-11-23 13:59:28 +08:00
|
|
|
app.display
|
|
|
|
end
|