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-11-15 04:21:11 UTC |
Source: | https://github.com/matt-dray/ActionSquirrel |
Generate An R6-Class 'Action Squirrel' Game
Generate An R6-Class 'Action Squirrel' Game
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.
Console output with cat()
.
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.
new()
Create a new overworld.
ActionSquirrel$new()
An R6-class object.
pause()
Pause menu with instructions.
ActionSquirrel$pause()
An R6-class object.
move()
Move the hero around the overworld.
ActionSquirrel$move(where = c("up", "down", "left", "right"))
where
Character. Which direction to move. One of "up"
,
"down"
, "left"
and "right"
.
An R6-class object.
clone()
The objects of this class are cloneable with this method.
ActionSquirrel$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run: x <- ActionSquirrel$new() # generate overworld x$move("up") # move character up x$move("right") # move character right ## End(Not run)
## Not run: x <- ActionSquirrel$new() # generate overworld x$move("up") # move character up x$move("right") # move character right ## End(Not run)