JohnGolgota / tamagochi

8 stars 0 forks source link

Add grid system for frames rendering #5

Open Kolozuz opened 10 months ago

Kolozuz commented 10 months ago

Description

Currently each frame of the pets animation is manually generated, the idea is to add a grid system so that frames can be generated dynamically, here's an example of what i mean by "grid" (essentially an array of arrays, aka two dimensional array):

# python example
grid = [
  ["","","","","","","","","",""]
  ["","","","","","","","","",""]
  ["","","","","","","","","",""]
  ["","","","","","","","","",""]
  ["","","","","","","","","",""]
  ["","","","","","","","","",""]
]

Acceptance Criteria

// Not like this, notice the fixed grid dimensions
let mut grid:Vec<Vec<&str>> = vec![vec!["."; 12]; 6];
//                                           ^^   ^ grid dimensions

// Instead it should be a function (preferably a object's method), so that the desired grid
// dimensions can be parametrized, something like this:
pub fn new(width:usize, height:usize) -> Vec<Vec<&'static str>>{
    let grid:Vec<Vec<&str>> = vec![vec!["."; width]; height];
    return grid//                            ^^^^^^  ^^^^^^ grid dimensions
}

Current

Right now every frame is manually generated (kinda cringe smh :disappointed:)

Notes

Thew way of printing or drawing our grid should be something like this

for row in grid {
    let mut rowstr: String = String::new();
    for cell  in row {
        rowstr += cell;
    }
    println!("{}", rowstr);
}

// 12x6 grid output if every character was a dot
// ............
// ............
// ............
// ............
// ............
// ............
JohnGolgota commented 9 months ago

is this still in development? what other issues are there? I mean what was this turn like? (Si, me causo gracia traducir un modismo o coloquialismo, no se. Aunque no se si este correcto.)

Kolozuz commented 9 months ago

is this still in development? what other issues are there? I mean what was this turn like? (Si, me causo gracia traducir un modismo o coloquialismo, no se. Aunque no se si este correcto.)

Hahah yeah this vuelta is still in developement, in general it's no really too hard to implement, the main reasons why it is taking long are:

For now i think i will just implement the grid system as a function in the utils module and call it a day, so that i can start working on the animation process, which shouldn't take too much time.

Sorry for such long text lmao, i was inspired, feel free to translate it xd