Created
September 18, 2013 00:23
-
-
Save alexdantas/6602729 to your computer and use it in GitHub Desktop.
RubySDL test.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Awesome test on 'rubysdl' gem | |
# Complete reference: | |
# | |
# http://www.kmc.gr.jp/~ohai/rubysdl_ref_2.en.html | |
require 'sdl' | |
begin | |
SDL.init(SDL::INIT_EVERYTHING) | |
screen = SDL::Screen.open(200, 200, 0, SDL::HWSURFACE) | |
SDL::WM.set_caption("Maximized window", "Minimized window") | |
puts "RubySDL version #{SDL::VERSION}" | |
color = screen.format.map_rgb(255, 20, 255) | |
screen.fill_rect(3, 3, 10, 20, color) | |
color = screen.format.map_rgb(10, 20, 10) | |
screen.fill_rect(150, 140, 10, 10, color) | |
screen.update_rect(0, 0, 0, 0) | |
terminated = false | |
while not terminated | |
while event = SDL::Event2.poll | |
case event | |
when SDL::Event2::Quit | |
terminated = true | |
when SDL::Event2::KeyDown | |
puts "haha" | |
end | |
end | |
sleep 0.05 | |
end | |
SDL.quit # Method automatically called when Ruby ends | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment