Compare commits
7 Commits
5585a49393
...
v0.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9b4e2d34a | ||
|
|
73985e298a | ||
|
|
ffc9d08a2d | ||
| 35bd4c1740 | |||
|
|
20ecde081b | ||
|
|
d87e4ba21a | ||
|
|
9e8bafa6e2 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
dist-newstyle
|
||||
result
|
||||
66
CHANGELOG.md
66
CHANGELOG.md
@@ -10,30 +10,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- test suite for non-IO functions
|
||||
- test suite for non-`IO` functions
|
||||
|
||||
### Changed
|
||||
|
||||
- use Rotors rather than Quaternions for rotation; easily extended to 4D
|
||||
- move Player out of Camera
|
||||
- make effektiv all fields configurable
|
||||
- use rotors rather than `Linear.Quaternion` for rotation; easily extended to 4D
|
||||
- move `Player` out of `Camera`
|
||||
- configure with `Properties` objects in the Model
|
||||
- use `Double` rather than `FLoat` for internal calculations
|
||||
- `cursorPos`, `dt` natively `Double` already
|
||||
|
||||
## [Unreleased]
|
||||
## [0.3.0] - 2025-12-08
|
||||
|
||||
### Added
|
||||
|
||||
- Cabal build system
|
||||
- `.gitignore` against build artifacts
|
||||
|
||||
### Changed
|
||||
|
||||
- versioning using the [PVP standard](https://pvp.haskell.org/), though it will remain SemVer compliant
|
||||
- SemVer version A.B.C will become PVP version A.B.C.0
|
||||
- `README.md` overhauled to reflect new build system
|
||||
|
||||
### Fixed
|
||||
|
||||
- a couple non-impactful typos
|
||||
|
||||
### Removed
|
||||
|
||||
- `Game` module -> moved to `Main`
|
||||
|
||||
## [0.2.1] - 2025-12-08
|
||||
|
||||
### Changed
|
||||
|
||||
- break Git by using it wrong
|
||||
- fix Git (maybe)
|
||||
|
||||
## [0.2.0] - 2025-12-07
|
||||
|
||||
### Added
|
||||
|
||||
- 100% documentation coverage
|
||||
- 4 outputs of Nix flake
|
||||
- debug: compiles fast, no docs
|
||||
- release: runs fast, no docs
|
||||
- docs: only docs
|
||||
- default: release binary with docs
|
||||
- `debug`: compiles fast, no docs
|
||||
- `release`: runs fast, no docs
|
||||
- `docs`: only docs
|
||||
- `default`: release binary with docs
|
||||
|
||||
### Changed
|
||||
|
||||
- initResources no longer takes a GLFW.Window argument
|
||||
- `initResources` no longer takes a `GLFW.Window` argument
|
||||
- BSD 3-clause license adopted rather than WTFPL
|
||||
- reasoning: More professional, widely recognised, effectively identical
|
||||
- `CHANGELOG.md` has more formatting, namely inline code
|
||||
- clarify a couple entries in the `[0.1.0] - 2025-12-07 Changed` entry
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -43,17 +75,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- CHANGELOG.md
|
||||
- layer correctly drawn objects in the view function
|
||||
- added `CHANGELOG.md`
|
||||
- layer correctly drawn objects in `view`
|
||||
|
||||
### Changed
|
||||
|
||||
- 8xMSAA rather than 4xMSAA window hint to improve AA
|
||||
- todo and changelog in CHANGELOG.md rather than README.md
|
||||
- a nubmer fo functions from Game module now in Game.Internal
|
||||
- initResources takes an array of objects to draw rather than hardcoded arrays
|
||||
- square the far plane of the perspective transform
|
||||
- loop function takes delta time
|
||||
- todo and changelog in `CHANGELOG.md` rather than `README.md`
|
||||
- a nubmer fo functions from `Game` now in `Game.Internal`
|
||||
- `initResources` takes an `[V3 GL.GLfloat]` to draw rather than hardcoded arrays
|
||||
- square the distance of the far plane of the perspective transform
|
||||
- `loop` function takes delta time `dt :: Float`
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
45
README.md
45
README.md
@@ -1,21 +1,30 @@
|
||||
to run:
|
||||
see CHANGELOG.md
|
||||
|
||||
```bash
|
||||
git clone https://git.mtgmonkey.net/Andromeda/hs-game
|
||||
cd hs-game
|
||||
nix run
|
||||
```
|
||||
to run without nix:
|
||||
- get build tools:
|
||||
- with apt: `apt install cabal-install ghc git`
|
||||
- get source code: `git clone https://git.mtgmonkey.net/Andromeda/hs-game --depth 1; cd hs-game`
|
||||
- get dependencies
|
||||
- with apt on x86-64: `apt install g++-x86-64_linux-gnu libgl-dev libx11-dev libxi-dev libxrandr-dev libxxf86vm-dev libxcursor-dev libxinerama-dev libglu1-mesa-dev`
|
||||
- run with `cabal run` or build with `cabal build`
|
||||
|
||||
to run with nix:
|
||||
`nix run git+https://git.mtgmonkey.net/Andromeda/hs-game`
|
||||
|
||||
to enter nix development shell:
|
||||
`nix develop git+https://git.mtgmonkey.net/Andromeda/hs-game`
|
||||
|
||||
build tested on
|
||||
- nix
|
||||
- Kubuntu 25.10
|
||||
|
||||
to release:
|
||||
|
||||
```bash
|
||||
nix build .#release
|
||||
```
|
||||
|
||||
to debug build:
|
||||
|
||||
```bash
|
||||
nix build .#debug
|
||||
```
|
||||
|
||||
todo moved to CHANGELOG.md
|
||||
- update CHANGELOG.md with new version
|
||||
- update version in hs-game.cabal
|
||||
- update version in flake.nix
|
||||
- check that it builds
|
||||
- `git add -A`
|
||||
- `git status` make sure there aren't random files
|
||||
- `git status -v` make sure all additions are in CHANGELOG.md
|
||||
- double check that flake, .cabal, and CHANGELOG.md all have the same version
|
||||
- release
|
||||
|
||||
111
flake.nix
111
flake.nix
@@ -2,70 +2,63 @@
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
outputs = {nixpkgs, ...}: let
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
versionString = "0.3.0";
|
||||
package = {
|
||||
mkDerivation,
|
||||
base,
|
||||
bytestring,
|
||||
GLFW-b,
|
||||
lens,
|
||||
lib,
|
||||
linear,
|
||||
OpenGL,
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "hs-game";
|
||||
version = versionString;
|
||||
src = ./.;
|
||||
isLibrary = false;
|
||||
isExecutable = true;
|
||||
executableHaskellDepends = [
|
||||
base
|
||||
bytestring
|
||||
GLFW-b
|
||||
lens
|
||||
linear
|
||||
OpenGL
|
||||
];
|
||||
homepage = "https://git.mtgmonkey.net/Andromeda/hs-game";
|
||||
license = lib.licenses.bsd3;
|
||||
mainProgram = "hs-game";
|
||||
};
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
debugGhcOptions = pkgs.lib.concatStringsSep " " (debugGhcFlags ++ commonGhcFlags);
|
||||
debugGhcFlags = [
|
||||
"-O0"
|
||||
"-Wall"
|
||||
"-Widentities"
|
||||
"-Wincomplete-record-updates"
|
||||
"-Wincomplete-uni-patterns"
|
||||
# "-Wmissing-export-lists"
|
||||
"-Wmissing-home-modules"
|
||||
"-Wpartial-fields"
|
||||
"-Wredundant-constraints"
|
||||
"-threaded"
|
||||
"-rtsopts"
|
||||
"-with-rtsopts=-N"
|
||||
"-main-is Game"
|
||||
];
|
||||
haddockOptions = pkgs.lib.concatStringsSep " " haddockFlags;
|
||||
haddockFlags = [
|
||||
"--html"
|
||||
"--odir docs"
|
||||
"--optghc=-i./src"
|
||||
"src/Game.hs"
|
||||
];
|
||||
releaseGhcOptions = pkgs.lib.concatStringsSep " " (releaseGhcFlags ++ commonGhcFlags);
|
||||
releaseGhcFlags = [
|
||||
"-O2"
|
||||
"-threaded"
|
||||
"-rtsopts"
|
||||
"-with-rtsopts=-N"
|
||||
"-main-is Game"
|
||||
];
|
||||
noHaddockOptions = "";
|
||||
commonGhcFlags = [
|
||||
"-i./src"
|
||||
];
|
||||
ghcPackages = p: [
|
||||
p.GLFW-b
|
||||
p.linear
|
||||
p.OpenGL
|
||||
];
|
||||
in {
|
||||
packages.${system} = {
|
||||
debug = pkgs.callPackage ./package.nix {
|
||||
ghcOptions = debugGhcOptions;
|
||||
haddockOptions = noHaddockOptions;
|
||||
inherit ghcPackages;
|
||||
default =
|
||||
pkgs.haskellPackages.callPackage package {};
|
||||
};
|
||||
release = pkgs.callPackage ./package.nix {
|
||||
ghcOptions = releaseGhcOptions;
|
||||
haddockOptions = noHaddockOptions;
|
||||
inherit ghcPackages;
|
||||
};
|
||||
docs = pkgs.callPackage ./package.nix {
|
||||
ghcOptions = "--version";
|
||||
inherit haddockOptions;
|
||||
inherit ghcPackages;
|
||||
};
|
||||
default = pkgs.callPackage ./package.nix {
|
||||
ghcOptions = releaseGhcOptions;
|
||||
inherit haddockOptions;
|
||||
inherit ghcPackages;
|
||||
devShells.${system} = {
|
||||
default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.cabal-install
|
||||
pkgs.libGL
|
||||
pkgs.xorg.libX11
|
||||
pkgs.xorg.libXi
|
||||
pkgs.xorg.libXrandr
|
||||
pkgs.xorg.libXxf86vm
|
||||
pkgs.xorg.libXcursor
|
||||
pkgs.xorg.libXinerama
|
||||
pkgs.libGLU
|
||||
];
|
||||
inputsFrom = [
|
||||
self.packages.${system}.default
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
38
hs-game.cabal
Normal file
38
hs-game.cabal
Normal file
@@ -0,0 +1,38 @@
|
||||
cabal-version: 3.0
|
||||
name: hs-game
|
||||
version: 0.3.0
|
||||
-- synopsis:
|
||||
-- description:
|
||||
homepage: https://git.mtgmonkey.net/Andromeda/hs-game
|
||||
license: BSD-3-Clause
|
||||
license-file: LICENSE
|
||||
author: andromeda
|
||||
maintainer: @andromeda:tchncs.de
|
||||
-- copyright:
|
||||
category: Game
|
||||
build-type: Simple
|
||||
extra-doc-files: CHANGELOG.md
|
||||
-- extra-source-files:
|
||||
|
||||
common warnings
|
||||
ghc-options: -Wall
|
||||
|
||||
common optimizations
|
||||
ghc-options: -O2
|
||||
|
||||
executable hs-game
|
||||
import: optimizations
|
||||
main-is: Main.hs
|
||||
other-modules:
|
||||
Game.Internal,
|
||||
Game.Internal.LoadShaders,
|
||||
Game.Internal.Types
|
||||
-- other-extensions:
|
||||
build-depends:
|
||||
base >= 4.18,
|
||||
bytestring >= 0.12,
|
||||
GLFW-b >= 3.3,
|
||||
lens >= 5.3,
|
||||
linear >= 1.23,
|
||||
OpenGL >= 3.0,
|
||||
hs-source-dirs: src
|
||||
39
package.nix
39
package.nix
@@ -1,39 +0,0 @@
|
||||
{
|
||||
haskellPackages,
|
||||
lib,
|
||||
stdenv,
|
||||
ghcOptions,
|
||||
haddockOptions,
|
||||
ghcPackages,
|
||||
...
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "hs-game";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
nativeBuildInputs = [
|
||||
(haskellPackages.ghcWithPackages ghcPackages)
|
||||
];
|
||||
buildInputs = [
|
||||
];
|
||||
configurePhase = ''
|
||||
'';
|
||||
buildPhase = ''
|
||||
touch Main
|
||||
ghc ${ghcOptions} ./src/Game.hs -o ./Main
|
||||
mkdir ./docs
|
||||
haddock ${haddockOptions}
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ./Main $out/bin/hs-game
|
||||
cp ./docs $out/docs -r
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = "https://mtgmonkey.net";
|
||||
license = lib.licenses.bsd3;
|
||||
mainProgram = "hs-game";
|
||||
platforms = ["x86_64-linux"];
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
{-# LANGUAGE DisambiguateRecordFields, NamedFieldPuns, OverloadedRecordDot #-}
|
||||
{- |
|
||||
- Module : Game.Internal
|
||||
- Description : 'hidden' functions
|
||||
- Copyright : Andromeda 2025
|
||||
- License : WTFPL
|
||||
- Description : internal functions
|
||||
- Copyright : 2025 Andromeda
|
||||
- License : BSD 3-clause
|
||||
- Maintainer : Matrix @Andromeda:tchncs.de
|
||||
- Stability : Experimental
|
||||
-}
|
||||
@@ -208,7 +208,7 @@ applyToTuples f (x, y) (a, b) = (f x a, f y b)
|
||||
updateCursorPos :: Double -> Double -> Model -> Model
|
||||
updateCursorPos x y model =
|
||||
let
|
||||
pyth = (((fst model.cursorPos) - x) ** 2 + ((snd model.cursorPos - y)) ** 2) ** 0.5
|
||||
pyth = (((fst model.cursorPos) - x) ** 2 + ((snd model.cursorPos) - y) ** 2) ** 0.5
|
||||
in
|
||||
if pyth < 16 then
|
||||
model
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
{- |
|
||||
- Module : Game
|
||||
- Description : runs game
|
||||
- Copyright : Andromeda 2025
|
||||
- License : WTFPL
|
||||
- Copyright : 2025 Andromeda
|
||||
- License : BSD 3-clause
|
||||
- Maintainer : Matrix @Andromeda:tchncs.de
|
||||
- Stability : Experimental
|
||||
-}
|
||||
module Game (main) where
|
||||
module Main (main) where
|
||||
|
||||
import Game.Internal.Types
|
||||
import Game.Internal
|
||||
Reference in New Issue
Block a user