Compare commits

..

9 Commits

Author SHA1 Message Date
deadvey
40b8e7e4c7 removed swp file 2025-01-12 01:24:18 +00:00
deadvey
af9cac3a1b added insults 2025-01-12 01:22:45 +00:00
deadvey
e41e86779f removed noun from adjectives 2025-01-12 01:14:10 +00:00
deadvey
eb627344ad more insults 2025-01-12 01:12:28 +00:00
deadvey
7305b69fcb insults 2025-01-12 01:04:27 +00:00
deadvey
87af9b73a0 Added timer so you can have a highscore rustsweeper 2025-01-06 02:52:34 +00:00
deadvey
8ed27b637a Made flags ⚑ character 2025-01-05 18:49:37 +00:00
deadvey
553b9c1971 readme, added <br/> 2025-01-05 17:36:23 +00:00
deadvey
a754491f68 rustsweeper proper win conditions 2025-01-05 17:35:49 +00:00
5 changed files with 352 additions and 33 deletions

View File

@@ -38,8 +38,11 @@ Greet them as we have before.
Watch the nibblers spin and snap. Watch the nibblers spin and snap.
``` ```
# Insults
Generates an insulting phrase for someone :D
# Rubiks Cube thing (WIP) # Rubiks Cube thing (WIP)
It's just a rubiks cube in the terminal, written in rust It's just a rubiks cube in the terminal, written in rust.<br/>
![example image for rubiks](screenshots/rubiks.png) ![example image for rubiks](screenshots/rubiks.png)
# Roman Numerals (WIP) # Roman Numerals (WIP)

7
insults/Cargo.toml Normal file
View File

@@ -0,0 +1,7 @@
[package]
name = "insults"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8.5"

257
insults/insults Normal file
View File

@@ -0,0 +1,257 @@
apish
bald-pated
artless
barren-spirited
beslubbering
beast-eating
calmunating
cautelous
churlish
coldblooded
concupscible
covetous
crudy
cuckoldly
deceptious
degenerate
facinerious
fawning
finical
fusty
goastish
gorbellied
greasy
heinous
incontinent
inexecrable
insolent
lecherous
lisping
loathly
lubberly
lumpish
mammering
musty
naughty
obscene
overgorged
panderly
pestiferous
plumfy
puking
rascally
reeky
sanctimonious
sickly
solbbery
sneaping
spongy
stinking
superserviceable
thrasonical
unhandsome
unwiped
viperous
wanton
warped
witless
breast-eating
beef-witted
boiled-brained
clay-brained
dirt-rotten
dizzy-eyed
dull-brained
eye-offending
fat-kidneyed
flap-eared
foul-mouthed
half-blooded
hard-haired
hell-governed
hollow-eyed
hook-nosed
ill-tempered
knotty-pated
leaden-footed
leptus leering
lily-livered
logger-headed
lust-breathed
motley-minded
mouse-eaten
muddy-mettled
nook-shotten
one-trunk-inheriting
pale-hearted
pigeon-livered
puke-stocking
puppy-headed
rank-scented
rug-headed
rump-fed
self-glorious
senseless-obstinate
sheep-biting
shrill-tongued
snail-paced
sodden-witted
stretch-mouthed
stubborn-hard
swag-bellied
tardy-gaited
thick-eyed
three-suited
thripe-visaged
under-honest
uneducated
useless
white-livered
barmy
gormless
manky
minging
naffy
idiotic
bigotted
stupid
blue-balled
arrogant
retarded
petulent
bigoted
phscopathic
small-minded
non-linux-user
pengiunless
crude
muppet
pikey
dodgy
micro-cocked
flaccid-cocked
shit-faced
piss-taking
sloppy
aggressive
ugly
abomination
arch-villain
baggage
bed-presser
blockhead
braggart
bugbear
bull's pizzle
codpiece
capocchia
cornuto
costermonger
cot-quean
coxcomb
cozener
dissembler
dullard
dunghill
fashion-monger
fleshmonger
foot-licker
fustilarian
geck
giglet
horn-beast
horse-back-breaker
idiot-worshipper
jack-a-nape
lewdster
malignancy
malmsey-butt
measle
miscreant
mushrump
ox-head
parasite
pig-nut
pin-buttock
potato-finger
princox
purpose-chnager
quatch-buttock
rabbit-sucker
rampallian
rat-catcher
ratsbane
renegatho
scum
scut
starve-lackey
stock-fish
ticklebrain
under-skinner
villiago
cum-bucket
retard
tosser
wheevil
cretin
wanker
slag
daft-cow
arsehole
chav
git
nutter
pillock
plonker
prat
trollop
twat
knob-head
bell-end
skiver
wazzock
ninny
berk
airy-fairy
ankle-biter
arse-licker
arsemonger
chuffer
gannet
ligger
maggot
mingebag
two-dicked-dog
window
apple
cunt
dick
cock
cum-sock
phallus
pussy
bigot
capitalist
cock-sucker
child
pedo
nonce
pedophile
apple-fanboy
nerd
geek
weeb
neek
swot
goblin
crumpet
piss-taker
shit-face
sucker
loser
minger
minge
battery-eater
toenail-clipping
tik-toker

