All Projects → facundoolano → Advenjure

facundoolano / Advenjure

Licence: epl-1.0
Text adventure engine written in Clojure and ClojureScript

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Advenjure

Etlegacy
ET: Legacy is an open source project based on the code of Wolfenstein: Enemy Territory which was released in 2010 under the terms of the GPLv3 license.
Stars: ✭ 212 (-15.87%)
Mutual labels:  game-development
Inline Engine
Game engine written in C++ with ease of use and next-gen parallel computing in focus.
Stars: ✭ 237 (-5.95%)
Mutual labels:  game-development
Panda3d
Powerful, mature open-source cross-platform game engine for Python and C++, developed by Disney and CMU
Stars: ✭ 3,035 (+1104.37%)
Mutual labels:  game-development
Gamedev Resources
An updated collection of useful resources to resources to design, develop and market games.
Stars: ✭ 219 (-13.1%)
Mutual labels:  game-development
Entitas Cpp
Entitas++ is a fast Entity Component System (ECS) C++11 port of Entitas C#
Stars: ✭ 229 (-9.13%)
Mutual labels:  game-development
Sucle
Common Lisp Voxel Game Engine
Stars: ✭ 239 (-5.16%)
Mutual labels:  game-development
Atomicgameengine
The Atomic Game Engine is a multi-platform 2D and 3D engine with a consistent API in C++, C#, JavaScript, and TypeScript
Stars: ✭ 2,541 (+908.33%)
Mutual labels:  game-development
Blender Tools
🐵 Embark Addon for Blender
Stars: ✭ 250 (-0.79%)
Mutual labels:  game-development
Kira
Library for expressive game audio.
Stars: ✭ 237 (-5.95%)
Mutual labels:  game-development
Gameframework
This is literally a game framework, based on Unity game engine. It encapsulates commonly used game modules during development, and, to a large degree, standardises the process, enhances the development speed and ensures the product quality.
Stars: ✭ 3,318 (+1216.67%)
Mutual labels:  game-development
Stealthgameudemy
C++ Stealth Game in Unreal Engine (Udemy Project)
Stars: ✭ 221 (-12.3%)
Mutual labels:  game-development
Awesome Godot
A curated list of free/libre plugins, scripts and add-ons for Godot
Stars: ✭ 3,092 (+1126.98%)
Mutual labels:  game-development
Shadered
Lightweight, cross-platform & full-featured shader IDE
Stars: ✭ 3,247 (+1188.49%)
Mutual labels:  game-development
Antimine Android
Antimine is an open source minesweeper-like puzzle game.
Stars: ✭ 218 (-13.49%)
Mutual labels:  game-development
Gdevelop
🎮 GDevelop is an open-source, cross-platform game engine designed to be used by everyone.
Stars: ✭ 3,221 (+1178.17%)
Mutual labels:  game-development
Awesome Haxe Gamedev
Resources for game development on haxe
Stars: ✭ 213 (-15.48%)
Mutual labels:  game-development
Luascript
Lua language support for Godot Engine
Stars: ✭ 240 (-4.76%)
Mutual labels:  game-development
Flopnite Ue4
A remake of the popular battle royale game, Fortnite, made in Unreal Engine 4 and integrated with Amazon GameLift
Stars: ✭ 250 (-0.79%)
Mutual labels:  game-development
Octopuskit
2D ECS game engine in 100% Swift + SwiftUI for iOS, macOS, tvOS
Stars: ✭ 246 (-2.38%)
Mutual labels:  game-development
Godot Mixing Desk
A complete audio solution for Godot 3.2.x, making procedural sound and adaptive/procedural music possible with a few nodes and a couple lines of code.
Stars: ✭ 240 (-4.76%)
Mutual labels:  game-development

advenjure Build Status

Example game

Advenjure is a text adventure (or interactive fiction) game engine. I wrote it as an excuse to learn Clojure. Some of its distinctive features are:

  • Target the terminal and the browser with the same codebase.
  • Unix-like prompt with smart tab completion and command history
  • Customizable verbs and plugins.
  • LucasArts inspired dialog trees.

Example game

You can see the code for a working example in the advenjure-example repository and play it online here.

For a fully fledged game see House Taken Over.

Installation

Add the following to your project map as a dependency:

[advenjure "0.9.0"]

Basic Usage

Creating items

Text adventures consist mainly of moving around rooms and interacting with items through verb commands such as GO, LOOK, TAKE, etc.

Items are represented by maps in advenjure. the advenjure.items/make function takes a name, a description and a set of key-value pairs to customize behavior. For example:

