Title: | Puzzle Game for the R Console |
Version: | 1.0.1 |
Description: | Puzzle game that can be played in the R console. Restore the pixel art by shifting rows. |
License: | GPL-3 |
Encoding: | UTF-8 |
URL: | https://github.com/rolkra/pixelpuzzle |
Imports: | beepr, cli, stringr |
RoxygenNote: | 7.2.1 |
NeedsCompilation: | no |
Packaged: | 2023-01-28 09:36:23 UTC; rolkra |
Author: | Roland Krasser [aut, cre] |
Maintainer: | Roland Krasser <roland.krasser@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2023-01-28 10:10:02 UTC |
Colorize a sprite
Description
Colorize a sprite
Usage
colorize_sprite(img, colors = c("X", "S", "W", "S", "X", "ORI"), sleep = 0.1)
Arguments
img |
Sprite |
colors |
Vector of colors that are used |
sleep |
Time between setting colors |
Value
Nothing
Combine two sprite
Description
Combine two sprite
Usage
combine_sprite(img, img2, gap = 1)
Arguments
img |
Sprite 1 |
img2 |
Sprite 2 (added on the right) |
gap |
Gap between the sprites |
Value
Sprite
Examples
sprites <- define_sprite()
sprite1 <- sprites[["buhu"]]
sprite2 <- sprites[["sword"]]
show_sprite(combine_sprite(sprite1, sprite2))
Returns a list of predefined sprites
Description
Returns a list of predefined sprites
Usage
define_sprite()
Value
List of sprites
Examples
sprites <- define_sprite()
## show first sprite
show_sprite(sprites[[1]])
## show sprite named "sword"
show_sprite(sprites[["sword"]])
Flip a sprite
Description
Flip a sprite
Usage
flip_sprite(img)
Arguments
img |
Sprite |
Value
Sprite
Examples
sprites <- define_sprite()
sprite <- sprites[["sword"]]
show_sprite(flip_sprite(sprite))
Intro of pixelpuzzle game
Description
Intro of pixelpuzzle game
Usage
intro(sleep = 0.1)
Arguments
sleep |
How long to wait between change of color |
Value
Nothing
Play pixelpuzzle in the R-console
Description
Play pixelpuzzle in the R-console
Usage
pixelpuzzle(img = NA, bg = ".")
Arguments
img |
Image of Sprite (vector of strings). If no sprite is provided, the player can choose one of the predefined pixel arts. |
bg |
Background color, default is transparent (".") |
Value
Nothing
Examples
## Start game (in interactive R sessions)
if (interactive()) {
pixelpuzzle()
}
Play pixelpuzzle with a sprite
Description
Play pixelpuzzle with a sprite
Usage
play_sprite(img, ori, bg = ".")
Arguments
img |
Sprite to play with |
ori |
Original Sprite |
bg |
Background ("." is transparent) |
Value
Nothing
Select one of the predefined sprites
Description
Select one of the predefined sprites
Usage
select_sprite(sprites, bg = ".")
Arguments
sprites |
List of predefined sprites |
bg |
Background of the sprite ("." = transparent) |
Value
Sprite
Sift a row of the sprite
Description
Sift a row of the sprite
Usage
shift_sprite_row(img, row = 1, shift = 1)
Arguments
img |
Image of Sprite (vector of strings) |
row |
Which row is shifted |
shift |
Nuber of shifts |
Value
Sprite
Show a sprite in console
Description
Show a sprite in console
Usage
show_sprite(img, rownumbers = TRUE, cls = TRUE, bg = ".")
Arguments
img |
Image of Sprite (vector of strings) |
rownumbers |
Show rownumbers on the left side? |
cls |
Clear Screen before drawing sprite? |
bg |
Background color, default is transparent (".") |
Value
Prints sprite in console
Examples
sprites <- define_sprite()
## show first sprite
show_sprite(sprites[[1]])
## show sprite named "sword"
show_sprite(sprites[["sword"]])
Shuffle a sprite randomly
Description
Shuffle a sprite randomly
Usage
shuffle_sprite(img, difficulty = 1)
Arguments
img |
Sprite |
difficulty |
Difficulty (intensity of shuffeling) |
Value
List of sprites
Examples
sprites <- define_sprite()
sprite <- sprites[["sword"]]
show_sprite(shuffle_sprite(sprite))