Created a test obstacle to test collisions with.
[urggr.git] / src / urggr_package / test_obstacle.lua
blobacea8cb34357b27b193c8fef6856942e9cffd44c
1 --[[
2 Urggr - An horizontal scrolling shoot'em up.
3 Copyright 2008-2009 Antoine Chavasse <a.chavasse@gmail.com>
5 This file is part of Urggr.
7 Urggr is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3
9 as published by the Free Software Foundation.
11 Urggr is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 --]]
20 require 'fail.utils'
21 require 'fail.math'
22 sg = require 'fail.scenegraph'
23 col = require 'fail.bullet.collision'
25 TestObstacle = fail.utils.class
27 superclass = GameObject,
29 function( self, level )
30 GameObject.init( self )
32 self.frame = sg.Frame()
33 self.frame.LocalToParent.position.x = 0 -- = fail.math.Vector3f( 0, 3, 3 )
34 self.frame.LocalToParent.position.y = 3 -- = fail.math.Vector3f( 0, 3, 3 )
35 self.frame.LocalToParent.position.z = 3 -- = fail.math.Vector3f( 0, 3, 3 )
38 local mat = sg.Material()
39 mat.Emission.value = fail.math.Vector4f( 0, 0, 1, 1 )
40 mat.Specular.value = fail.math.Vector4f( 0, 0, 0, 1 )
41 self.renderable = sg.shapes.Cube( mat, self.frame )
43 level:addRenderable( self.renderable )
45 self.CollisionObject = col.Object()
46 self.CollisionObject.pShape = col.BoxShape( fail.math.Vector3f( 0.5, 0.5, 0.5 ) )
47 self.CollisionObject.pFrame = self.frame
48 level:addCollisionObject( self.CollisionObject )
50 self.sigcon = self.CollisionObject.Contact:connect( function( obj ) print "lol" end )
51 end