Skip to content

Commit 7ca9f18

Browse files
committed
Add TP6
1 parent 09e2836 commit 7ca9f18

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

tn-fp-course.cabal

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ library slides
6868
Course04
6969
Course05
7070

71+
library
72+
import: common-all
73+
hs-source-dirs: tps
74+
exposed-modules: Scratch
75+
7176
executable TP1.hs
7277
import: common-all
7378
main-is: TP1.hs
@@ -93,7 +98,9 @@ executable TP5.hs
9398
main-is: TP5.hs
9499
hs-source-dirs: tps
95100

96-
library
97-
import: common-all
98-
hs-source-dirs: tps
99-
exposed-modules: Scratch
101+
-- Remove the comments below to enable the TP6!
102+
-- executable TP6.hs
103+
-- import: common-all
104+
-- build-depends: gloss
105+
-- main-is: TP6.hs
106+
-- hs-source-dirs: tps

tps/TP6.hs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
-- Build me with: cabal build TP6.hs
2+
-- Execute me with: cabal run -v0 TP6.hs
3+
--
4+
-- This lab exercice uses the following library:
5+
--
6+
-- - 'gloss' for rendering simple graphics. See its documentation here:
7+
-- https://hackage.haskell.org/package/gloss-1.13.2.2/docs/Graphics-Gloss.html
8+
--
9+
-- Goals:
10+
--
11+
-- 1. Write an OpenGL Pong game using the gloss library. The two players
12+
-- play on the same keyboard.
13+
-- 2. Make the game work over the network: one player is the server, the second
14+
-- one connects to the server and then the game begins.
15+
--
16+
-- -----------------------------------
17+
-- WARNING YOU NEED TO DO SOMETHING! -
18+
-- -----------------------------------
19+
--
20+
-- To avoid requiring installation OpenGL drivers during the first TPs,
21+
-- this one is not active by default. So you MUST:
22+
--
23+
-- 1. Uncomment the lines concerning TP6.hs at the end of the file tn-tp-course.cabal at the repository root.(<=)
24+
-- 2. You need to install OpenGL libraries on your machine:
25+
--
26+
-- sudo apt install libgl1-mesa-dev freeglut3 freeglut3-dev
27+
-- 3. Then you can run 'cabal build TP6.hs' at the repository root and it should work.
28+
--
29+
-- -----------
30+
-- END WARNING
31+
-- -----------
32+
33+
module Main where
34+
35+
import Graphics.Gloss
36+
import Graphics.Gloss.Interface.Pure.Game
37+
38+
-- Data carried out all along the game
39+
data PongGame = PongGame
40+
{ {- Your fields here -}
41+
} deriving Show
42+
43+
initialState :: PongGame
44+
initialState = undefined
45+
46+
main :: IO ()
47+
main = play
48+
undefined
49+
undefined
50+
60 -- Frames per second
51+
initialState
52+
render
53+
undefined
54+
undefined
55+
56+
-- Render the game state
57+
render :: PongGame -> Picture
58+
render _ = undefined

0 commit comments

Comments
 (0)