#!/bin/bash # Simple UDP test script for the game server # Sends registration and position updates to simulate two players HOST="localhost" PORT=9999 echo "Testing game server at $HOST:$PORT" echo "" # Helper to send UDP packet send_udp() { local msg="$1" echo "Sending: $msg" echo -n "$msg" | nc -u -w1 "$HOST" "$PORT" } echo "=== Registering Player 1 ===" send_udp "REGISTER" nc -u -l 0.0.0.0 12345 # sleep 0.5 # echo "" # echo "=== Registering Player 2 ===" # send_udp "register:2" # sleep 0.5 # echo "" # echo "=== Player 1 moving around ===" # for i in {1..3}; do # x=$((100 + i * 10)) # y=$((200 + i * 5)) # send_udp "1:$x:$y" # sleep 0.3 # done # echo "" # echo "=== Player 2 moving around ===" # for i in {1..3}; do # x=$((300 - i * 10)) # y=$((150 + i * 20)) # send_udp "2:$x:$y" # sleep 0.3 # done echo "" echo "Done!"