(require '[advenjure.items :as items])

(def magazine (items/make "magazine"
                          "The cover read 'Sports Almanac 1950-2000'"
                          :take true
                          :read "Oh là là? Oh là là!?"))

That will define a magazine item that can be taken (put in the player's inventory) and can be read (which differs from looking at it).

You can provide a vector of names so the player can refer to it by one of its synonyms; the first name in the vector will be considered its canonical name:

(def magazine (items/make ["magazine" "sports magazine" "newspaper"]
                          "The cover read 'Sports Almanac 1950-2000'"
                          :take true
                          :read "Oh là là? Oh là là!?"))

Like :take and :read there are keywords for the other actions (:look-at, :open, :close, :unlock, etc.).

A special kind of items are those that can contain other items:

(def magazine (items/make "bag" :items #{magazine} :closed true))

The bag contains the magazine, but since it's :closed the player needs to open it before being able to look inside it and take its contents. Note that marking an object as :closed also implies that OPEN and CLOSE verbs can be applied to it (i.e. it means :open true, :close true).

Creating rooms

Once you've created a bunch of items, you'll need to put them in a room (if not directly into the player's inventory). Rooms are also maps and also have an advenjure.rooms/make function to build them:

(require '[advenjure.rooms :as rooms])

(def bedroom (rooms/make "Bedroom"
                         "A smelling bedroom."
                         :initial-description "I woke up in a smelling little bedroom, without windows."))

Note that rooms can have only one name. :initial-description is an optional attribute to define how the player will describe a room the first time he visits it, usually with a more verbose description. If :initial-description is not defined, and whenever the LOOK AROUND command is entered, the regular description will be used.

To add items to a room use advenjure.rooms/add-item:

(def bedroom (-> (rooms/make "Bedroom"
                             "A smelling bedroom."
                             :initial-description "I woke up in a smelling little bedroom, without windows.")
                 (rooms/add-item (items/make "bed" "It was the bed I slept in."))
                 (rooms/add-item magazine "On the floor was a sports magazine.")))

The second parameter is an optional room-specific description of the item. It will be used to mention the item while describing the room (as opposed of the default a <item> is here.).

Building a room map

Once you have some rooms, you need to connect them to build a room map, which is nothing but a plain clojure hash map. First map the room to some id keyword, then connect the rooms using the advenjure.rooms/connect function:

(def room-map (-> {:bedroom bedroom
                   :living living
                   :outside outside}
                  (rooms/connect :bedroom :north :living)
                  (rooms/connect :living :east :outside)))

An alternative function, advenjure.rooms/one-way-connect, allows connecting the rooms just in one direction.

Building and running a game

The next building block is the game map itself, which contains the room map, the player's inventory and a pointer to the current room. advenjure.game/make helps to build it:

(require '[advenjure.game :as game])

(game/make room-map :bedroom)

The room keyword defines what room the player will be in when the game starts. If you want to start off the game with some items in the player's inventory, just pass them in a set as the third argument.

Lastly, the advenjure.game/run takes a game state map, a boolean function to tell if the game has finished and an optional string to print before it starts. Putting it all together in a -main function:

(defn -main
  "Build and run the game."
  [& args]
  (let [game-state (game/make room-map :bedroom)
        finished? #(= (:current-room %) :outside)]
    (game/run game-state finished? :start-message "Welcome to the advenjure!")))

The game flows by taking the initial game state map, prompting the user for a command, applying the command to produce a new game state and repeat the process until the finished? condition is met, which, in the example above means entering the :outside room.

Advanced Usage

There is a number of advanced features available in the engine:

  • Overriding messages: use custom messages for a given action on a room or item.
  • Pre conditions: function hook to define whether an action can be performed.
  • Post conditions: function hook to customize how the game state is modified after an action is performed.
  • Dialogs: interactive dialogs with 'character' items, in the style of the LucasArts graphic adventures.
  • Text customization and internationalization.
  • Custom verbs/commands.
  • Plugin hooks to customize behavior without modifying the library.

I'm waiting for the APIs to stabilize (and get a lot of free time) before fully documenting all those features, but I'd be happy to write something up if you need help with something specific, just file an issue!

Run on the browser

The codebase is prepared to run both in the terminal with Clojure and the browser with ClojureScript. An example configuration, using lein-cljsbuild would be:

:cljsbuild
    {:builds
     {:main {:source-paths ["src"]
             :compiler {:output-to "main.js"
                        :main example.core
                        :optimizations :simple
                        :pretty-print false
                        :optimize-constants true
                        :static-fns true}}}

Then the command lein cljsbuild once will output a main.js file that can be included in any web page to run the game. The HTML should have a #terminal div and include the jQuery Terminal CSS to properly render the terminal.

The current limitations of the ClojureScript version of the library are:

  • No internationalization support (since clojure-gettext does not support ClojureScript).
  • Can use up to :simple optimizations (not :advanced), since ClojureScript self-hosting is required for some of the advanced features.

See the advenjure-example for a game that targets both the terminal and the browser.

Roadmap

Check the milestones.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].