简体   繁体   中英

Drawing bitmap to screen Gloss Haskell

For uni I have this assignment where I need to code a simple game, im now having issues with drawing the player object to the screen. I have the following functions:

data Player = MkPlayer {
                playerpos :: Point,
                playerradius :: Int,
                playerbullets :: [Bullet]
              }

instance Renderable Player where
  render (MkPlayer pos rad _ ) = do picture <- loadBMP "./images/player.bmp"
                                    return picture
.
.
.

view :: GameState -> IO Picture
view (MkGameState False (MkBoard player _) _) = render player

this displays the image to the center of the screen. But of course, I want to draw the image at the players position with the right size. How do i implement this? Any help at alll is aprreciated!!

before return use translate function


instance Renderable Player where
  render (MkPlayer (x,y) rad _ ) = do picture <- loadBMP "./images/player.bmp"
                                    return $ translate x y picture

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM