from vgengine import game
from vgengine.game import graphics, physics, control
import copy
import time
import math
import random
print physics._pymunk.moment_for_box(10, (10, 10))
scene = game.Scene(
	physics.Physics2D((1/60.)),
	graphics.Graphics2D((400, 400)),
	control.Control()
)

scene.physics.space.gravity = (0, -500)
scene.graphics.camera.size = (400, 400)
scene.graphics.camera.background_color = (0, 0, 255)

def quit(scene, event):
	print 'quiting scene'
	scene.game.quit()

scene.add_event_handler('quit', quit)

platform = game.GameObject(
	physics.StaticBody2D(),
	physics.BoxShape2D((400, 10)),
	graphics.RectSprite2D((400, 10)),
)

mass = 10
size = (20, 20)
boxes = [
	game.GameObject(
		physics.Body2D(mass, physics._pymunk.moment_for_box(mass, size)),
		physics.BoxShape2D(size),
		graphics.RectSprite2D(size),
	)
	for x in xrange(10)
]
platform.body.position = (0, -200)
for shape in platform.body.shapes:
	shape.friction = 1.0
# platform.body.angle = 2

for i, box in enumerate(boxes):
	box.body.position = (0, -190+i*20.1)
	for shape in box.body.shapes:
		shape.friction = 1.0
scene.room.add(platform)
scene.room.add(*boxes)
basic_game = game.Game(scene)

basic_game.run(60)