
# Invivo AI challenge simulation environment
# Copyright 2009 Simon Funk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""Pseudo Game just for testing...
"""

import Model as m
import math

class Game(object):

	def __init__(self):

		worldBounds = ((-10., 0.),(10., 10.))

		testBox1  = m.Body((0.0, 5.), 1., m.Box(((-1.0, -0.5),(1.0, 0.5))))
		testBox2  = m.Body((0.1, 1.), 0., m.Box(((-0.1, -0.1),(0.1, 0.1))))
		testBox3  = m.Body((0.0, 6.), -1., m.Box(((-1.0, -0.5),(1.0, 0.5)), color=(255, 0, 0)))
		testThing = m.Body((3.0, 5.), 0., [
			m.Circle((0., 0.), .5, color=(0, 255, 255)),
			#m.Box(((-1.0, -0.5),(1.0, 0.5)), color=(  0, 255, 255)),
			m.Box((( 0.1, -0.6),(0.2, 0.1)), color=(255,   0,   0))
			])

		pivot1 = m.Pivot(testBox1, testBox3, (0., 5.5), torque=15.)

		bodies = [testBox1, testBox2, testBox3, testThing]
		joints = [pivot1]

		self.p1 = pivot1

		self.world = m.World(worldBounds, bodies, joints)

		self.world.watch(self.update)

	def update(self, model):

		self.p1.torque = math.sin(model.time) * 30.

