Initial version
This commit is contained in:
parent
f44c66dd16
commit
89aa89a8f2
6
.gitignore
vendored
6
.gitignore
vendored
@ -20,3 +20,9 @@ Cargo.lock
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
|
||||
# Added by cargo
|
||||
|
||||
/target
|
||||
/local-deploy
|
||||
|
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "blr_city_name"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
macroquad = "0.4.14"
|
15
build/build-web.sh
Executable file
15
build/build-web.sh
Executable file
@ -0,0 +1,15 @@
|
||||
cargo build --target wasm32-unknown-unknown --release
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Wasm build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf ./dist && mkdir -p ./dist && mv ./target/wasm32-unknown-unknown/release/blr_city_name.wasm ./dist/blr_city_name.wasm && cp ./build/index.html ./dist/index.html
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to create create dist directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar -czvf ./sol_chess.tar.gz -C ./dist . && rm -rf ./dist && echo "Web build complete"
|
10
build/deploy-ltpd.sh
Executable file
10
build/deploy-ltpd.sh
Executable file
@ -0,0 +1,10 @@
|
||||
./build-web.sh
|
||||
|
||||
serve_root=$1
|
||||
|
||||
sudo mv ./blr_city_name.tar.gz $serve_root/blr_city_name.tar.gz && \
|
||||
sudo tar -xzvf $serve_root/blr_city_name.tar.gz -C $serve_root && \
|
||||
sudo rm $serve_root/blr_city_name.tar.gz
|
||||
|
||||
echo "Deployment complete"
|
||||
|
27
build/index.html
Normal file
27
build/index.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Solitaire Chess</title>
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
canvas {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
background: black;
|
||||
z-index: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="glcanvas" tabindex='1'></canvas>
|
||||
<script src="https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js"></script>
|
||||
<script>load("blr_city_name.wasm");</script> <!-- Your compiled WASM binary -->
|
||||
</body>
|
||||
</html>
|
27
build/local-deploy/index.html
Normal file
27
build/local-deploy/index.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Solitaire Chess</title>
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
canvas {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
background: black;
|
||||
z-index: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="glcanvas" tabindex='1'></canvas>
|
||||
<script src="https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js"></script>
|
||||
<script>load("blr_city_name.wasm");</script> <!-- Your compiled WASM binary -->
|
||||
</body>
|
||||
</html>
|
11
build/run-local.sh
Executable file
11
build/run-local.sh
Executable file
@ -0,0 +1,11 @@
|
||||
cargo build --target wasm32-unknown-unknown --release
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Wasm build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p ./local-deploy && \
|
||||
cp ./build/index.html ./local-deploy/index.html && \
|
||||
cp ./target/wasm32-unknown-unknown/release/blr_city_name.wasm ./local-deploy/blr_city_name.wasm && \
|
||||
basic-http-server ./local-deploy
|
22
src/data/mid.txt
Normal file
22
src/data/mid.txt
Normal file
@ -0,0 +1,22 @@
|
||||
gup
|
||||
appan
|
||||
gana
|
||||
shank
|
||||
a
|
||||
gup
|
||||
ara
|
||||
kalla
|
||||
gunte
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
na
|
||||
natha
|
||||
ana
|
||||
ghatta
|
||||
jara
|
||||
chena
|
20
src/data/prefix.txt
Normal file
20
src/data/prefix.txt
Normal file
@ -0,0 +1,20 @@
|
||||
Atti
|
||||
Baiya
|
||||
Benni
|
||||
Bana
|
||||
Challa
|
||||
Chikka
|
||||
Garuda
|
||||
Hala
|
||||
Jala
|
||||
Kadu
|
||||
Kunda
|
||||
Mada
|
||||
Maha
|
||||
Manju
|
||||
Nallur
|
||||
Pantha
|
||||
Seetha
|
||||
Singha
|
||||
Thala
|
||||
Yela
|
19
src/data/suffix.txt
Normal file
19
src/data/suffix.txt
Normal file
@ -0,0 +1,19 @@
|
||||
guppe
|
||||
halli
|
||||
kari
|
||||
ghatta
|
||||
pete
|
||||
kallu
|
||||
sandra
|
||||
palya
|
||||
nagar
|
||||
bharathi
|
||||
eri
|
||||
ara
|
||||
Road
|
||||
hara
|
||||
nya
|
||||
Nagar
|
||||
pura
|
||||
pur
|
||||
|
57
src/main.rs
Normal file
57
src/main.rs
Normal file
@ -0,0 +1,57 @@
|
||||
use macroquad::prelude::*;
|
||||
use macroquad::rand;
|
||||
|
||||
#[macroquad::main("MyGame")]
|
||||
async fn main() {
|
||||
let mut rand_name = String::from("Random bangalore area names");
|
||||
let mut last_update = 0.0;
|
||||
loop {
|
||||
clear_background(WHITE);
|
||||
write_name(&rand_name);
|
||||
let t = get_time();
|
||||
if t - last_update > 1.75 {
|
||||
rand_name = random_name();
|
||||
last_update = get_time();
|
||||
}
|
||||
next_frame().await
|
||||
}
|
||||
}
|
||||
|
||||
fn write_name(random_name: &str) {
|
||||
let font_size = 40.0;
|
||||
let width = screen_width();
|
||||
let height = screen_height();
|
||||
let text_dimensions = measure_text(random_name, None, font_size as u16, 1.0);
|
||||
draw_text(
|
||||
&random_name,
|
||||
(width - text_dimensions.width) / 2.,
|
||||
(height - text_dimensions.height) / 2.,
|
||||
font_size,
|
||||
DARKGRAY,
|
||||
);
|
||||
}
|
||||
|
||||
fn random_name() -> String {
|
||||
let prefix = read_segments(include_str!("./data/prefix.txt"));
|
||||
let mid = read_segments(include_str!("./data/mid.txt"));
|
||||
let suffix = read_segments(include_str!("./data/suffix.txt"));
|
||||
|
||||
format!(
|
||||
"{}{}{}",
|
||||
choose_random(&prefix),
|
||||
choose_random(&mid),
|
||||
choose_random(&suffix)
|
||||
)
|
||||
}
|
||||
|
||||
fn choose_random(prefix: &[&str]) -> String {
|
||||
let idx = rand::gen_range(0, prefix.len());
|
||||
match prefix.get(idx) {
|
||||
Some(&name) => name.to_string(),
|
||||
None => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn read_segments(file_contents: &str) -> Vec<&str> {
|
||||
file_contents.lines().collect::<Vec<_>>()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user