|
@ -1,10 +1,3 @@
|
||||||
app.wasm
|
|
||||||
app.wat
|
|
||||||
png2c
|
|
||||||
penger.c
|
|
||||||
hand.c
|
|
||||||
index.html
|
|
||||||
museum.c
|
|
||||||
pengers.h
|
|
||||||
node_modules/
|
node_modules/
|
||||||
coin.c
|
out/*
|
||||||
|
!out/.gitkeep
|
6
app.c
|
@ -1,6 +1,6 @@
|
||||||
#include "pengers.h"
|
#include "out/pengers.h"
|
||||||
#include "hand.c"
|
#include "out/hand.c"
|
||||||
#include "coin.c"
|
#include "out/coin.c"
|
||||||
|
|
||||||
#define GREEN 0xff00ff00
|
#define GREEN 0xff00ff00
|
||||||
#define RED 0xff0000ff
|
#define RED 0xff0000ff
|
||||||
|
|
39
build.sh
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ "$1" == "clear" ]]; then
|
if [[ "$1" == "clear" ]]; then
|
||||||
rm -vfr museum.c pengers.h hand.c app.wasm png2c app.wat index.html
|
rm -vfr out/*
|
||||||
|
touch out/.gitkeep
|
||||||
exit
|
exit
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
@ -21,39 +22,39 @@ fi
|
||||||
|
|
||||||
#set -xe
|
#set -xe
|
||||||
|
|
||||||
clang png2c.c -o png2c -lm
|
clang png2c.c -o out/png2c -lm
|
||||||
mkdir -p museum.c
|
mkdir -p out/museum.c
|
||||||
rm -f museum.c/*
|
rm -f out/museum.c/*
|
||||||
|
|
||||||
pengers_html=$'\n'
|
pengers_html=$'\n'
|
||||||
pengers_include=$'\n'
|
pengers_include=$'\n'
|
||||||
id=0
|
id=0
|
||||||
for p in $(ls museum); do
|
for p in $(ls static/museum/); do
|
||||||
file=$(echo $p | sed "s/\.png$//g")
|
file=$(echo $p | sed "s/\.png$//g")
|
||||||
./png2c "museum/"$p $id > museum.c/$file.c
|
./out/png2c "static/museum/"$p $id > out/museum.c/$file.c
|
||||||
pengers_html+=$' <img src="museum/'$p'" class="penger-img" penger-id="'$id'"></img>\n'
|
pengers_html+=$' <img src="static/museum/'$p'" class="penger-img" penger-id="'$id'"></img>\n'
|
||||||
pengers_include+='#include "museum.c/'$file$'.c"\n'
|
pengers_include+='#include "museum.c/'$file$'.c"\n'
|
||||||
((id=id+1))
|
((id=id+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "int pengers_height[$id];" > pengers.h
|
echo "int pengers_height[$id];" > out/pengers.h
|
||||||
echo "int pengers_width[$id];" >> pengers.h
|
echo "int pengers_width[$id];" >> out/pengers.h
|
||||||
echo "unsigned int *pengers_img[$id];" >> pengers.h
|
echo "unsigned int *pengers_img[$id];" >> out/pengers.h
|
||||||
echo "$pengers_include" >> pengers.h
|
echo "$pengers_include" >> out/pengers.h
|
||||||
echo "void pengers_init(void) {" >> pengers.h
|
echo "void pengers_init(void) {" >> out/pengers.h
|
||||||
((id=id-1))
|
((id=id-1))
|
||||||
for i in $(seq 0 $id); do
|
for i in $(seq 0 $id); do
|
||||||
echo " penger_init_$i();" >> pengers.h;
|
echo " penger_init_$i();" >> out/pengers.h;
|
||||||
done
|
done
|
||||||
echo "}" >> pengers.h
|
echo "}" >> out/pengers.h
|
||||||
|
|
||||||
echo -e "$pengers_html" > pengers_image.html.temp
|
echo -e "$pengers_html" > pengers_image.html.temp
|
||||||
sed -e '/<!-- penger images src -->/rpengers_image.html.temp' index.html.template > index.html
|
sed -e '/<!-- penger images src -->/rpengers_image.html.temp' templates/index.html.template > out/index.html
|
||||||
rm pengers_image.html.temp
|
rm pengers_image.html.temp
|
||||||
|
|
||||||
./png2c "hand.png" > hand.c
|
./out/png2c "static/assets/hand.png" > out/hand.c
|
||||||
./png2c "coin.png" > coin.c
|
./out/png2c "static/assets/coin.png" > out/coin.c
|
||||||
|
|
||||||
clang -O3 --target=wasm32 -fno-builtin -nostdlib --no-standard-libraries -Wl,--no-entry $export_cmd -Wl,--allow-undefined -o $f.wasm $a
|
clang -O3 --target=wasm32 -fno-builtin -nostdlib --no-standard-libraries -Wl,--no-entry $export_cmd -Wl,--allow-undefined -o out/$f.wasm $a
|
||||||
|
|
||||||
wasm2wat $f.wasm > $f.wat
|
wasm2wat out/$f.wasm > out/$f.wat
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
penger-party:
|
penger-party:
|
||||||
container_name: "penger-party"
|
container_name: "penger-party"
|
||||||
|
|
2
load.js
|
@ -175,7 +175,7 @@ function make_environment(...envs) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { instance } = await WebAssembly.instantiateStreaming(fetch("./app.wasm"), {
|
const { instance } = await WebAssembly.instantiateStreaming(fetch("./out/app.wasm"), {
|
||||||
"env": make_environment({
|
"env": make_environment({
|
||||||
// importer les fonctions dans le wasm
|
// importer les fonctions dans le wasm
|
||||||
'random': Math.random,
|
'random': Math.random,
|
||||||
|
|
20
png2c.c
|
@ -20,11 +20,23 @@ int main(int argc, const char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 3) { // no id provided
|
if (argc < 3) { // no id provided
|
||||||
int file_name_len = strlen(img_path) - strlen(".png");
|
char *last_slash = strrchr(img_path, '/');
|
||||||
|
char extracted[50];
|
||||||
|
|
||||||
printf("int %.*s_height = %d;\n", file_name_len, img_path, height);
|
if (last_slash != NULL) {
|
||||||
printf("int %.*s_width = %d;\n", file_name_len, img_path, width);
|
// Extract the part after the last '/'
|
||||||
printf("unsigned int %.*s_img[%d][%d] = {\n", file_name_len, img_path, height, width);
|
strcpy(extracted, last_slash + 1);
|
||||||
|
|
||||||
|
// Remove the '.png' extension
|
||||||
|
char *dot = strrchr(extracted, '.');
|
||||||
|
if (dot != NULL) {
|
||||||
|
*dot = '\0'; // Null-terminate the string at the '.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("int %s_height = %d;\n", extracted, height);
|
||||||
|
printf("int %s_width = %d;\n", extracted, width);
|
||||||
|
printf("unsigned int %s_img[%d][%d] = {\n", extracted, height, width);
|
||||||
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
|
17
server.js
|
@ -46,6 +46,7 @@ function send_new_map()
|
||||||
});
|
});
|
||||||
setTimeout(send_new_map, map_every_ms);
|
setTimeout(send_new_map, map_every_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(send_new_map, map_every_ms);
|
setTimeout(send_new_map, map_every_ms);
|
||||||
function send_map(socket)
|
function send_map(socket)
|
||||||
{
|
{
|
||||||
|
@ -55,14 +56,14 @@ function send_map(socket)
|
||||||
const requestListener = function (req, res) {
|
const requestListener = function (req, res) {
|
||||||
var url = req.url;
|
var url = req.url;
|
||||||
|
|
||||||
if (url == "/" || url == "/index.html") {
|
if (url == "/") {
|
||||||
res.setHeader("Content-Type", "text/html");
|
res.setHeader("Content-Type", "text/html");
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(fs.readFileSync("./index.html"));
|
res.end(fs.readFileSync("./out/index.html"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url == "/app.wasm") {
|
if (url == "/out/app.wasm") {
|
||||||
res.setHeader("Content-Type", "application/wasm");
|
res.setHeader("Content-Type", "application/wasm");
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(fs.readFileSync("." + url));
|
res.end(fs.readFileSync("." + url));
|
||||||
|
@ -76,12 +77,20 @@ const requestListener = function (req, res) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.startsWith("/museum/")) {
|
if (url.startsWith("/static/museum/")) {
|
||||||
res.setHeader("Content-Type", "image/png");
|
res.setHeader("Content-Type", "image/png");
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(fs.readFileSync("." + url));
|
res.end(fs.readFileSync("." + url));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url.startsWith("/static/css/")) {
|
||||||
|
res.setHeader("Content-Type", "text/css");
|
||||||
|
res.writeHead(200);
|
||||||
|
res.end(fs.readFileSync("." + url));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (url == "/create-map") {
|
if (url == "/create-map") {
|
||||||
res.setHeader("Content-Type", "text/html");
|
res.setHeader("Content-Type", "text/html");
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
|
|
Before Width: | Height: | Size: 474 B After Width: | Height: | Size: 474 B |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
@ -0,0 +1,55 @@
|
||||||
|
#demo-canvas:hover {
|
||||||
|
cursor: none
|
||||||
|
}
|
||||||
|
.penger-img {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
image-rendering: pixelated;
|
||||||
|
object-fit: contain;
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
.penger-img:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
.players-img {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 3.5em;
|
||||||
|
margin: 0px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-family: "Comic Sans MS", "Comic Sans", cursive;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
margin-top: 7px;
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.info > * {
|
||||||
|
margin-right: 1rem;
|
||||||
|
}
|
||||||
|
#chat {
|
||||||
|
width: 69%;
|
||||||
|
}
|
||||||
|
@media screen and (min-width: calc(800px + calc(64px * 4))) {
|
||||||
|
#css-bullshit {
|
||||||
|
content: "";
|
||||||
|
display: table;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
#left {
|
||||||
|
float: left;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
#right {
|
||||||
|
float: right;
|
||||||
|
width: calc(100% - 800px - 25px);
|
||||||
|
position: absolute;
|
||||||
|
right: 0px;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
.rainbow{
|
||||||
|
animation: rainbow 2.5s linear;
|
||||||
|
animation-iteration-count: infinite;
|
||||||
|
}
|
||||||
|
@keyframes rainbow{
|
||||||
|
100%,0%{
|
||||||
|
color: rgb(255,0,0);
|
||||||
|
}
|
||||||
|
8%{
|
||||||
|
color: rgb(255,127,0);
|
||||||
|
}
|
||||||
|
16%{
|
||||||
|
color: rgb(255,255,0);
|
||||||
|
}
|
||||||
|
25%{
|
||||||
|
color: rgb(127,255,0);
|
||||||
|
}
|
||||||
|
33%{
|
||||||
|
color: rgb(0,255,0);
|
||||||
|
}
|
||||||
|
41%{
|
||||||
|
color: rgb(0,255,127);
|
||||||
|
}
|
||||||
|
50%{
|
||||||
|
color: rgb(0,255,255);
|
||||||
|
}
|
||||||
|
58%{
|
||||||
|
color: rgb(0,127,255);
|
||||||
|
}
|
||||||
|
66%{
|
||||||
|
color: rgb(0,0,255);
|
||||||
|
}
|
||||||
|
75%{
|
||||||
|
color: rgb(127,0,255);
|
||||||
|
}
|
||||||
|
83%{
|
||||||
|
color: rgb(255,0,255);
|
||||||
|
}
|
||||||
|
91%{
|
||||||
|
color: rgb(255,0,127);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 728 B After Width: | Height: | Size: 728 B |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 550 B |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 500 B After Width: | Height: | Size: 500 B |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |