Rendering
This commit is contained in:
parent
76f9ba0bc6
commit
7efc16fabc
1 changed files with 9 additions and 7 deletions
16
src/Main.hs
16
src/Main.hs
|
@ -194,15 +194,19 @@ nextBoard b@Board{ turned = [c1, c2] } = resetTurned b
|
|||
|
||||
-- Zet een positie op het bord om naar een positie op het scherm.
|
||||
-- Hint: hou zeker rekening met het coordinatensysteem van Gloss.
|
||||
-- TODO unfinished
|
||||
-- 0: x-axis, 1: y-axis
|
||||
-- Linksonderaan is (0,0) voor Card.Coordinate,
|
||||
-- (-(x/2),-(y/2)) voor as van lengte x en y in Gloss.
|
||||
convert :: Int -> Int -> Float
|
||||
convert location axis = fromIntegral location
|
||||
convert location axis = car + inset
|
||||
where car = (-(fromIntegral axis / 2.0) + fromIntegral location) * fromIntegral scaling
|
||||
inset = fromIntegral ((-(axis `div` 2) + location) * cardInset)
|
||||
|
||||
-- Render een vierkant met een gegeven kleur en grootte.
|
||||
-- TODO Klopt deze functionaliteit?
|
||||
renderColoredSquare :: Int -> Color -> Picture
|
||||
renderColoredSquare size c = color c $ rectangleSolid s s
|
||||
where s = fromIntegral size
|
||||
renderColoredSquare size c = color c $ rectangleSolid x x
|
||||
where x = fromIntegral size
|
||||
|
||||
-- Render de selector.
|
||||
-- TODO unfinished
|
||||
|
@ -210,10 +214,8 @@ renderSelector :: Coordinate -> Picture
|
|||
renderSelector coord = blank
|
||||
|
||||
-- Render een kaart.
|
||||
-- TODO Klopt deze functionaliteit?
|
||||
renderCard :: Card -> Picture
|
||||
renderCard card = renderColoredSquare scaling color
|
||||
where color = (\(_,c,_) -> c) card
|
||||
renderCard ((x,y),color,status) = translate (convert x width) (convert y height) $ renderColoredSquare scaling color
|
||||
|
||||
-- Render alle kaarten.
|
||||
renderCards :: [Card] -> Picture
|
||||
|
|
Reference in a new issue