From d631fb551d2087c9d71cae5298d584618b9562f0 Mon Sep 17 00:00:00 2001 From: Matt Dray Date: Tue, 4 Oct 2022 22:43:12 +0100 Subject: [PATCH] Add graphics for each species and level, close #10 --- NEWS.md | 1 + R/draw.R | 30 +++++++++++++++++++++++------- R/interact.R | 6 +++++- R/sysdata.rda | Bin 208 -> 410 bytes data-raw/images.R | 39 +++++++++++++++++++++++++++++++-------- 5 files changed, 60 insertions(+), 16 deletions(-) diff --git a/NEWS.md b/NEWS.md index 055a32e..d84ae9f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ # tamRgo 0.0.0.9004 * Simplified the output of `get_stats()` and included 'bars' for status values. +* Added graphics for species X, Y and Z for levels 0 (shared), 1, 2 and 3 (#10). # tamRgo 0.0.0.9003 diff --git a/R/draw.R b/R/draw.R index 5abc3dc..7cce2b0 100644 --- a/R/draw.R +++ b/R/draw.R @@ -7,20 +7,36 @@ #' @examples \dontrun{ .get_pet_matrix("X")} #' #' @noRd -.get_pet_matrix <- function(species = c("X", "Y", "Z")) { +.get_pet_matrix <- function(species = c("X", "Y", "Z"), level = 1L:3L) { species <- match.arg(species) - if (species == "X") { - return(species_images[["X"]]) + if (level == 0L) { + return(species_images[["X"]][["level_0"]]) } - if (species == "Y") { - return(species_images[["Y"]]) + if (species == "X" & level == 1L) { + return(species_images[["X"]][["level_1"]]) + } else if (species == "X" & level == 2L) { + return(species_images[["X"]][["level_2"]]) + } else if (species == "X" & level == 3L) { + return(species_images[["X"]][["level_3"]]) } - if (species == "Z") { - return(species_images[["Z"]]) + if (species == "Y" & level == 1L) { + return(species_images[["Y"]][["level_1"]]) + } else if (species == "Y" & level == 2L) { + return(species_images[["Y"]][["level_2"]]) + } else if (species == "Y" & level == 3L) { + return(species_images[["Y"]][["level_3"]]) + } + + if (species == "Z" & level == 1L) { + return(species_images[["Z"]][["level_1"]]) + } else if (species == "Z" & level == 2L) { + return(species_images[["Z"]][["level_2"]]) + } else if (species == "Z" & level == 3L) { + return(species_images[["Z"]][["level_3"]]) } } diff --git a/R/interact.R b/R/interact.R index bd8b7d3..c113d04 100644 --- a/R/interact.R +++ b/R/interact.R @@ -81,7 +81,11 @@ see_pet <- function() { bp <- .check_and_update() - pet_matrix <- .get_pet_matrix(bp$characteristics$species) + pet_matrix <- .get_pet_matrix( + bp$characteristics$species, + bp$experience$level + ) + .draw_pet(pet_matrix) } diff --git a/R/sysdata.rda b/R/sysdata.rda index c85de92ce3a35771e86f2adbe8b7d964e5b68c8f..8d9f8960b58550ce1c0f28cdb178e6aa9e0b3641 100644 GIT binary patch literal 410 zcmV;L0cHL|T4*^jL0KkKSwJ~VjsOysf8qZ3NB}?pcmPBI5OA)iNdQ1VK>!c{00F=P zny{cogKA1LAF4DO8U{h?0p&Cjda9|Wng&Li0h1wsKq5&esGdpafB*m+P%);1Kn$7# zBTWoV8BW0z6CiQVJP=T6r)93>&@}C1tzx1#f~CDObc~# zMFuc>EmWm6s?otAB1nuxvZF?np)|`&EGa`nG_uN4G|Z(fEwW^$Rw*%9N=-8}Ya1kG znSjbnn-*X|kYGpzgkwUgCp=YAvbKa~TLnhO7MRwSYb7>QOi2c)jUrOYDVj=?CQNE# znkY@Mkc5*qWg?nsjTWONq@!&bLu!qZD`QY#tZfw1ue$qYt_f}e2vZf2NI(x#6&j;Q zA1^#i-v=kf!**gN&_qZei)hplK_dZz#9KuK1<(Zs3&jTUQveI92?{0wkwXw8T^2?Q z;zgZ4`*UQbkxZuP5}n-JLG}k(ejD{VKzD$k{(zvz_yq@)1qP5iRHyu1$rRy2K>+14 EIQa>jsQ>@~ literal 208 zcmV;>05AVST4*^jL0KkKStkAMH~<3%@8SM)NB|H3L;w(QuA@i*KtLe?5C8xHumJcd zN|4Y1&@?myY6dWvnhX($WMMEuq*KwP&;ZcT8fk}PtFHa|paZti>3#W`{cL>ndG!gq z2Aho30p*@BO2;A!si-KTB$Z`~SXzpbA_ydcCZ x -matrix_to_sprite(ym) -> y -matrix_to_sprite(zm) -> z +matrix_to_sprite(xyz0) -> xyz0_s + +matrix_to_sprite(x1) -> x1_s +matrix_to_sprite(x2) -> x2_s +matrix_to_sprite(x3) -> x3_s + +matrix_to_sprite(y1) -> y1_s +matrix_to_sprite(y2) -> y2_s +matrix_to_sprite(y3) -> y3_s + +matrix_to_sprite(z1) -> z1_s +matrix_to_sprite(z2) -> z2_s +matrix_to_sprite(z3) -> z3_s -species_images <- list(X = x, Y = y, Z = z) +species_images <- list( + X = list(level_0 = xyz0_s, level_1 = x1_s, level_2 = x2_s, level_3 = x3_s), + Y = list(level_0 = xyz0_s, level_1 = y1_s, level_2 = y2_s, level_3 = y3_s) , + Z = list(level_0 = xyz0_s, level_1 = z1_s, level_2 = z2_s, level_3 = z3_s) +) usethis::use_data(species_images, internal = TRUE, overwrite = TRUE)