/quadtreetest.py
#!/usr/bin/python

import Richter.Engine as Engine
from Richter.util import QuadTreeR
import pygame
from pygame.locals import *
from random import randint

r = QuadTreeR((0, 0, 640, 480))
for i in xrange(0, 20):
	x = randint(0, 640)
	y = randint(0, 480)
	w = randint(0, 640 - x)
	h = randint(0, 480 - y)
	r.add((x,y,w,h), None)

mouse = pygame.Rect(0, 0, 100, 100)

Engine.init((640, 480))

def input(e):
	if e.type == MOUSEMOTION:
		mouse.center = (e.pos[0], 480 - e.pos[1])
	if e.type == KEYDOWN:
		if e.key == K_LEFT:
			mouse.centerx -= 1
		elif e.key == K_RIGHT:
			mouse.centerx += 1
		elif e.key == K_UP:
			mouse.centery += 1
		elif e.key == K_DOWN:
			mouse.centery -= 1
		elif e.key == K_ESCAPE:
			Engine.stop()

Engine.eventhandlers.append(input)

def draw():
	r.draw(mouse)

Engine.drawers.append(draw)

Engine.run()