I'm getting the error "thread 'main' panicked at 'attempt to multiply with overflow', src\main.rs:18:5" and I am not quire sure where the error is or what is actually going wrong?
The code that seems to be the problem is:
pub fn xy_idx(x: i32, y: i32) -> usize {
(y as usize * GRIDHEIGHT) + x as usize
}
[...]
fn update_pixel_position(mut pixels: Query<(&mut Position, &mut Transform)>, mut map: ResMut<Map>){
for (position, mut transform) in &mut pixels {
transform.translation.x = position.x;
transform.translation.y = position.y;
map.grid[xy_idx(position.x as i32, position.y as i32)] = 1;
}
}
[...]
fn update_pixel_physics(mut pixels: Query<(&mut Physics, &mut Position,)>, map: Res<Map>){
for (physics, mut position) in &mut pixels{
if (physics.p_type == PhysicsType::Fall) | (physics.p_type == PhysicsType::Fill) { //Check Down and Down Diags for free space
if map.grid[xy_idx(position.x as i32, (position.y - 1.0) as i32)] != 1{
position.y -= 1.0;
}
}
}
}
Calling xy_idx seems to be the problem from what I can gather.