require '../src/ClanRuby'
include ClanRuby

class ClanRubyMouse

	def onMouseMove(x, y)
		puts x, y
	end
end
#
# This sample script show the use of input handlers..
#

#
# Initialize the core and display libs.
#
SetupCore.init()
SetupDisplay.init()

#
# Create an 640 X 480 window, 16 bits of color.
#
Display.setVideoMode( 640, 480, 16, false )

#
# Now create an event handler object and use it.
#

x=0
y=0

p=Proc.new{ | ascii, id, mouseX, mouseY |
	x=mouseX
	y=mouseY
}

Input.buttonHandler=p

#
# Just draw a block where the mouse last was.
#

count=0

while ( ! KeyBoard.getKeycode( CL_KEY_ESCAPE) )


	Display.fillRect( 0, 0, 640, 480, 1, 1, 1, 1)
	Display.fillRect( x-20, y-20, x+20, y+20, 1, 0, 0, 1)
	#
	# Make it all visible.
	#
	Display.flipDisplay()
	System.keepAlive(20)

	count = count + 1

	puts count

	if ( count == 150 )
		puts 'nil'
		Input.buttonHandler=nil

	elsif (count == 300 )
		puts p
		Input.buttonHandler=p

	end
		
end

#
# Clean up
#
SetupDisplay.deinit()
SetupCore.deinit()




