File: event2.rb

package info (click to toggle)
libsdl-ruby 0.9.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 612 kB
  • ctags: 543
  • sloc: ansic: 4,055; ruby: 1,694; makefile: 42
file content (32 lines) | stat: -rw-r--r-- 673 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'sdl'

SDL.init( SDL::INIT_VIDEO )
screen = SDL::setVideoMode(640,480,16,SDL::SWSURFACE)
SDL::WM::setCaption $0,$0

loop do
  if event=SDL::Event2.poll then
    case event
    when SDL::Event2::Active
      print "Active ", (event.gain)?"gain":"lost","\n"
    when SDL::Event2::KeyDown
      print "KeyDown sym:#{event.sym} mod:#{event.mod}","\n"
      if event.sym==SDL::Key::A then
	e=SDL::Event2::KeyDown.new
	e.sym=3333
	e.mod=3333
	e.press=true
        e.unicode=200
	SDL::Event2.push(e)
      end
    when SDL::Event2::KeyUp
      print "KeyUp sym:#{event.sym} mod:#{event.mod}","\n"
      
    when SDL::Event2::Quit
      exit
      
    end
  end
end