This commit is contained in:
Keanu D?lle 2022-12-28 01:37:34 +01:00
parent c51f47ca30
commit 3d5f029ef4

View File

@ -1,66 +1,97 @@
use std::io::Write;
use std::net::TcpStream;
use std::thread;
use std::sync::{Arc, RwLock};
use std::{thread, time};
use std::thread::sleep;
fn main() {
thread::spawn(|| {
let mut y_offset_org = Arc::new(RwLock::new(0));
let y_offset = Arc::clone(&y_offset_org);
thread::spawn(move || {
let mut stream = TcpStream::connect("schenklflut.de:1234").unwrap();
println!("Connected to the server!");
loop {
let yo : i32 = y_offset.read().unwrap().clone();
for x in 1..1280 {
for y in 1..50 {
for y in yo+1..yo+25 {
let command = format!("PX {} {} 5BCEFA\n", x, y);
stream.write_all(command.as_str().as_ref()).unwrap()
}
}
}
});
thread::spawn(|| {
let y_offset = Arc::clone(&y_offset_org);
thread::spawn(move|| {
let mut stream = TcpStream::connect("schenklflut.de:1234").unwrap();
println!("Connected to the server!");
loop {
let yo : i32 = y_offset.read().unwrap().clone();
for x in 1..1280 {
for y in 50..100 {
for y in yo+25..yo+50 {
let command = format!("PX {} {} F5A9B8\n", x, y);
stream.write_all(command.as_str().as_ref()).unwrap()
}
}
}
});
thread::spawn(|| {
let y_offset = Arc::clone(&y_offset_org);
thread::spawn(move|| {
let mut stream = TcpStream::connect("schenklflut.de:1234").unwrap();
println!("Connected to the server!");
loop {
let yo : i32 = y_offset.read().unwrap().clone();
for x in 1..1280 {
for y in 100..150 {
for y in yo+50..yo+75 {
let command = format!("PX {} {} FFFFFF\n", x, y);
stream.write_all(command.as_str().as_ref()).unwrap()
}
}
}
});
thread::spawn(|| {
let y_offset = Arc::clone(&y_offset_org);
thread::spawn(move|| {
let mut stream = TcpStream::connect("schenklflut.de:1234").unwrap();
println!("Connected to the server!");
loop {
let yo : i32 = y_offset.read().unwrap().clone();
for x in 1..1280 {
for y in 150..200 {
for y in yo+75..yo+100 {
let command = format!("PX {} {} F5A9B8\n", x, y);
stream.write_all(command.as_str().as_ref()).unwrap()
}
}
}
});
thread::spawn(|| {
let y_offset = Arc::clone(&y_offset_org);
thread::spawn(move|| {
let mut stream = TcpStream::connect("schenklflut.de:1234").unwrap();
println!("Connected to the server!");
loop {
let yo : i32 = y_offset.read().unwrap().clone();
for x in 1..1280 {
for y in 200..250 {
for y in yo+100..yo+125 {
let command = format!("PX {} {} 5BCEFA\n", x, y);
stream.write_all(command.as_str().as_ref()).unwrap()
}
}
}
});
thread::spawn(move|| {
loop {
let temp = y_offset_org.read().unwrap().clone();
if temp + 10 < 720 {
*y_offset_org.write().unwrap() = temp + 10;
} else {
*y_offset_org.write().unwrap() = 0;
}
println!("Set y_offset to: {}", temp + 10);
sleep(time::Duration::from_millis(100));
println!("Woke up from sleep");
}
}).join().unwrap();
}