Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
require 'rubygame' include Rubygame class Object include Sprites::Sprite def initialize(coords, screenWidth) super() @image = Surface::load_image('object.png') @rect = @image.make_rect() @coords = coords @screenWidth = screenWidth @rectCenter = @rect.center=(coords) update def update @rect.centerx += 5 if @rect.centerx > 640 @rect.centerx = 0 end #initialize end #Object def main() queue = EventQueue.new screen = Screen.new([640, 480]) screen.title = "Rubygame Window" background = Surface.new(screen.size) background.fill([225, 225, 225]) screenSizeWidth = screen.width() coordsArray = [64, 64] square = Object.new(coordsArray, screenSizeWidth) spriteGroup = Sprites::Group.new() spriteGroup.extend(Sprites::UpdateGroup) spriteGroup.push(square) loop do Clock.delay(12) background.blit(screen, [0, 0]) spriteGroup.undraw(screen, background) spriteGroup.update() spriteGroup.draw(screen) screen.update() queue.each do |event| case event when QuitEvent return end #case end #do end #loop do end #main main()
From the Design Piracy series on my blog: