Compare commits
17 commits
make_affec
...
master
Author | SHA1 | Date | |
---|---|---|---|
01183a2465 | |||
|
009cd6fac7 | ||
13700f1b55 | |||
c044dc89da | |||
367ba034b6 | |||
3bc7faa7cd | |||
df2cfcf411 | |||
a7ce6f36a1 | |||
07edd99d0a | |||
dd8556ee2b | |||
66f9d07905 | |||
518e27d1a8 | |||
cd2a0f3706 | |||
eecfe82abd | |||
f8ea2785bf | |||
f678b216d6 | |||
0cc3195455 |
19 changed files with 238 additions and 170 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -8,6 +8,7 @@
|
||||||
cabal.sandbox.config
|
cabal.sandbox.config
|
||||||
dist/
|
dist/
|
||||||
dist-newstyle/
|
dist-newstyle/
|
||||||
|
.direnv/
|
||||||
*.prof
|
*.prof
|
||||||
*.aux
|
*.aux
|
||||||
*.hp
|
*.hp
|
||||||
|
@ -18,3 +19,4 @@ dist-newstyle/
|
||||||
*.eventlog
|
*.eventlog
|
||||||
*.*~
|
*.*~
|
||||||
.*autosave.kra
|
.*autosave.kra
|
||||||
|
result
|
||||||
|
|
BIN
assets/policem.kra
Normal file
BIN
assets/policem.kra
Normal file
Binary file not shown.
BIN
assets/policem.png
Normal file
BIN
assets/policem.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -1,2 +0,0 @@
|
||||||
constraints: affection +verbose
|
|
||||||
profiling: True
|
|
|
@ -1,4 +0,0 @@
|
||||||
packages:
|
|
||||||
./
|
|
||||||
../affection
|
|
||||||
profiling: True
|
|
84
flake.lock
Normal file
84
flake.lock
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"affection-src": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": [
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1700847735,
|
||||||
|
"narHash": "sha256-hSHgLPZwWP7tPoUhH2GLQ4GvHvVGFiXIM0CLps+O5KE=",
|
||||||
|
"ref": "refs/heads/master",
|
||||||
|
"rev": "d0465fa3e1d122503439df7c2de9d16598fc0cf5",
|
||||||
|
"revCount": 306,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.nek0.eu/nek0/affection"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitea.nek0.eu/nek0/affection"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1694529238,
|
||||||
|
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1700844339,
|
||||||
|
"narHash": "sha256-VRlPYk0eRn1ao75hoA99LGehYhxZH5RlkP1YXpVROHM=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "33576fdfce2d11204067d6cfa99a2f990ef2169a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"affection-src": "affection-src",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
46
flake.nix
Normal file
46
flake.nix
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
description = "A game stub written in Haskell";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
affection-src = {
|
||||||
|
url = "git+https://gitea.nek0.eu/nek0/affection";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, flake-utils, affection-src }:
|
||||||
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
|
||||||
|
haskellPackages = pkgs.haskellPackages;
|
||||||
|
|
||||||
|
jailbreakUnbreak = pkg:
|
||||||
|
pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; }));
|
||||||
|
|
||||||
|
packageName = "tracer-game";
|
||||||
|
in rec {
|
||||||
|
packages.${packageName} = # (ref:haskell-package-def)
|
||||||
|
haskellPackages.callCabal2nix packageName self rec {
|
||||||
|
affection = affection-src.defaultPackage.${system};
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultPackage = self.packages.${system}.${packageName};
|
||||||
|
|
||||||
|
devShell = haskellPackages.shellFor {
|
||||||
|
packages = p: [ defaultPackage ];
|
||||||
|
withHoogle = true;
|
||||||
|
buildInputs = with haskellPackages; [
|
||||||
|
haskell-language-server
|
||||||
|
ghcid
|
||||||
|
cabal-install
|
||||||
|
] ++ (builtins.attrValues self.packages.${system});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
110
shell.nix
110
shell.nix
|
@ -1,102 +1,14 @@
|
||||||
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:
|
{ pkgs ? import <nixpkgs> {}}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# create a modified haskell package set with my package inside it and broken dependencies
|
||||||
inherit (nixpkgs) pkgs;
|
# jailbroken.
|
||||||
|
hpkgs = pkgs.haskellPackages.override {
|
||||||
affection = with haskellPackages; callPackage(
|
overrides = hself: hsuper: {
|
||||||
{ mkDerivation, base, bytestring, clock, containers, glib, linear
|
tracer-game = hself.callCabal2nix "tracer-game" (gitignore ./.) {};
|
||||||
, monad-loops, monad-parallel, mtl, OpenGL, sdl2, stdenv, stm, text
|
affection = hself.callCabal2nix "affection" (gitignore ../affection) {};
|
||||||
, uuid, vector
|
};
|
||||||
}:
|
};
|
||||||
mkDerivation {
|
gitignore = dir: pkgs.nix-gitignore.gitignoreSource [] dir;
|
||||||
pname = "affection";
|
|
||||||
version = "0.0.0.10";
|
|
||||||
src = ../affection;
|
|
||||||
isLibrary = true;
|
|
||||||
isExecutable = true;
|
|
||||||
libraryHaskellDepends = [
|
|
||||||
base bytestring clock containers glib linear monad-loops
|
|
||||||
monad-parallel mtl OpenGL sdl2 stm text uuid vector
|
|
||||||
];
|
|
||||||
homepage = "https://github.com/nek0/affection#readme";
|
|
||||||
description = "A simple Game Engine using SDL";
|
|
||||||
license = stdenv.lib.licenses.lgpl3;
|
|
||||||
doHaddock = false;
|
|
||||||
}) {};
|
|
||||||
|
|
||||||
algebraic-graphs = with haskellPackages; callPackage(
|
|
||||||
{ mkDerivation, array, base, containers, deepseq, extra
|
|
||||||
, inspection-testing, mtl, QuickCheck, stdenv, transformers
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "algebraic-graphs";
|
|
||||||
version = "0.5";
|
|
||||||
sha256 = "89b9fecf8245476ec823355125fcb95decf41fd9784e807d7bd0d09f0a79c50b";
|
|
||||||
libraryHaskellDepends = [
|
|
||||||
array base containers deepseq mtl transformers
|
|
||||||
];
|
|
||||||
testHaskellDepends = [
|
|
||||||
array base containers deepseq extra inspection-testing mtl
|
|
||||||
QuickCheck transformers
|
|
||||||
];
|
|
||||||
homepage = "https://github.com/snowleopard/alga";
|
|
||||||
description = "A library for algebraic graph construction and transformation";
|
|
||||||
license = stdenv.lib.licenses.mit;
|
|
||||||
}
|
|
||||||
) {};
|
|
||||||
|
|
||||||
nanovg = with haskellPackages; callPackage(
|
|
||||||
{ mkDerivation, base, bytestring, c2hs, containers, glew
|
|
||||||
, hspec, inline-c, libGL, libGLU, QuickCheck, stdenv, text, vector
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "nanovg";
|
|
||||||
version = "0.6.0.0";
|
|
||||||
sha256 = "e35a2772f2a2e71916013cab70eeb8eedd6f66b5490ddf7ce237c8c76895d496";
|
|
||||||
revision = "1";
|
|
||||||
editedCabalFile = "1lhfsq50r9bdby7mfscw8ih3wsz2m19lr2a2z9b6diaf5kz76vij";
|
|
||||||
configureFlags = [ "-fgl3" ];
|
|
||||||
isLibrary = true;
|
|
||||||
isExecutable = true;
|
|
||||||
libraryHaskellDepends = [ base bytestring containers text vector ];
|
|
||||||
librarySystemDepends = [ glew libGL libGLU ];
|
|
||||||
libraryPkgconfigDepends = [ glew ];
|
|
||||||
libraryToolDepends = [ c2hs ];
|
|
||||||
testHaskellDepends = [ base containers hspec inline-c QuickCheck ];
|
|
||||||
homepage = "https://github.com/cocreature/nanovg-hs";
|
|
||||||
description = "Haskell bindings for nanovg";
|
|
||||||
license = stdenv.lib.licenses.isc;
|
|
||||||
doCheck = false;
|
|
||||||
}) {};
|
|
||||||
|
|
||||||
f = { mkDerivation, astar, base
|
|
||||||
, bytestring, containers, ecstasy, JuicyPixels, JuicyPixels-extra
|
|
||||||
, linear, matrix, mtl, OpenGL, parallel, random, sdl2
|
|
||||||
, split, stdenv, stm, text, unordered-containers, vector
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "tracer-game";
|
|
||||||
version = "0.0.0.0";
|
|
||||||
src = ./.;
|
|
||||||
isLibrary = false;
|
|
||||||
isExecutable = true;
|
|
||||||
executableHaskellDepends = [
|
|
||||||
affection algebraic-graphs astar base bytestring containers ecstasy
|
|
||||||
JuicyPixels JuicyPixels-extra linear matrix mtl nanovg OpenGL
|
|
||||||
parallel random sdl2 split stm text unordered-containers vector
|
|
||||||
];
|
|
||||||
license = stdenv.lib.licenses.gpl3;
|
|
||||||
};
|
|
||||||
|
|
||||||
haskellPackages = if compiler == "default"
|
|
||||||
then pkgs.haskellPackages
|
|
||||||
else pkgs.haskell.packages.${compiler};
|
|
||||||
|
|
||||||
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
|
|
||||||
|
|
||||||
drv = variant (haskellPackages.callPackage f {});
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
hpkgs.tracer-game.env
|
||||||
if pkgs.lib.inNixShell then drv.env else drv
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ loadPlayerSprite fp w h nvg rids = do
|
||||||
mapM (\(num, i) -> do
|
mapM (\(num, i) -> do
|
||||||
let cr = crop (num * w) (row * h) w h img
|
let cr = crop (num * w) (row * h) w h img
|
||||||
mresimg <-
|
mresimg <-
|
||||||
createImageMem nvg ImagePremultiplied (toStrict $ encodePng cr)
|
createImageMem nvg (S.singleton ImagePremultiplied) (toStrict $ encodePng cr)
|
||||||
case mresimg of
|
case mresimg of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
logIO
|
logIO
|
||||||
|
|
103
src/Load.hs
103
src/Load.hs
|
@ -8,16 +8,19 @@ import Graphics.Rendering.OpenGL.GL.FlushFinish (finish)
|
||||||
import Control.Concurrent (forkIO)
|
import Control.Concurrent (forkIO)
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
import Control.Monad.Trans.Resource (ResIO)
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Ecstasy
|
import Data.Ecstasy
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import qualified Data.Set as S
|
||||||
import Data.String
|
import Data.String
|
||||||
|
|
||||||
import System.Exit (exitFailure)
|
import System.Exit (exitFailure)
|
||||||
|
|
||||||
import NanoVG hiding (V2(..))
|
import NanoVG hiding (V2(..))
|
||||||
|
import NanoVG.Internal.Image
|
||||||
|
|
||||||
-- internal imports
|
-- internal imports
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ loadLoad ud = do
|
||||||
(nano ud)
|
(nano ud)
|
||||||
(stateMVar ud)
|
(stateMVar ud)
|
||||||
(stateProgress ud)
|
(stateProgress ud)
|
||||||
SDL.glMakeCurrent (fromJust curWin) (snd $ head $ glContext ad)
|
SDL.glMakeCurrent (fromJust curWin) (acContext $ head $ glContext ad)
|
||||||
void $ liftIO $ swapMVar (state ud) Load
|
void $ liftIO $ swapMVar (state ud) Load
|
||||||
void $ liftIO $ swapMVar (assetFonts ud) (M.fromList
|
void $ liftIO $ swapMVar (assetFonts ud) (M.fromList
|
||||||
[ (FontBedstead, "bedstead")
|
[ (FontBedstead, "bedstead")
|
||||||
|
@ -51,12 +54,12 @@ loadLoad ud = do
|
||||||
)
|
)
|
||||||
|
|
||||||
loadFork
|
loadFork
|
||||||
:: SystemState Entity (AffectionState (AffectionData) IO)
|
:: SystemState Entity (AffectionState (AffectionData) ResIO)
|
||||||
-> SDL.Window
|
-> SDL.Window
|
||||||
-> SDL.GLContext
|
-> SDL.GLContext
|
||||||
-> Context
|
-> Context
|
||||||
-> MVar
|
-> MVar
|
||||||
( SystemState Entity (AffectionState (AffectionData) IO)
|
( SystemState Entity (AffectionState (AffectionData) ResIO)
|
||||||
, StateData
|
, StateData
|
||||||
)
|
)
|
||||||
-> MVar (Float, T.Text)
|
-> MVar (Float, T.Text)
|
||||||
|
@ -69,202 +72,202 @@ loadFork ws win glc nvg future progress = do
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading icon \"conntroller_blue\""
|
, "Loading icon \"conntroller_blue\""
|
||||||
)))
|
)))
|
||||||
mcontrblue <- createImage nvg (FileName "assets/icons/controller_blue.png") 0
|
mcontrblue <- createImage nvg (FileName "assets/icons/controller_blue.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading icon \"controller_blue\""
|
, "Loading icon \"controller_blue\""
|
||||||
)))
|
)))
|
||||||
mcontrgreen <- createImage nvg (FileName "assets/icons/controller_green.png") 0
|
mcontrgreen <- createImage nvg (FileName "assets/icons/controller_green.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading icon \"controller_green\""
|
, "Loading icon \"controller_green\""
|
||||||
)))
|
)))
|
||||||
mkbdblue <- createImage nvg (FileName "assets/icons/keyboard_blue.png") 0
|
mkbdblue <- createImage nvg (FileName "assets/icons/keyboard_blue.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading icon \"keyboard_blue\""
|
, "Loading icon \"keyboard_blue\""
|
||||||
)))
|
)))
|
||||||
mkbdgreen <- createImage nvg (FileName "assets/icons/keyboard_green.png") 0
|
mkbdgreen <- createImage nvg (FileName "assets/icons/keyboard_green.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading icon \"keyboard_green\""
|
, "Loading icon \"keyboard_green\""
|
||||||
)))
|
)))
|
||||||
marrow <- createImage nvg (FileName "assets/icons/arrow.png") 0
|
marrow <- createImage nvg (FileName "assets/icons/arrow.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_asc\""
|
, "Loading asset \"wall_asc\""
|
||||||
)))
|
)))
|
||||||
mwallasc <- createImage nvg (FileName "assets/walls/wall_asc.png") 0
|
mwallasc <- createImage nvg (FileName "assets/walls/wall_asc.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_desc\""
|
, "Loading asset \"wall_desc\""
|
||||||
)))
|
)))
|
||||||
mwalldesc <- createImage nvg (FileName "assets/walls/wall_desc.png") 0
|
mwalldesc <- createImage nvg (FileName "assets/walls/wall_desc.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_corner_n\""
|
, "Loading asset \"wall_corner_n\""
|
||||||
)))
|
)))
|
||||||
mwallcornern <- createImage nvg (FileName "assets/walls/wall_corner_n.png") 0
|
mwallcornern <- createImage nvg (FileName "assets/walls/wall_corner_n.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_corner_e\""
|
, "Loading asset \"wall_corner_e\""
|
||||||
)))
|
)))
|
||||||
mwallcornere <- createImage nvg (FileName "assets/walls/wall_corner_e.png") 0
|
mwallcornere <- createImage nvg (FileName "assets/walls/wall_corner_e.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_corner_s\""
|
, "Loading asset \"wall_corner_s\""
|
||||||
)))
|
)))
|
||||||
mwallcorners <- createImage nvg (FileName "assets/walls/wall_corner_s.png") 0
|
mwallcorners <- createImage nvg (FileName "assets/walls/wall_corner_s.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_corner_w\""
|
, "Loading asset \"wall_corner_w\""
|
||||||
)))
|
)))
|
||||||
mwallcornerw <- createImage nvg (FileName "assets/walls/wall_corner_w.png") 0
|
mwallcornerw <- createImage nvg (FileName "assets/walls/wall_corner_w.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_t_ne\""
|
, "Loading asset \"wall_t_ne\""
|
||||||
)))
|
)))
|
||||||
mwalltne <- createImage nvg (FileName "assets/walls/wall_t_ne.png") 0
|
mwalltne <- createImage nvg (FileName "assets/walls/wall_t_ne.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_t_se\""
|
, "Loading asset \"wall_t_se\""
|
||||||
)))
|
)))
|
||||||
mwalltse <- createImage nvg (FileName "assets/walls/wall_t_se.png") 0
|
mwalltse <- createImage nvg (FileName "assets/walls/wall_t_se.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_t_sw\""
|
, "Loading asset \"wall_t_sw\""
|
||||||
)))
|
)))
|
||||||
mwalltsw <- createImage nvg (FileName "assets/walls/wall_t_sw.png") 0
|
mwalltsw <- createImage nvg (FileName "assets/walls/wall_t_sw.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_t_nw\""
|
, "Loading asset \"wall_t_nw\""
|
||||||
)))
|
)))
|
||||||
mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") 0
|
mwalltnw <- createImage nvg (FileName "assets/walls/wall_t_nw.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"wall_cross\""
|
, "Loading asset \"wall_cross\""
|
||||||
)))
|
)))
|
||||||
mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") 0
|
mwallcross <- createImage nvg (FileName "assets/walls/wall_cross.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"box1\""
|
, "Loading asset \"box1\""
|
||||||
)))
|
)))
|
||||||
mmiscbox1 <- createImage nvg (FileName "assets/misc/box1.png") 0
|
mmiscbox1 <- createImage nvg (FileName "assets/misc/box1.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableSW\""
|
, "Loading asset \"tableSW\""
|
||||||
)))
|
)))
|
||||||
mtableSW <- createImage nvg (FileName "assets/table/tableSW.png") 0
|
mtableSW <- createImage nvg (FileName "assets/table/tableSW.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableSE\""
|
, "Loading asset \"tableSE\""
|
||||||
)))
|
)))
|
||||||
mtableSE <- createImage nvg (FileName "assets/table/tableSE.png") 0
|
mtableSE <- createImage nvg (FileName "assets/table/tableSE.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableNE\""
|
, "Loading asset \"tableNE\""
|
||||||
)))
|
)))
|
||||||
mtableNE <- createImage nvg (FileName "assets/table/tableNE.png") 0
|
mtableNE <- createImage nvg (FileName "assets/table/tableNE.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableNW\""
|
, "Loading asset \"tableNW\""
|
||||||
)))
|
)))
|
||||||
mtableNW <- createImage nvg (FileName "assets/table/tableNW.png") 0
|
mtableNW <- createImage nvg (FileName "assets/table/tableNW.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableC1\""
|
, "Loading asset \"tableC1\""
|
||||||
)))
|
)))
|
||||||
mtablec1 <- createImage nvg (FileName "assets/table/tablec1.png") 0
|
mtablec1 <- createImage nvg (FileName "assets/table/tablec1.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableC2\""
|
, "Loading asset \"tableC2\""
|
||||||
)))
|
)))
|
||||||
mtablec2 <- createImage nvg (FileName "assets/table/tablec2.png") 0
|
mtablec2 <- createImage nvg (FileName "assets/table/tablec2.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableC3\""
|
, "Loading asset \"tableC3\""
|
||||||
)))
|
)))
|
||||||
mtablec3 <- createImage nvg (FileName "assets/table/tablec3.png") 0
|
mtablec3 <- createImage nvg (FileName "assets/table/tablec3.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableC4\""
|
, "Loading asset \"tableC4\""
|
||||||
)))
|
)))
|
||||||
mtablec4 <- createImage nvg (FileName "assets/table/tablec4.png") 0
|
mtablec4 <- createImage nvg (FileName "assets/table/tablec4.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"tableCorner\""
|
, "Loading asset \"tableCorner\""
|
||||||
)))
|
)))
|
||||||
mtableC <- createImage nvg (FileName "assets/table/tableCorner.png") 0
|
mtableC <- createImage nvg (FileName "assets/table/tableCorner.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"flipchart\""
|
, "Loading asset \"flipchart\""
|
||||||
)))
|
)))
|
||||||
mmiscFlipchart <- createImage nvg (FileName "assets/misc/flipchart.png") 0
|
mmiscFlipchart <- createImage nvg (FileName "assets/misc/flipchart.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"plant1\""
|
, "Loading asset \"plant1\""
|
||||||
)))
|
)))
|
||||||
mmiscPlant1 <- createImage nvg (FileName "assets/misc/plant1.png") 0
|
mmiscPlant1 <- createImage nvg (FileName "assets/misc/plant1.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"plant2\""
|
, "Loading asset \"plant2\""
|
||||||
)))
|
)))
|
||||||
mmiscPlant2 <- createImage nvg (FileName "assets/misc/plant2.png") 0
|
mmiscPlant2 <- createImage nvg (FileName "assets/misc/plant2.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"watercooler\""
|
, "Loading asset \"watercooler\""
|
||||||
)))
|
)))
|
||||||
mmiscWatercooler <- createImage nvg (FileName "assets/misc/watercooler.png") 0
|
mmiscWatercooler <- createImage nvg (FileName "assets/misc/watercooler.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"vending machine\""
|
, "Loading asset \"vending machine\""
|
||||||
)))
|
)))
|
||||||
mmiscVending <- createImage nvg (FileName "assets/misc/vending.png") 0
|
mmiscVending <- createImage nvg (FileName "assets/misc/vending.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"Cabinet with Coffee machine SW\""
|
, "Loading asset \"Cabinet with Coffee machine SW\""
|
||||||
)))
|
)))
|
||||||
mcabCoffeeSW <- createImage nvg (FileName "assets/cabinet/cabCoffeeSW.png") 0
|
mcabCoffeeSW <- createImage nvg (FileName "assets/cabinet/cabCoffeeSW.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"Cabinet with Coffee machine SE\""
|
, "Loading asset \"Cabinet with Coffee machine SE\""
|
||||||
)))
|
)))
|
||||||
mcabCoffeeSE <- createImage nvg (FileName "assets/cabinet/cabCoffeeSE.png") 0
|
mcabCoffeeSE <- createImage nvg (FileName "assets/cabinet/cabCoffeeSE.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"Cabinet with sink SW\""
|
, "Loading asset \"Cabinet with sink SW\""
|
||||||
)))
|
)))
|
||||||
mcabSinkSW <- createImage nvg (FileName "assets/cabinet/cabSinkSW.png") 0
|
mcabSinkSW <- createImage nvg (FileName "assets/cabinet/cabSinkSW.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"Cabinet with sink SE\""
|
, "Loading asset \"Cabinet with sink SE\""
|
||||||
)))
|
)))
|
||||||
mcabSinkSE <- createImage nvg (FileName "assets/cabinet/cabSinkSE.png") 0
|
mcabSinkSE <- createImage nvg (FileName "assets/cabinet/cabSinkSE.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"Cabinet with stove SW\""
|
, "Loading asset \"Cabinet with stove SW\""
|
||||||
)))
|
)))
|
||||||
mcabStoveSW <- createImage nvg (FileName "assets/cabinet/cabStoveSW.png") 0
|
mcabStoveSW <- createImage nvg (FileName "assets/cabinet/cabStoveSW.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"Cabinet with stove SE\""
|
, "Loading asset \"Cabinet with stove SE\""
|
||||||
)))
|
)))
|
||||||
mcabStoveSE <- createImage nvg (FileName "assets/cabinet/cabStoveSE.png") 0
|
mcabStoveSE <- createImage nvg (FileName "assets/cabinet/cabStoveSE.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"cabinet SW\""
|
, "Loading asset \"cabinet SW\""
|
||||||
)))
|
)))
|
||||||
mcabinetSW <- createImage nvg (FileName "assets/cabinet/cabinetSW.png") 0
|
mcabinetSW <- createImage nvg (FileName "assets/cabinet/cabinetSW.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"cabinet SE\""
|
, "Loading asset \"cabinet SE\""
|
||||||
)))
|
)))
|
||||||
mcabinetSE <- createImage nvg (FileName "assets/cabinet/cabinetSE.png") 0
|
mcabinetSE <- createImage nvg (FileName "assets/cabinet/cabinetSE.png") (S.singleton ImagePremultiplied)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading asset \"cabinet corner\""
|
, "Loading asset \"cabinet corner\""
|
||||||
)))
|
)))
|
||||||
mcabinetCorner <- createImage nvg (FileName "assets/cabinet/cabinetCorner.png") 0
|
mcabinetCorner <- createImage nvg (FileName "assets/cabinet/cabinetCorner.png") (S.singleton ImagePremultiplied)
|
||||||
let micons =
|
let micons =
|
||||||
[ mcontrblue, mcontrgreen, mkbdblue, mkbdgreen, marrow
|
[ mcontrblue, mcontrgreen, mkbdblue, mkbdgreen, marrow
|
||||||
]
|
]
|
||||||
|
@ -334,6 +337,18 @@ loadFork ws win glc nvg future progress = do
|
||||||
)))
|
)))
|
||||||
jdoemWalking <- loadAnimationSprites "assets/jdoem.png" nvg
|
jdoemWalking <- loadAnimationSprites "assets/jdoem.png" nvg
|
||||||
(zip (walkIds AnimJDoeM) walkConfigs)
|
(zip (walkIds AnimJDoeM) walkConfigs)
|
||||||
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
|
( p + increment
|
||||||
|
, "Loading Animation \"policem: standing\""
|
||||||
|
)))
|
||||||
|
policemStanding <- loadAnimationSprites "assets/policem.png" nvg
|
||||||
|
(zip (standIds AnimPoliceM) standConfigs)
|
||||||
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
|
( p + increment
|
||||||
|
, "Loading Animation \"policem: walking\""
|
||||||
|
)))
|
||||||
|
policemWalking <- loadAnimationSprites "assets/policem.png" nvg
|
||||||
|
(zip (walkIds AnimPoliceM) walkConfigs)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Loading Animation \"copier: stand\""
|
, "Loading Animation \"copier: stand\""
|
||||||
|
@ -506,6 +521,8 @@ loadFork ws win glc nvg future progress = do
|
||||||
playerWalking ++
|
playerWalking ++
|
||||||
jdoemStanding ++
|
jdoemStanding ++
|
||||||
jdoemWalking ++
|
jdoemWalking ++
|
||||||
|
policemStanding ++
|
||||||
|
policemWalking ++
|
||||||
copierStand ++
|
copierStand ++
|
||||||
copierCopy ++
|
copierCopy ++
|
||||||
cornerComputerOff ++
|
cornerComputerOff ++
|
||||||
|
|
16
src/Main.hs
16
src/Main.hs
|
@ -17,6 +17,7 @@ import Data.Maybe (fromJust)
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
|
import Control.Monad.Trans.Resource (allocate)
|
||||||
|
|
||||||
-- internal imports
|
-- internal imports
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ main = do
|
||||||
, windowConfigs =
|
, windowConfigs =
|
||||||
[ ( 0
|
[ ( 0
|
||||||
, SDL.defaultWindow
|
, SDL.defaultWindow
|
||||||
{ SDL.windowInitialSize = V2 1280 720
|
{ SDL.windowInitialSize = V2 1920 1080
|
||||||
, SDL.windowResizable = True
|
, SDL.windowResizable = True
|
||||||
, SDL.windowGraphicsContext = SDL.OpenGLContext SDL.defaultOpenGL
|
, SDL.windowGraphicsContext = SDL.OpenGLContext SDL.defaultOpenGL
|
||||||
{ SDL.glProfile = SDL.Core SDL.Normal 3 3
|
{ SDL.glProfile = SDL.Core SDL.Normal 3 3
|
||||||
|
@ -60,17 +61,18 @@ main = do
|
||||||
pre :: UserData -> Affection ()
|
pre :: UserData -> Affection ()
|
||||||
pre ud = do
|
pre ud = do
|
||||||
ad <- A.get
|
ad <- A.get
|
||||||
threadCtx <- SDL.glCreateContext ((\(_, y, _) -> y) $ head $ drawWindows ad)
|
let (AffectionWindow awwindow _ _) = head $ drawWindows ad
|
||||||
SDL.glMakeCurrent ((\(_, y, _) -> y) $ head $ drawWindows ad) (snd $ head $ glContext ad)
|
threadCtx <- SDL.glCreateContext awwindow
|
||||||
|
SDL.glMakeCurrent awwindow (acContext $ head $ glContext ad)
|
||||||
let Subsystems w _ k j _ = subsystems ud
|
let Subsystems w _ k j _ = subsystems ud
|
||||||
_ <- partSubscribe w (fitViewport (1280/720))
|
_ <- partSubscribe w (fitViewport (1920/1080))
|
||||||
_ <- partSubscribe w (exitOnWindowClose ud)
|
_ <- partSubscribe w (exitOnWindowClose ud)
|
||||||
_ <- partSubscribe k toggleFullScreen
|
_ <- partSubscribe k toggleFullScreen
|
||||||
_ <- partSubscribe k (quitGame ud)
|
_ <- partSubscribe k (quitGame ud)
|
||||||
u <- partSubscribe j (cacheJoypad ud)
|
u <- partSubscribe j (cacheJoypad ud)
|
||||||
(ws, _) <- yieldSystemT (0, defStorage) (return ())
|
(ws, _) <- yieldSystemT (0, defStorage) (return ())
|
||||||
void $ liftIO $ swapMVar (threadContext ud) (Just threadCtx)
|
void $ liftIO $ swapMVar (threadContext ud) (Just threadCtx)
|
||||||
void $ liftIO $ swapMVar (window ud) (Just $ (\(_, y, _) -> y) $ head $ drawWindows ad)
|
void $ liftIO $ swapMVar (window ud) (Just awwindow)
|
||||||
void $ liftIO $ putMVar (worldState ud) ws
|
void $ liftIO $ putMVar (worldState ud) ws
|
||||||
void $ liftIO $ putMVar (joyUUID ud) u
|
void $ liftIO $ putMVar (joyUUID ud) u
|
||||||
|
|
||||||
|
@ -90,8 +92,8 @@ quitGame ud (MsgKeyboardEvent _ _ SDL.Pressed False sym)
|
||||||
mapM_ (partUnSubscribe j) curUUID
|
mapM_ (partUnSubscribe j) curUUID
|
||||||
mapM_ (partUnSubscribe t) curUUID
|
mapM_ (partUnSubscribe t) curUUID
|
||||||
SDL.glMakeCurrent
|
SDL.glMakeCurrent
|
||||||
((\(_, y, _) -> y) $ head $ drawWindows ad)
|
(awWindow $ head $ drawWindows ad)
|
||||||
(snd $ head $ glContext ad)
|
(acContext $ head $ glContext ad)
|
||||||
(ws, _) <- yieldSystemT (0, defStorage) (return ())
|
(ws, _) <- yieldSystemT (0, defStorage) (return ())
|
||||||
void $ liftIO $ swapMVar (worldState ud) ws
|
void $ liftIO $ swapMVar (worldState ud) ws
|
||||||
void $ liftIO $ swapMVar (state ud) Load
|
void $ liftIO $ swapMVar (state ud) Load
|
||||||
|
|
|
@ -12,6 +12,7 @@ import NanoVG hiding (V2(..))
|
||||||
|
|
||||||
import Control.Monad (when, void)
|
import Control.Monad (when, void)
|
||||||
import Control.Monad.State.Strict (evalStateT)
|
import Control.Monad.State.Strict (evalStateT)
|
||||||
|
import Control.Monad.Trans.Resource (ResIO, runResourceT)
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
import Control.Concurrent (forkIO)
|
import Control.Concurrent (forkIO)
|
||||||
import Control.Parallel.Strategies hiding (dot)
|
import Control.Parallel.Strategies hiding (dot)
|
||||||
|
@ -85,7 +86,7 @@ changeMaps2 _ _ = return ()
|
||||||
loadMapFork
|
loadMapFork
|
||||||
:: UserData
|
:: UserData
|
||||||
-> AffectionData
|
-> AffectionData
|
||||||
-> MVar (SystemState Entity (AffectionState AffectionData IO), StateData)
|
-> MVar (SystemState Entity (AffectionState AffectionData ResIO), StateData)
|
||||||
-> MVar (Float, T.Text)
|
-> MVar (Float, T.Text)
|
||||||
-> IO ()
|
-> IO ()
|
||||||
loadMapFork ud ad future progress = do
|
loadMapFork ud ad future progress = do
|
||||||
|
@ -94,7 +95,7 @@ loadMapFork ud ad future progress = do
|
||||||
fc = FloorConfig
|
fc = FloorConfig
|
||||||
(V2 10 10)
|
(V2 10 10)
|
||||||
[(V2 5 5), (V2 5 20)]
|
[(V2 5 5), (V2 5 20)]
|
||||||
(50, 50)
|
(40, 40)
|
||||||
modifyMVar_ progress (return . (\(p, _) ->
|
modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Building floor"
|
, "Building floor"
|
||||||
|
@ -130,7 +131,7 @@ loadMapFork ud ad future progress = do
|
||||||
, "Creating WorldState"
|
, "Creating WorldState"
|
||||||
)))
|
)))
|
||||||
wState <- liftIO $ readMVar (worldState ud)
|
wState <- liftIO $ readMVar (worldState ud)
|
||||||
(nws, mmimgmat) <- evalStateT (runState (yieldSystemT wState $ do
|
(nws, mmimgmat) <- runResourceT $ evalStateT (runState (yieldSystemT wState $ do
|
||||||
liftIO $ modifyMVar_ progress (return . (\(p, _) ->
|
liftIO $ modifyMVar_ progress (return . (\(p, _) ->
|
||||||
( p + increment
|
( p + increment
|
||||||
, "Registering copiers into WorldState"
|
, "Registering copiers into WorldState"
|
||||||
|
@ -248,6 +249,7 @@ loadMapFork ud ad future progress = do
|
||||||
<*> (randomRIO (0, 1))
|
<*> (randomRIO (0, 1))
|
||||||
<*> (randomRIO (0, 1))
|
<*> (randomRIO (0, 1))
|
||||||
<*> (randomRIO (0, 1))
|
<*> (randomRIO (0, 1))
|
||||||
|
police <- liftIO $ randomRIO (0 :: Int, 9 :: Int)
|
||||||
let room = V.head
|
let room = V.head
|
||||||
(V.filter
|
(V.filter
|
||||||
((inBounds $ pointCoord cpr) . bounds)
|
((inBounds $ pointCoord cpr) . bounds)
|
||||||
|
@ -264,7 +266,8 @@ loadMapFork ud ad future progress = do
|
||||||
, npcActionState = Just ASWork
|
, npcActionState = Just ASWork
|
||||||
, npcStats = Just stats
|
, npcStats = Just stats
|
||||||
, clearanceLvl = Just (clearance room)
|
, clearanceLvl = Just (clearance room)
|
||||||
, anim = Just $ AnimState (AnimId AnimJDoeM "standing" SE) 0 0
|
, anim = Just $ AnimState
|
||||||
|
(AnimId (if police == 0 then AnimPoliceM else AnimJDoeM) "standing" SE) 0 0
|
||||||
}
|
}
|
||||||
) computers
|
) computers
|
||||||
liftIO $ modifyMVar_ progress (return . (\(p, _) ->
|
liftIO $ modifyMVar_ progress (return . (\(p, _) ->
|
||||||
|
@ -617,10 +620,12 @@ drawMap ud = do
|
||||||
"FPS: "
|
"FPS: "
|
||||||
<> T.pack (Prelude.take 5 $ show (1/dt))
|
<> T.pack (Prelude.take 5 $ show (1/dt))
|
||||||
<> " Clearance: "
|
<> " Clearance: "
|
||||||
<> if not (Prelude.null room)
|
<> (if not (Prelude.null room)
|
||||||
then T.pack (show $ clearance $ V.head room)
|
then T.pack (show $ clearance $ V.head room)
|
||||||
else "0"
|
else "0"
|
||||||
)
|
)
|
||||||
|
-- <> "\nFor answers call 6350"
|
||||||
|
)
|
||||||
|
|
||||||
drawTile
|
drawTile
|
||||||
:: UserData
|
:: UserData
|
||||||
|
|
|
@ -15,6 +15,7 @@ import Data.String
|
||||||
|
|
||||||
import Control.Monad.IO.Class (MonadIO(..))
|
import Control.Monad.IO.Class (MonadIO(..))
|
||||||
import Control.Monad.Trans (lift)
|
import Control.Monad.Trans (lift)
|
||||||
|
import Control.Monad.Trans.Resource (ResIO)
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
import Control.Concurrent (forkIO)
|
import Control.Concurrent (forkIO)
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ import Object ()
|
||||||
getPosBounds
|
getPosBounds
|
||||||
:: SystemT
|
:: SystemT
|
||||||
Entity
|
Entity
|
||||||
(AffectionState AffectionData IO)
|
(AffectionState AffectionData ResIO)
|
||||||
[(V2 Double, Boundaries Double)]
|
[(V2 Double, Boundaries Double)]
|
||||||
getPosBounds = do
|
getPosBounds = do
|
||||||
efor allEnts $ do
|
efor allEnts $ do
|
||||||
|
@ -47,10 +48,10 @@ getPosBounds = do
|
||||||
updateNPCs
|
updateNPCs
|
||||||
:: M.Matrix (Maybe ImgId)
|
:: M.Matrix (Maybe ImgId)
|
||||||
-> M.Matrix TileState
|
-> M.Matrix TileState
|
||||||
-> SystemState Entity (AffectionState AffectionData IO)
|
-> SystemState Entity (AffectionState AffectionData ResIO)
|
||||||
-> V.Vector ReachPoint
|
-> V.Vector ReachPoint
|
||||||
-> Double
|
-> Double
|
||||||
-> SystemT Entity (AffectionState AffectionData IO) ()
|
-> SystemT Entity (AffectionState AffectionData ResIO) ()
|
||||||
updateNPCs imgmat tsmat ws rrp dt = do
|
updateNPCs imgmat tsmat ws rrp dt = do
|
||||||
updateStats dt
|
updateStats dt
|
||||||
posbounds <- getPosBounds
|
posbounds <- getPosBounds
|
||||||
|
@ -263,7 +264,7 @@ standStill imgmat tsmat pos' rot' ws posbounds rp = do
|
||||||
|
|
||||||
updateStats
|
updateStats
|
||||||
:: Double
|
:: Double
|
||||||
-> SystemT Entity (AffectionState AffectionData IO) ()
|
-> SystemT Entity (AffectionState AffectionData ResIO) ()
|
||||||
updateStats dt =
|
updateStats dt =
|
||||||
emap allEnts $ do
|
emap allEnts $ do
|
||||||
with npcStats
|
with npcStats
|
||||||
|
|
|
@ -46,6 +46,7 @@ data AnimationName
|
||||||
| AnimComputer
|
| AnimComputer
|
||||||
| AnimToilet
|
| AnimToilet
|
||||||
| AnimJDoeM
|
| AnimJDoeM
|
||||||
|
| AnimPoliceM
|
||||||
| AnimDoor0
|
| AnimDoor0
|
||||||
deriving (Show, Eq, Ord, Enum)
|
deriving (Show, Eq, Ord, Enum)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ module Types.ObjClass where
|
||||||
|
|
||||||
import Affection
|
import Affection
|
||||||
|
|
||||||
|
import Control.Monad.Trans.Resource (ResIO)
|
||||||
import Data.Ecstasy
|
import Data.Ecstasy
|
||||||
|
|
||||||
import Types.Entity
|
import Types.Entity
|
||||||
|
@ -15,7 +16,7 @@ class ObjectAction otype ostate where
|
||||||
-> otype
|
-> otype
|
||||||
-> ostate
|
-> ostate
|
||||||
-> Ent
|
-> Ent
|
||||||
-> SystemT Entity (AffectionState AffectionData IO) ()
|
-> SystemT Entity (AffectionState AffectionData ResIO) ()
|
||||||
|
|
||||||
objectTransition
|
objectTransition
|
||||||
:: otype
|
:: otype
|
||||||
|
@ -23,7 +24,7 @@ class ObjectAction otype ostate where
|
||||||
-> Bool
|
-> Bool
|
||||||
-> Ent
|
-> Ent
|
||||||
-> Maybe Ent
|
-> Maybe Ent
|
||||||
-> SystemT Entity (AffectionState AffectionData IO) (Entity 'SetterOf)
|
-> SystemT Entity (AffectionState AffectionData ResIO) (Entity 'SetterOf)
|
||||||
|
|
||||||
class ActionTime otype ostate where
|
class ActionTime otype ostate where
|
||||||
actionTime :: otype -> ostate -> Double
|
actionTime :: otype -> ostate -> Double
|
||||||
|
|
|
@ -16,6 +16,7 @@ import qualified Data.Text as T
|
||||||
import Data.Ecstasy
|
import Data.Ecstasy
|
||||||
|
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
|
import Control.Monad.Trans.Resource
|
||||||
|
|
||||||
import Types.StateData
|
import Types.StateData
|
||||||
import Types.ImgId
|
import Types.ImgId
|
||||||
|
@ -34,10 +35,10 @@ data UserData = UserData
|
||||||
, translation :: MVar Translation
|
, translation :: MVar Translation
|
||||||
, nano :: Context
|
, nano :: Context
|
||||||
, uuid :: MVar [UUID]
|
, uuid :: MVar [UUID]
|
||||||
, worldState :: MVar (SystemState Entity (AffectionState AffectionData IO))
|
, worldState :: MVar (SystemState Entity (AffectionState AffectionData ResIO))
|
||||||
, stateData :: MVar StateData
|
, stateData :: MVar StateData
|
||||||
, stateMVar :: MVar
|
, stateMVar :: MVar
|
||||||
( SystemState Entity (AffectionState AffectionData IO)
|
( SystemState Entity (AffectionState AffectionData ResIO)
|
||||||
, StateData
|
, StateData
|
||||||
)
|
)
|
||||||
, stateProgress :: MVar (Float, T.Text)
|
, stateProgress :: MVar (Float, T.Text)
|
||||||
|
|
|
@ -257,7 +257,7 @@ loadAnimationSprites fp nvg idconfs = do
|
||||||
mresimgs <- mapM
|
mresimgs <- mapM
|
||||||
(\cr ->
|
(\cr ->
|
||||||
createImageMem nvg
|
createImageMem nvg
|
||||||
ImagePremultiplied (toStrict $ encodePng cr))
|
(S.singleton ImagePremultiplied) (toStrict $ encodePng cr))
|
||||||
crs
|
crs
|
||||||
imgs <- if any isNothing mresimgs
|
imgs <- if any isNothing mresimgs
|
||||||
then do
|
then do
|
||||||
|
|
|
@ -80,6 +80,7 @@ executable tracer-game
|
||||||
, mtl
|
, mtl
|
||||||
, parallel
|
, parallel
|
||||||
, split
|
, split
|
||||||
|
, resourcet
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
ghc-options: -Wall -threaded
|
ghc-options: -Wall -threaded
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
Loading…
Reference in a new issue