Package 'ActionSquirrel'

Title: Play An R6-Class 'Action Squirrel' Game
Description: Prints to the console a grid of emoji representing a forest, including a player-controlled squirrel that can be moved by the user to collect nuts and avoid an owl enemy. Collect enough nuts to survive winter.
Authors: Matt Dray [aut, cre]
Maintainer: Matt Dray <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-10-16 04:16:01 UTC
Source: https://github.com/matt-dray/ActionSquirrel

Help Index


Generate An R6-Class 'Action Squirrel' Game

Description

Generate An R6-Class 'Action Squirrel' Game

Generate An R6-Class 'Action Squirrel' Game

Details

Prints to the console a grid of emoji representing an overworld, including a player character that can be controlled by the user. Also provides a live tally of moves taken.

Value

Console output with cat().

Public fields

active

Logcial. Is the game in play?

overworld

Character vector. The overworld in one dimension.

s_loc

Numeric. The location of the squirrel.

n_loc

Numeric. The location of the nut.

o_loc

Numeric. The location of the owl.

moves

Numeric. The number of moves made by the player.

nuts

Numeric. The number of nuts collected by the player.

Methods

Public methods


Method new()

Create a new overworld.

Usage
ActionSquirrel$new()
Returns

An R6-class object.


Method pause()

Pause menu with instructions.

Usage
ActionSquirrel$pause()
Returns

An R6-class object.


Method move()

Move the hero around the overworld.

Usage
ActionSquirrel$move(where = c("up", "down", "left", "right"))
Arguments
where

Character. Which direction to move. One of "up", "down", "left" and "right".

Returns

An R6-class object.


Method clone()

The objects of this class are cloneable with this method.

Usage
ActionSquirrel$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

## Not run: 
    x <- ActionSquirrel$new()  # generate overworld
    x$move("up")               # move character up
    x$move("right")            # move character right
    
## End(Not run)