Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
FP Asteroids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Edwin
FP Asteroids
Compare revisions
70155c4eaf38016fbe5605cef627f729e18b4d87 to 36232466dee1b044e9379d9659eef084ff73b562
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
9562850/fp-asteroids
Select target project
No results found
36232466dee1b044e9379d9659eef084ff73b562
Select Git revision
Swap
Target
9562850/fp-asteroids
Select target project
9562850/fp-asteroids
1 result
70155c4eaf38016fbe5605cef627f729e18b4d87
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
made a start with type classes
· a938f6f0
Edwin
authored
4 months ago
a938f6f0
Merge branch 'main' of
https://git.science.uu.nl/9562850/fp-asteroids
· 36232466
Edwin
authored
4 months ago
36232466
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Controller.hs
+4
-1
4 additions, 1 deletion
src/Controller.hs
src/Model.hs
+27
-1
27 additions, 1 deletion
src/Model.hs
with
31 additions
and
2 deletions
src/Controller.hs
View file @
36232466
...
...
@@ -232,11 +232,14 @@ spawnPowerup gen Nothing = (Just genPowerup, newGen)
(
index
,
newGen
)
=
randomR
(
fromEnum
(
minBound
::
Effect
),
fromEnum
(
maxBound
::
Effect
))
gen''
genPowerup
=
Powerup
(
genX
,
genY
)
(
toEnum
index
)
powerupRadius
::
Float
powerupRadius
=
15
checkPowerupCollision
::
GameState
->
GameState
checkPowerupCollision
gstate
@
(
GameState
{
spaceShip
,
powerup
})
=
case
powerup
of
Nothing
->
gstate
Just
x
->
if
(
collidesWith
15
(
position
x
)
(
location
spaceShip
))
Just
x
->
if
(
collidesWith
powerupRadius
(
position
x
)
(
location
spaceShip
))
then
(
claimPowerup
gstate
)
else
gstate
...
...
This diff is collapsed.
Click to expand it.
src/Model.hs
View file @
36232466
...
...
@@ -8,6 +8,19 @@ import System.Random
import
System.IO
(
withFile
,
IOMode
(
ReadMode
),
hGetContents
)
class
Spawnable
a
where
getLastSpawn
::
a
->
Float
spawn
::
StdGen
->
(
a
,
StdGen
)
class
Moving
a
where
getLocation
::
a
->
Location
getOrientation
::
a
->
Orientation
getVelocity
::
a
->
Velocity
move
::
Float
->
a
->
a
--checkCollision :: a -> GameState -> Bool (!) not sure if we need this
data
MovingObject
=
MovingObject
Location
Orientation
Velocity
type
Velocity
=
Float
type
Location
=
(
Float
,
Float
)
type
Orientation
=
Float
...
...
@@ -31,7 +44,16 @@ data Specifications = Specs {
type
Size
=
Int
data
Meteor
=
Meteor
{
coordinates
::
Location
,
directoin
::
Orientation
,
pace
::
Velocity
,
size
::
Size
}
data
UFO
=
UFO
Location
Orientation
Velocity
Bullet
data
UFO
=
UFO
MovingObject
Bullet
instance
Moving
UFO
where
getLocation
(
UFO
(
MovingObject
x
_
_
)
_
)
=
x
getOrientation
(
UFO
(
MovingObject
_
x
_
)
_
)
=
x
getVelocity
(
UFO
(
MovingObject
_
_
x
)
_
)
=
x
move
secs
(
UFO
(
MovingObject
loc
orient
v
)
b
)
=
UFO
(
MovingObject
loc
orient
v
)
b
type
Score
=
Int
type
Name
=
String
type
Highscore
=
(
Name
,
Score
)
...
...
@@ -61,8 +83,10 @@ data GameState = GameState {
,
elapsedTime
::
Float
,
powerupTimer
::
Float
,
meteorTimer
::
Float
,
ufoTimer
::
Float
,
spaceShip
::
Spaceship
,
meteors
::
[
Meteor
]
,
ufos
::
[
UFO
]
,
powerup
::
Maybe
Powerup
,
seed
::
StdGen
-- Each game has its own 'seed' which allows for pure randomness
}
...
...
@@ -113,9 +137,11 @@ initialState seed = GameState {
,
player
=
Player
3
0
"Player"
,
elapsedTime
=
0
,
powerupTimer
=
0
,
ufoTimer
=
0
,
spaceShip
=
Spaceship
(
0
,
0
)
0
0
[]
seed
0
defaultSpecs
,
powerup
=
Nothing
,
meteors
=
[]
,
ufos
=
[]
,
notification
=
""
,
tooltip
=
""
,
seed
=
seed
...
...
This diff is collapsed.
Click to expand it.