This commit is contained in:
bronku 2026-02-16 00:40:47 +01:00
parent 27615d4a70
commit 05d5e55118

View file

@ -1,3 +1,5 @@
use std::{clone, ops};
use raylib::prelude::*;
const WINDOW_WIDTH: i32 = 640;
@ -14,6 +16,7 @@ impl Vec2 {
}
}
#[derive(Clone, Copy, Debug)]
struct Vec3(f64, f64, f64);
impl Vec3 {
@ -39,23 +42,34 @@ fn draw_points(d: &mut RaylibDrawHandle, points: &[Vec3]) {
}
}
fn move_by(points: &mut [Vec3], delta_pos: &Vec3) {
for point in points {
(*point).0 += delta_pos.0;
(*point).1 += delta_pos.1;
(*point).2 += delta_pos.2;
}
}
const CUBE: [Vec3; 8] = [
Vec3(-0.5, -0.5, 1.0),
Vec3(0.5, -0.5, 1.0),
Vec3(0.5, 0.5, 1.0),
Vec3(-0.5, 0.5, 1.0),
Vec3(-0.5, -0.5, 1.5),
Vec3(0.5, -0.5, 1.5),
Vec3(0.5, 0.5, 1.5),
Vec3(-0.5, 0.5, 1.5),
Vec3(-0.5, -0.5, -0.5),
Vec3(0.5, -0.5, -0.5),
Vec3(0.5, 0.5, -0.5),
Vec3(-0.5, 0.5, -0.5),
Vec3(-0.5, -0.5, 0.5),
Vec3(0.5, -0.5, 0.5),
Vec3(0.5, 0.5, 0.5),
Vec3(-0.5, 0.5, 0.5),
];
fn main() {
let (mut rl, thread) = raylib::init().size(WINDOW_WIDTH, WINDOW_HEIGHT).build();
let mut c = CUBE.clone();
move_by(&mut c, &Vec3(0.0, 0.0, 2.0));
while !rl.window_should_close() {
let mut d = rl.begin_drawing(&thread);
draw_points(&mut d, &CUBE);
draw_points(&mut d, &c);
d.clear_background(Color::WHITE);
}
}