start_game: Play A Roguelike Game

View source: R/play.R

start_gameR Documentation

Play A Roguelike Game

Description

Clears the console and starts a game of 'r.oguelike' by printing a map with an inventory and status message. The user inputs a keypress to move the character and explore the map, fighting enemies and collecting objects. This is a toy; a proof-of-concept.

Usage

start_game(
  max_turns = Inf,
  n_row = 20L,
  n_col = 30L,
  n_rooms = 5L,
  iterations = 4L,
  is_snake = FALSE,
  is_organic = TRUE,
  has_colour = TRUE,
  has_sfx = TRUE
)

Arguments

max_turns

Integer. How many turns? Default is Inf(inite).

n_row

Integer Number of row tiles in the dungeon, i.e. its height.

n_col

Integer. Number of column tiles in the dungeon, i.e. its width.

n_rooms

Integer Number of rooms to place randomly on the map as starting points for iterative growth.

iterations

Integer. How many times to 'grow' iteratively the dungeon rooms, where tiles adjacent to current floor tiles (.) have a random chance of becoming floor tiles themselves with each iteration.

is_snake

Logical. Should the room start points be connected randomly (FALSE, the default) or from left to right across the room matrix (TRUE)? See details.

is_organic

Logical. Join the room start points with corridors before iterative growth steps (TRUE, the default), or after (FALSE)? See details.

has_colour

Logical. Should the characters in the output be coloured using crayon (TRUE, the default)?

has_sfx

Logical. Should sound effects be used? Defaults to TRUE.

Details

Use the WASD keys to move up, left, down and right. Use the '1' key to eat an apple from your inventory. Use the '0' to quit the game. If your terminal supports the 'keypress' package, then you can use a single keypress as input (e.g. the up arrow key), otherwise you will have to type at the prompt and then press 'Enter'.Use has_keypress_support to see if 'keypress' is supported.

Symbols used in the game are as follows:

  • . floor tile

  • # wall

  • @ player (10 HP max, -1 HP attack damage)

  • $ gold (+1 to +3 G)

  • E enemy (3 HP max, -1 HP attack damage)

  • a apple (+1 HP)

When TRUE, is_snake will tend to create one continuous cavern; is_organic will tend to create more 'natural' looking caves.

Arguments that take integer values are coerced to integer if provided as numeric values.

Value

Nothing. Clears the console and prints to it with cat.

Examples

## Not run: start_game()

matt-dray/r.oguelike documentation built on Jan. 9, 2023, 2:55 p.m.