Changes made for out Project

This commit is contained in:
sotos
2025-12-08 09:09:48 +01:00
parent 23be1e4059
commit 508f1a46b2
16 changed files with 95 additions and 262 deletions

22
snake/Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
FROM alpine:latest
RUN apk add --no-cache nginx bash curl php82 php82-fpm php82-mysqli \
php82-pdo php82-pdo_mysql php82-gd php82-opcache php82-session \
php82-ctype php82-dom php82-mbstring php82-zlib php82-curl tar
# Verzeichnisse anlegen und Rechte setzen
RUN mkdir -p /run/nginx /var/log/nginx /var/www/html /data \
&& chmod o+rx /data \
&& chmod -R o+r /data \
&& rm -rf /var/www/html \
&& ln -s /data /var/www/html \
&& chown -R 101:101 /data
# nginx config und Startskript kopieren
COPY nginx.conf /etc/nginx/nginx.conf
COPY start.sh /start.sh
RUN chmod +x /start.sh
EXPOSE 80
CMD ["/start.sh"]

43
snake/index.html Normal file
View File

@@ -0,0 +1,43 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Snake Game</title>
<style>
body { display:flex; height:100vh; align-items:center; justify-content:center; }
canvas { border:1px solid #333; }
</style>
</head>
<body>
<canvas id="game" width="300" height="300"></canvas>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const size = 10;
let dir = 'right';
let snake = [{x:2,y:0},{x:1,y:0},{x:0,y:0}];
let food = {x:8,y:8};
document.addEventListener('keydown', e => {
if (e.key.includes('Arrow')) dir = e.key.replace('Arrow','').toLowerCase();
});
function draw(){
ctx.fillStyle = '#fff'; ctx.fillRect(0,0,300,300);
ctx.fillStyle = '#f00'; ctx.fillRect(food.x*size,food.y*size,size,size);
ctx.fillStyle = '#000';
snake.forEach(s => ctx.fillRect(s.x*size,s.y*size,size,size));
}
function update(){
const head = {...snake[0]};
if (dir==='right') head.x++;
if (dir==='left') head.x--;
if (dir==='up') head.y--;
if (dir==='down') head.y++;
if (head.x===food.x && head.y===food.y){ snake.unshift(head); food = {x:Math.floor(Math.random()*30), y:Math.floor(Math.random()*30)} }
else { snake.pop(); snake.unshift(head); }
snake[0].x = (snake[0].x+30)%30;
snake[0].y = (snake[0].y+30)%30;
}
setInterval(()=>{ update(); draw(); }, 120);
</script>
</body>
</html>

41
snake/nginx.conf Normal file
View File

@@ -0,0 +1,41 @@
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 100M;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
}