Re-corrected coordinates... and new tank texture

This commit is contained in:
Matthias Schiffer 2010-03-08 20:16:51 +01:00
parent d8cf601ac2
commit 996313bd89
3 changed files with 8 additions and 4 deletions

5
GLX.hs
View file

@ -157,9 +157,12 @@ handleEvent glx xevent = do
wa <- getWindowAttributes (glxDisplay glx) (glxWindow glx) wa <- getWindowAttributes (glxDisplay glx) (glxWindow glx)
let x = fromIntegral . ev_x $ event let x = fromIntegral . ev_x $ event
y = fromIntegral . ev_y $ event y = fromIntegral . ev_y $ event
w = fromIntegral . wa_width $ wa
h = fromIntegral . wa_height $ wa h = fromIntegral . wa_height $ wa
s = fromRational . glxScale $ glx s = fromRational . glxScale $ glx
return (glx, Just $ SomeEvent $ MouseMotionEvent (x/s) ((h-y)/s)) lw = fromIntegral . glxLevelWidth $ glx
lh = fromIntegral . glxLevelHeight $ glx
return (glx, Just $ SomeEvent $ MouseMotionEvent ((w/2+x)/s - lw/2) ((h/2-y)/s + lh/2))
| otherwise -> return (glx, Nothing) | otherwise -> return (glx, Nothing)

View file

@ -39,7 +39,8 @@ runMain st (MainT a) = runStateT a st
main :: IO () main :: IO ()
main = do main = do
gl <- initGL $ glxDriver 10 10 let theLevel = testLevel
gl <- initGL $ glxDriver (levelWidth theLevel) (levelHeight theLevel)
when (initialized gl) $ do when (initialized gl) $ do
currentTime <- getCurrentTime currentTime <- getCurrentTime
@ -47,8 +48,8 @@ main = do
[ SomePlayer $ DefaultPlayer S.empty 0 0 [ SomePlayer $ DefaultPlayer S.empty 0 0
, SomePlayer $ CPUPlayer 0 , SomePlayer $ CPUPlayer 0
]} ]}
gameState = GameState {level = testLevel, tanks = [ Tank 5.0 5.0 0 0 2 360 False gameState = GameState {level = theLevel, tanks = [ Tank 5.0 5.0 0 0 2 270 False
, Tank 5.0 3.5 0 0 2 360 False , Tank 5.0 3.5 0 0 2 270 False
], textures = M.empty} ], textures = M.empty}
runGame gameState $ do runGame gameState $ do

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 284 B