Giter Club home page Giter Club logo

the_bearriver_arcade's Introduction

The Bearriver Arcade

A few simple games and a game engine (maybe less of an engine and more like a bunch of scattered systems) with features such as game state saving and loading (the game is saved on quit, this can be used for pseudo code hot-swapping), collision detection, a input manager, frame rate targets, SDL rendering wrappers and more. I also have more games I’m working on that will probably appear here in time.

I have tried cleaning the code up a bit with everything I have learned since starting this but it might be a bit rough in a few places. Comments are scarce because I didn’t think of releasing this while writing it but the code should be pretty straight forward hopefully.

The games

Lunar lander

Scroll to zoom

Arrow keys to rotate the ship and fly forward

This is a lunar lander clone, with a few visual issues, most probably caused by relying on SDL for rendering. Or maybe it’s my fault I’m not entirely sure and haven’t bother finding out because I’m trying to transition to use Vulkan for future projects.

LunarLander.png

This game also has a few other secret games in it! This was the repository where it all begun, so if you look back through the commits you can find (hopefully) working builds of simpler games made using reflex, reactive banana and even a traditional game loop.

Simple game 1

Arrow keys to move

This is just the one of simplest games you can make SimpleGame1.png

Simple game 2

Arrow keys to move

This game is pretty interesting. If you go slow the player is pretty much a square: SimpleGame2-1.png

But the faster you go the thinner the player gets: SimpleGame2-2.png

Simple game 3

Arrow keys to move

This game is a lot like the last game, but with some new gameplay mechanics. It’s not polished code-wise or gameplay-wise

Installation

This project contains git submodules. Clone it with git clone --recurse-submodules https://github.com/walseb/The_Bearriver_Arcade

Run project

  1. Enter a directory for a game like FRPLunarLander
  2. Run nix-shell
  3. Run cabal run

If you don’t want to run this under nix, just get the dependencies listed in the shell.nix file. For lunar lander that would be:

pkg-config
cabal-install
ghc
SDL2
SDL2_image
SDL2_ttf

Bugs

Supported resolutions

Right now only 1080p monitors are correctly centered on the player. This is because I haven’t bothered looking into the resolution change events SDL probably emits.

the_bearriver_arcade's People

Contributors

walseb avatar

Stargazers

Vladimir Lopatin avatar Julian G avatar George Takumi Crary avatar jwy avatar Daniel Kahlenberg avatar Ivan Perez, PhD avatar

Watchers

James Cloos avatar  avatar

the_bearriver_arcade's Issues

Suggestion: use ghcWithPackages instead of ghc in shell.nix

At the moment:

❯ cd FRPSimpleGame2
❯ nix-shell --run "cabal run"
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.RemoteRepo {remoteRepoName = "hackage.haskell.org",
remoteRepoURI = http://hackage.haskell.org/, remoteRepoSecure = Just True,
remoteRepoRootKeys =
["fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0","1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42","2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3","0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d","51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921"],
remoteRepoKeyThreshold = 3, remoteRepoShouldTryHttps = True}
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: FRPEngine-0.2.0.0 (user goal)
[__1] unknown package: vector (dependency of FRPEngine)
[__1] fail (backjumping, conflict set: FRPEngine, vector)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: FRPEngine, vector

If FRPSimpleGame2/shell.nix were modified to look something like this:

{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell {
  buildInputs = with pkgs; [
    pkg-config
    cabal-install
    (haskellPackages.ghcWithPackages (hpkgs:
    with hpkgs; [
      vector
      sdl2-ttf
      sdl2-image
      gjk
      extra
      bearriver
      aeson
    ]))
    SDL2
    SDL2_image
    SDL2_ttf
  ];
}

Then nix-shell --run "cabal run" works out of the box.

I've only looked at FRPSimpleGame2 so far, but I expect the others would benefit from a similar/identical change.

Comments

Hi,

I've been going through the code, just to look around :)

This is really nice :) Congratulations! It should definitely be in the dunai and Yampa readmes.

I understand that these are just prototypes, but they are actually fun to play. With very minor changes, they could be something I could see myself having fun with. Some ideas:

  • Lunar lander: let players know if they won or lost.
  • SimpleGame1: further levels, longer level. It would be interesting to see that the game does have a time leak (if older blocks that you leave on the left remain in the world / in memory) -- I had this when I wrote a clone of flappy bird.
  • SimpleGame2: this is a great idea for a game. I can't clear that square you have in the screenshot well :)

If you are serious about trying to make any of these into a bigger game, I'd suggest trying to simplify it as much as possible: trust me, it'll get really complex if you add all the features a game needs.

Minor suggestions specifically about the code:

  • FRPEngine

Should Physics and Collision live under the same namespace?

  • YampaUtils

I normally call this FRP.Yampa.Extra (or FRP.Yampa.Utils). It makes it easy to ignore.

( \case
Just True -> True
_ -> False
)

Why not fromMaybe False?

https://github.com/walseb/The_Bearriver_Arcade/blob/master/FRPEngine/src/FRPEngine/Collision/GJK.hs#L15-L24

Why not:
(fromMaybe False . collides) <$> (getCollisionPointsPos a) <*> (getCollisionPointsPos b)

https://github.com/walseb/FRPSimpleGame2/blob/2eb7e7cbeed13b5b04f85dc9e11c02f35442abc9/src/Render/SDL/Render.hs#L16-L18

Why not:
when alive $ renderSpr (player ^. (collObj . obj))

https://github.com/walseb/The_Bearriver_Arcade/blob/master/FRPEngine/src/FRPEngine/Init.hs#L103-L110

Probably simplifiable with IfElse.

https://github.com/walseb/The_Bearriver_Arcade/blob/master/FRPEngine/src/FRPEngine/Init.hs#L113-L115

Why not: min dt frameMaxJump

https://github.com/walseb/FRPLunarLander/blob/09f033cab039d13710f8c69b6acfd66d2a120f22/src/Actors/Player.hs#L39-L43

Use maybe?

(I could go on for ages, cleaning code is my thing.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.