Binette

joined 6 months ago
[–] Binette@lemmy.ml 2 points 1 day ago (1 children)

Well where I am, 100 is the maximum. I think going any faster is pretty dangerous, considering you're in a big metal casket :/

[–] Binette@lemmy.ml -2 points 1 day ago (3 children)

Yeah nah. Any faster than 100 km/h is already way too fast. I still don't get how people are more comfortable going over it.

[–] Binette@lemmy.ml 10 points 3 days ago (3 children)

This has to be satire. There is no way...

[–] Binette@lemmy.ml 32 points 3 days ago (1 children)

What's even scarier is that it used that amount of strength to bring the vomit up

[–] Binette@lemmy.ml 11 points 3 days ago (4 children)

It surprises me that there are a lot of births on valentine's day.

Like 9 months later? Sure. But this? Nah.

[–] Binette@lemmy.ml 1 points 4 days ago

Hehe Biden blasts

[–] Binette@lemmy.ml 8 points 5 days ago

Franchement au fond j'ai était entrain de chercher un post sur Lemmy et je suis tombé hasard sur votre post je me suis dis attend je vous fais un petit coucou.

[–] Binette@lemmy.ml 4 points 5 days ago

Thanks! That worked for me (I just used yay -Rd hyprwayland-scanner-debug aswell).

[–] Binette@lemmy.ml 2 points 5 days ago

Nope, that was the only error. But I fixed it thanks to the comment above.

[–] Binette@lemmy.ml 1 points 5 days ago (2 children)

I tried installing it with yay. It's just that when I install it with yay, it gives me a conflict with the existing pacman package and asks me if I want to remove the pacman package. When I say yes, it gives me the above error, and when I say no, it doesn't let me install hyprland-git

 

In order to update hyprland-git, I need to install hyprwayland-scanner-git. But when I try to install it, pacman says that it failed to commit a transaction.

I followed the arch wiki, but unfortunately, the file in question is owned by hyprwayland-scanner, so I'm not sure how to proceed.

[–] Binette@lemmy.ml 1 points 6 days ago

Oh it's not a guide for how to heal from trauma, if that's what you meant! It's about using the term if you think it stems from trauma.

 
 

I'm trying to make minesweeper using rust and bevy, but it feels that my code is bloated (a lot of for loops, segments that seem to be repeating themselves, etc.)

When I look at other people's code, they are using functions that I don't really understand (map, zip, etc.) that seem to make their code faster and cleaner.

I know that I should look up the functions that I don't understand, but I was wondering where you would learn stuff like that in the first place. I want to learn how to find functions that would be useful for optimizing my code.

 

I don't know if it's the best place to ask this, but I've been having issues with trying to make minesweeper with bevy.

I tried making a function that would give the number of mines around the tile that was clicked if it wasn't a mine. Then, I wanted to make it so that when the number of mines around the clicked tiles is 0, it reveals the surrounding tiles. Finally, I tried making the function recursive by rerunning it on the empty surrounding tiles.

The issue is that it seems that certain tiles with no mines surrounding them don't reveal the surrounding tiles.

Here's the portion of the code I am talking about (I know it's pretty bad):

fn find_surrounding_mines(
                          mut set: ParamSet<(
                              EventReader<TileEntity>,
                              EventWriter<TileEntity>,
                             )>,
                          mut surrounding_mines: EventWriter<SurroundingMines>,
                          mut query_board: Query<&mut Board>,
                          mut change_tile_image: EventWriter<ChangeTileImage>,
                        mut query_mine: Query<(&Mine, &mut Tile)>) {
    let dy: [i8; 8] = [-1, -1, -1, 0, 0, 1, 1, 1];
    let dx: [i8; 8] = [-1, 0, 1, -1, 1, -1, 0, 1];
    
    let board = query_board.single_mut();
    let mut num_mine: u8 = 0;
    let mut y: u8 = 0;
    let mut copy_x: usize = 0;
    let mut tile_read:bool = false;
    let mut copy_num_mine:u8 = 0;
    for tile in set.p0().read(){
        for (row_index, vector) in board.tiles.iter().enumerate(){
            if let Some(x) = vector.iter().position(|&x|x == tile.0) {
                copy_x = x;
                y = row_index as u8;
                for i in 0..8{
                    if x as i8 + dx[i] >= 0 && x as i8 + dx[i] < board.width as i8 && y as i8 + dy[i] >= 0 && y as i8 +dy[i] < board.height as i8{
                        if let Ok((_mine,mut tile)) = query_mine.get_mut(board.tiles[(y as i8 + dy[i]) as usize][(x as i8+ dx[i]) as usize]){
                            num_mine += 1;
                            tile.hidden = false;
                        }
                    }
                }
                break;
            } 
        }
        
        surrounding_mines.send(SurroundingMines(num_mine));
        change_tile_image.send(ChangeTileImage{tile: tile.0, asset: "Minesweeper_LAZARUS_21x21_".to_string() + &num_mine.to_string() + ".png"});
        copy_num_mine = num_mine;
        num_mine = 0;
        tile_read = true;
    }

    if copy_num_mine == 0 && tile_read{
            tile_read = false;
            for i in 0..8{
                if copy_x as i8 + dx[i] >= 0 && copy_x as i8 + dx[i] < board.width as i8 && y as i8 + dy[i] >= 0 && y as i8 +dy[i] < board.height as i8{
                    if let Ok((_mine, mut tile)) = query_mine.get(board.tiles[(y as i8 + dy[i]) as usize][(copy_x as i8 + dx[i]) as usize]){
                        continue;
                    }else{
                        println!("{:?}", (y as i8 + dy[i], copy_x as i8 + dx[i]));
                        set.p1().send(TileEntity(board.tiles[(y as i8 + dy[i]) as usize][(copy_x as i8 + dx[i]) as usize]));
                    }
                }
            }
        }
}
view more: next ›