Simplified texture and model loading; also use crosshair for DefaultPlayer
This commit is contained in:
parent
dafe16f191
commit
08762ddc9a
7 changed files with 55 additions and 54 deletions
|
@ -8,12 +8,17 @@ import qualified Data.Set as S
|
|||
import Data.Fixed
|
||||
import Data.Ratio ((%))
|
||||
import Data.Typeable
|
||||
import Graphics.Rendering.OpenGL.GL (GLfloat, Vector3(..))
|
||||
import Graphics.Rendering.OpenGL.GL.BeginEnd (unsafeRenderPrimitive, PrimitiveMode(..))
|
||||
import Graphics.Rendering.OpenGL.GL.CoordTrans (unsafePreservingMatrix, translate, rotate)
|
||||
import Graphics.Rendering.OpenGL.GL.VertexSpec
|
||||
|
||||
import Tank
|
||||
import GLDriver
|
||||
import Player
|
||||
|
||||
|
||||
|
||||
data DefaultPlayer = DefaultPlayer (S.Set Key) Float Float Bool
|
||||
deriving (Typeable, Show)
|
||||
|
||||
|
@ -34,3 +39,20 @@ instance Player DefaultPlayer where
|
|||
| Just (MouseMotionEvent x y) <- fromEvent ev = DefaultPlayer keys x y shoot
|
||||
| Just (MousePressEvent x y) <- fromEvent ev = DefaultPlayer keys x y True
|
||||
| otherwise = DefaultPlayer keys aimx aimy shoot
|
||||
|
||||
renderPlayer (DefaultPlayer _ aimx aimy _) = unsafePreservingMatrix $ do
|
||||
translate $ Vector3 aimx aimy (0.2 :: GLfloat)
|
||||
rotate 30 $ Vector3 1 0 (0 :: GLfloat)
|
||||
|
||||
unsafeRenderPrimitive Quads $ do
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (-0.2 :: GLfloat) (-0.2 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (0 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (-0.2 :: GLfloat) (0.2 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (1 :: GLfloat)
|
||||
vertex $ Vertex2 (0.2 :: GLfloat) (0.2 :: GLfloat)
|
||||
|
||||
texCoord $ TexCoord2 (1 :: GLfloat) (0 :: GLfloat)
|
||||
vertex $ Vertex2 (0.2 :: GLfloat) (-0.2 :: GLfloat)
|
||||
|
|
Reference in a new issue