35
insults/src/main.rs Normal file
View File

@@ -0,0 +1,35 @@
use std::fs;
use std::io;
use rand::Rng;
fn main() -> io::Result<()> {
let file_contents: String = fs::read_to_string("insults")?;
let lines: Vec<&str> = file_contents.split('\n').collect();
let mut adjectives: Vec<String> = Vec::new();
let mut nouns: Vec<String> = Vec::new();
let mut noun = false; // nouns is set to true when we have reached the nouns section in the file
// so should start pushing insults to nouns instead of adjectives
let num_of_adjectives: u64 = 2;
for line in lines {
if line == "" {
noun = true;
continue;
}
if noun {
nouns.push(line.to_string());
}
else if noun != true {
adjectives.push(line.to_string());
}
}
for _x in 0..num_of_adjectives {
let random_adjective = adjectives[rand::thread_rng().gen_range(0..adjectives.len())].clone();
print!("{}, ", random_adjective);
}
let random_noun = nouns[rand::thread_rng().gen_range(0..nouns.len())].clone();
print!("{}\n", random_noun);
Ok(())
}

View File

@@ -1,11 +1,12 @@
use std::io::{stdin,stdout,Write}; use std::io::{stdin,stdout,Write};
use rand::Rng; use rand::Rng;
use colored::*; use colored::*;
use colored::Color::TrueColor;
use console::Term; use console::Term;
use std::time::Instant;
fn output_board(board: &Vec<Vec<i64>>, state: &Vec<Vec<char>>, x_hovered: i64, y_hovered: i64) { fn output_board(board: &Vec<Vec<i64>>, state: &Vec<Vec<char>>, x_hovered: i64, y_hovered: i64) {
print!("{}[2J", 27 as char); let mut output: String = "".to_string();
for y in 0..board.len() { for y in 0..board.len() {
for x in 0..board[y].len() { for x in 0..board[y].len() {
let background_color: u8; let background_color: u8;
@@ -18,52 +19,54 @@ fn output_board(board: &Vec<Vec<i64>>, state: &Vec<Vec<char>>, x_hovered: i64, y
} }
if x == x_hovered as usize && y == y_hovered as usize { if x == x_hovered as usize && y == y_hovered as usize {
print!("{}", "X".truecolor(0,0,0).on_truecolor(background_color,background_color,background_color)); output.push_str(&"X".truecolor(0,0,0).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if state[y][x] == 'u' { else if state[y][x] == 'u' {
if board[y][x] == -1 { if board[y][x] == -1 {
print!("{}","".truecolor(128,64,0).on_truecolor(background_color,background_color,background_color)); output.push_str(&"".truecolor(128,64,0).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 0 { else if board[y][x] == 0 {
print!("{}"," ".on_truecolor(background_color,background_color,background_color)); output.push_str(&" ".on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 1 { else if board[y][x] == 1 {
print!("{}", "1".truecolor(1,0,254).on_truecolor(background_color,background_color,background_color)); output.push_str(&"1".truecolor(1,0,254).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 2 { else if board[y][x] == 2 {
print!("{}", "2".truecolor(1,127,1).on_truecolor(background_color,background_color,background_color)); output.push_str(&"2".truecolor(1,127,1).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 3 { else if board[y][x] == 3 {
print!("{}", "3".truecolor(254,0,0).on_truecolor(background_color,background_color,background_color)); output.push_str(&"3".truecolor(254,0,0).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 4 { else if board[y][x] == 4 {
print!("{}", "4".truecolor(1,0,128).on_truecolor(background_color,background_color,background_color)); output.push_str(&"4".truecolor(1,0,128).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 5 { else if board[y][x] == 5 {
print!("{}", "5".truecolor(129,1,2).on_truecolor(background_color,background_color,background_color)); output.push_str(&"5".truecolor(129,1,2).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 6 { else if board[y][x] == 6 {
print!("{}", "6".truecolor(0,128,129).on_truecolor(background_color,background_color,background_color)); output.push_str(&"6".truecolor(0,128,129).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 7 { else if board[y][x] == 7 {
print!("{}", "7".truecolor(0,0,0).on_truecolor(background_color,background_color,background_color)); output.push_str(&"7".truecolor(0,0,0).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if board[y][x] == 8 { else if board[y][x] == 8 {
print!("{}", "8".truecolor(128,128,128).on_truecolor(background_color,background_color,background_color)); output.push_str(&"8".truecolor(128,128,128).on_truecolor(background_color,background_color,background_color).to_string());
} }
} }
else if state[y][x] == 'm' { else if state[y][x] == 'm' {
print!("{}", "m".truecolor(228,16,32).on_truecolor(background_color,background_color,background_color)); output.push_str(&"".truecolor(228,16,32).on_truecolor(background_color,background_color,background_color).to_string());
} }
else if state[y][x] == '?' { else if state[y][x] == '?' {
print!("{}", "?".truecolor(0,0,0).on_truecolor(background_color,background_color,background_color)); output.push_str(&"?".truecolor(0,0,0).on_truecolor(background_color,background_color,background_color).to_string());
} }
else { else {
print!("{}"," ".on_truecolor(background_color,background_color,background_color)); output.push_str(&" ".on_truecolor(background_color,background_color,background_color).to_string());
} }
} }
println!(); output.push_str("\n");
} }
print!("{}[2J", 27 as char);
println!("{}",output);
} }
fn input() -> String{ fn input() -> String{
@@ -218,15 +221,34 @@ fn uncover(board: &Vec<Vec<i64>>, state: &mut Vec<Vec<char>>, x_hovered: usize,
} }
} }
fn detect_win(state: &Vec<Vec<char>>, number_of_nails: i64, start: Instant) {
let mut number_of_covered_cells: i64 = 0;
for y in 0..state.len() {
for x in 0..state[y].len() {
if state[y][x] != 'u' {
number_of_covered_cells = number_of_covered_cells + 1;
}
}
}
if number_of_covered_cells == number_of_nails {
println!("Congratulations, you won!!!");
let end = std::time::Instant::now();
println!("In {:?}", end-start);
std::process::exit(0);
}
}
fn main() { fn main() {
let stdout = Term::buffered_stdout(); let stdout = Term::buffered_stdout();
let mut board: Vec<Vec<i64>> = Vec::new(); let mut board: Vec<Vec<i64>> = Vec::new();
let mut state: Vec<Vec<char>> = Vec::new(); // u = uncovered, c = covered, m = marked let mut state: Vec<Vec<char>> = Vec::new(); // u = uncovered, c = covered, m = marked
let height: i64 = 10; let height: i64 = 8;
let width: i64 = 30; let width: i64 = 8;
let number_of_nails: i64 = 35; let number_of_nails: i64 = 10;
//let percentage_of_cells_are_nails: i64 = 15;
//let number_of_nails: i64 = ((percentage_of_cells_are_nails / 100) as i64) * ((width * height) as i64) as i64;
let mut x_hovered: i64 = 0; let mut x_hovered: i64 = 0;
let mut y_hovered: i64 = 0; let mut y_hovered: i64 = 0;
@@ -242,6 +264,8 @@ fn main() {
//board[x as usize][y as usize] = -1; //board[x as usize][y as usize] = -1;
} }
} }
let start = std::time::Instant::now();
place_nails(&mut board, number_of_nails, width, height); place_nails(&mut board, number_of_nails, width, height);
determine_nails_in_range(&mut board); determine_nails_in_range(&mut board);
output_board(&board, &state, x_hovered, y_hovered); output_board(&board, &state, x_hovered, y_hovered);
@@ -249,10 +273,10 @@ fn main() {
'gameloop: loop { 'gameloop: loop {
if let Ok(character) = stdout.read_char() { if let Ok(character) = stdout.read_char() {
match character { match character {
'w' => if y_hovered > 0 { y_hovered -= 1 }, 'w' | 'k' => if y_hovered > 0 { y_hovered -= 1 },
'a' => if x_hovered > 0 { x_hovered -= 1}, 'a' | 'h' => if x_hovered > 0 { x_hovered -= 1},
's' => if y_hovered < height-1 { y_hovered += 1 }, 's' | 'j' => if y_hovered < height-1 { y_hovered += 1 },
'd' => if x_hovered < width-1 {x_hovered += 1}, 'd' | 'l' => if x_hovered < width-1 {x_hovered += 1},
'u' => uncover(&board, &mut state, x_hovered as usize, y_hovered as usize, &mut alive), 'u' => uncover(&board, &mut state, x_hovered as usize, y_hovered as usize, &mut alive),
'm' => { 'm' => {
if state[y_hovered as usize][x_hovered as usize] == 'm' { if state[y_hovered as usize][x_hovered as usize] == 'm' {
@@ -276,6 +300,7 @@ fn main() {
} }
if alive { if alive {
output_board(&board, &state, x_hovered, y_hovered); output_board(&board, &state, x_hovered, y_hovered);
detect_win(&state, number_of_nails, start);
} }
else if alive == false { else if alive == false {
println!("GAME OVER!\nYou got Tetanus!"); println!("GAME OVER!\nYou got Tetanus!");
@@ -293,14 +318,6 @@ fn main() {
println!(" ⠀⠀⠀⠀⠀⠀⠀⣼⣿⡟⠀⠀⠻⣿⣿⣧⠀⠀⠀⠀⠀"); println!(" ⠀⠀⠀⠀⠀⠀⠀⣼⣿⡟⠀⠀⠻⣿⣿⣧⠀⠀⠀⠀⠀");
println!(" ⠀⠀⠀⠀⠀⣠⣾⣿⠟⠁⠀⠀⠀⠘⢿⣿⣧/"); println!(" ⠀⠀⠀⠀⠀⣠⣾⣿⠟⠁⠀⠀⠀⠘⢿⣿⣧/");
println!(" ⠀⠀⠀⠀⢾⣿⠟⠁⠀⠀⠀⠀⠀⠀⠈⢻⣿⠇⠀⠀⠀"); println!(" ⠀⠀⠀⠀⢾⣿⠟⠁⠀⠀⠀⠀⠀⠀⠈⢻⣿⠇⠀⠀⠀");
println!(" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⠄⠀ ");
println!("BEWARE:⢀⡴⠀⠀⠀⠀⠀⠀⠘⠛⢿⡟⠁⠀⠀ ");
println!(" ⠀⢀⣴⢿⣇⠀⠀⠲⣶⣤⣤⡄⠀⠈⣧⠀⠀⠀ ");
println!(" ⠀⠙⢷⣄⠀⣿⠃⠀⠀⠀⠀⢻⡀⠀⠀ ");
println!(" ⠀⠀⠀⠀⠀⠀⠙⣿⣏⠀⠀⠀⠀⠀⢸⡇⠀⠀ ");
println!(" ⠀⠀⠀⣿⠛⢷⠄⠀⠀⠀⠈⢿⠀ ");
println!(" ⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ");
println!(" ⠀⠀⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀ ");
break 'gameloop; break 'gameloop;
} }
} }