Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
8 changed files with 273 additions and 497 deletions
|
|
@ -105,60 +105,6 @@ jobs:
|
||||||
echo "New version: $NEW_VERSION"
|
echo "New version: $NEW_VERSION"
|
||||||
echo "Current VERSION file: $(cat VERSION 2>/dev/null || echo 'not found')"
|
echo "Current VERSION file: $(cat VERSION 2>/dev/null || echo 'not found')"
|
||||||
|
|
||||||
- name: Update Version Files
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
|
||||||
TAG="${{ steps.version.outputs.tag }}"
|
|
||||||
|
|
||||||
echo "📝 Updating version files to: $VERSION"
|
|
||||||
|
|
||||||
# Configure git
|
|
||||||
git config user.name "forgebot"
|
|
||||||
git config user.email "forgebot@forgejo.io"
|
|
||||||
|
|
||||||
# Fetch latest changes to avoid conflicts
|
|
||||||
git fetch origin main || echo "Fetch completed or already up to date"
|
|
||||||
git checkout main || echo "Already on main"
|
|
||||||
|
|
||||||
# Update VERSION file
|
|
||||||
echo "$VERSION" > VERSION
|
|
||||||
|
|
||||||
# Update portainer.yml with new version
|
|
||||||
sed -i "s|\(image: git.jusemon.com/jusemon/threejs-test:\)[0-9.]*|\1$VERSION|" portainer.yml
|
|
||||||
|
|
||||||
# Verify the updates
|
|
||||||
if grep -q "^$VERSION$" VERSION && grep -q "image: git.jusemon.com/jusemon/threejs-test:$VERSION" portainer.yml; then
|
|
||||||
echo "✅ Successfully updated VERSION and portainer.yml to $VERSION"
|
|
||||||
else
|
|
||||||
echo "❌ Failed to update version files"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if there are changes to commit
|
|
||||||
if git diff --quiet VERSION portainer.yml; then
|
|
||||||
echo "⚠️ No changes to commit (files already up to date)"
|
|
||||||
echo "VERSION_COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
|
||||||
else
|
|
||||||
# Stage and commit with [skip ci] to prevent infinite loop
|
|
||||||
# Note: Forgejo Actions should respect [skip ci] in commit messages
|
|
||||||
git add VERSION portainer.yml
|
|
||||||
git commit -m "chore: update version to $VERSION [skip ci]" || {
|
|
||||||
echo "⚠️ Commit failed (may already be committed)"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Push to main branch (remote should already be configured with token)
|
|
||||||
git push origin main || {
|
|
||||||
echo "⚠️ Push failed (check token permissions)"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the commit hash of the version update commit
|
|
||||||
VERSION_COMMIT_HASH=$(git rev-parse HEAD)
|
|
||||||
echo "VERSION_COMMIT_HASH=$VERSION_COMMIT_HASH" >> $GITHUB_ENV
|
|
||||||
echo "✅ Successfully committed and pushed version update to $VERSION (commit: $VERSION_COMMIT_HASH)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build Docker Image
|
- name: Build Docker Image
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
|
@ -182,24 +128,20 @@ jobs:
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
TAG="${{ steps.version.outputs.tag }}"
|
TAG="${{ steps.version.outputs.tag }}"
|
||||||
IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:$VERSION"
|
IMAGE_NAME="git.jusemon.com/jusemon/threejs-test:$VERSION"
|
||||||
# Use the version update commit hash (which has the correct version in files)
|
COMMIT_HASH=$(git rev-parse HEAD)
|
||||||
COMMIT_HASH="${VERSION_COMMIT_HASH:-$(git rev-parse HEAD)}"
|
COMMIT_SHORT=$(git rev-parse --short HEAD)
|
||||||
COMMIT_SHORT=$(git rev-parse --short "$COMMIT_HASH")
|
|
||||||
BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||||
|
|
||||||
# Get commits since last tag, excluding version update commits
|
# Get commits since last tag
|
||||||
LATEST_TAG=$(git describe --tags --match 'v*.*.*' --abbrev=0 2>/dev/null || echo "")
|
LATEST_TAG=$(git describe --tags --match 'v*.*.*' --abbrev=0 2>/dev/null || echo "")
|
||||||
if [[ -n "$LATEST_TAG" ]]; then
|
if [[ -n "$LATEST_TAG" ]]; then
|
||||||
# Get commits excluding "chore: update version" commits (from previous releases)
|
COMMITS=$(git log ${LATEST_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
|
||||||
# We want commits from the tag to the version update commit (exclusive of the version commit itself)
|
|
||||||
COMMITS=$(git log ${LATEST_TAG}..${COMMIT_HASH}^ --pretty=format:"- %s (%h)" --no-merges | grep -v "chore: update version")
|
|
||||||
else
|
else
|
||||||
# Get commits excluding version update commits
|
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges -10)
|
||||||
COMMITS=$(git log ${COMMIT_HASH}^ --pretty=format:"- %s (%h)" --no-merges -10 | grep -v "chore: update version")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get author of the version update commit (or HEAD if no version commit)
|
# Get author of the commit
|
||||||
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an <%ae>" "$COMMIT_HASH")
|
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an <%ae>")
|
||||||
|
|
||||||
# Read template and replace placeholders
|
# Read template and replace placeholders
|
||||||
TEMPLATE_FILE=".forgejo/release-template.md"
|
TEMPLATE_FILE=".forgejo/release-template.md"
|
||||||
|
|
@ -243,21 +185,67 @@ jobs:
|
||||||
git config user.name "forgejo-actions"
|
git config user.name "forgejo-actions"
|
||||||
git config user.email "forgejo-actions@forgejo.io"
|
git config user.email "forgejo-actions@forgejo.io"
|
||||||
TAG="${{ steps.version.outputs.tag }}"
|
TAG="${{ steps.version.outputs.tag }}"
|
||||||
# Use the version update commit hash (which has the correct version in files)
|
|
||||||
VERSION_COMMIT="${VERSION_COMMIT_HASH:-$(git rev-parse HEAD)}"
|
|
||||||
|
|
||||||
# Check if tag already exists
|
# Check if tag already exists
|
||||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||||
echo "Tag $TAG already exists, skipping tag creation"
|
echo "Tag $TAG already exists, skipping tag creation"
|
||||||
echo "TAG_CREATED=false" >> $GITHUB_ENV
|
echo "TAG_CREATED=false" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
# Create tag pointing to the version update commit (which has correct VERSION file)
|
git tag -a "$TAG" -F /tmp/release_message.txt
|
||||||
git tag -a "$TAG" -F /tmp/release_message.txt "$VERSION_COMMIT"
|
|
||||||
git push origin "$TAG"
|
git push origin "$TAG"
|
||||||
echo "Created tag $TAG pointing to version update commit $VERSION_COMMIT with detailed release notes"
|
echo "Created tag $TAG with detailed release notes"
|
||||||
echo "TAG_CREATED=true" >> $GITHUB_ENV
|
echo "TAG_CREATED=true" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Update Version Files
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
TAG="${{ steps.version.outputs.tag }}"
|
||||||
|
|
||||||
|
echo "📝 Updating version files to: $VERSION"
|
||||||
|
|
||||||
|
# Configure git
|
||||||
|
git config user.name "forgebot"
|
||||||
|
git config user.email "forgebot@forgejo.io"
|
||||||
|
|
||||||
|
# Fetch latest changes to avoid conflicts
|
||||||
|
git fetch origin main || echo "Fetch completed or already up to date"
|
||||||
|
git checkout main || echo "Already on main"
|
||||||
|
|
||||||
|
# Update VERSION file
|
||||||
|
echo "$VERSION" > VERSION
|
||||||
|
|
||||||
|
# Update portainer.yml with new version
|
||||||
|
sed -i "s|\(image: git.jusemon.com/jusemon/threejs-test:\)[0-9.]*|\1$VERSION|" portainer.yml
|
||||||
|
|
||||||
|
# Verify the updates
|
||||||
|
if grep -q "^$VERSION$" VERSION && grep -q "image: git.jusemon.com/jusemon/threejs-test:$VERSION" portainer.yml; then
|
||||||
|
echo "✅ Successfully updated VERSION and portainer.yml to $VERSION"
|
||||||
|
else
|
||||||
|
echo "❌ Failed to update version files"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if there are changes to commit
|
||||||
|
if git diff --quiet VERSION portainer.yml; then
|
||||||
|
echo "⚠️ No changes to commit (files already up to date)"
|
||||||
|
else
|
||||||
|
# Stage and commit with [skip ci] to prevent infinite loop
|
||||||
|
# Note: Forgejo Actions should respect [skip ci] in commit messages
|
||||||
|
git add VERSION portainer.yml
|
||||||
|
git commit -m "chore: update version to $VERSION [skip ci]" || {
|
||||||
|
echo "⚠️ Commit failed (may already be committed)"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Push to main branch (remote should already be configured with token)
|
||||||
|
git push origin main || {
|
||||||
|
echo "⚠️ Push failed (check token permissions)"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "✅ Successfully committed and pushed version update to $VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Job Summary
|
- name: Job Summary
|
||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,6 @@ RUN printf '{"version":"%s","buildDate":"%s"}\n' "${VERSION}" "${BUILD_DATE}" >
|
||||||
COPY index.html /usr/share/nginx/html/
|
COPY index.html /usr/share/nginx/html/
|
||||||
COPY src/ /usr/share/nginx/html/src/
|
COPY src/ /usr/share/nginx/html/src/
|
||||||
|
|
||||||
# Copy and run cache busting script (bash/sed - no external dependencies needed)
|
|
||||||
COPY build-cache-bust.sh /tmp/build-cache-bust.sh
|
|
||||||
RUN chmod +x /tmp/build-cache-bust.sh && \
|
|
||||||
/tmp/build-cache-bust.sh "${VERSION}" /usr/share/nginx/html
|
|
||||||
|
|
||||||
# Copy nginx configuration
|
# Copy nginx configuration
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
|
|
||||||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
||||||
1.0.4
|
0.5.0
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Simple cache busting script - adds version query params to all JS imports
|
|
||||||
# Only runs during Docker build, not during local development
|
|
||||||
# This keeps development simple (no tools needed) while ensuring production cache busting
|
|
||||||
|
|
||||||
VERSION="${1:-dev}"
|
|
||||||
SRC_DIR="${2:-/usr/share/nginx/html}"
|
|
||||||
|
|
||||||
echo "Adding cache busting (v=${VERSION}) to JS imports in ${SRC_DIR}/src..."
|
|
||||||
|
|
||||||
# Find all JS files and add version query param to relative imports
|
|
||||||
find "$SRC_DIR/src" -type f -name "*.js" | while read -r file; do
|
|
||||||
# Skip if file doesn't exist
|
|
||||||
[ ! -f "$file" ] && continue
|
|
||||||
|
|
||||||
# Process file with sed to add version query params
|
|
||||||
# Pattern: from './path.js' or from "../path.js" or import('./path.js')
|
|
||||||
# Only match relative imports (./ or ../) ending in .js
|
|
||||||
# Skip if already has query params (contains ?)
|
|
||||||
|
|
||||||
# Handle single quote imports: from './path.js'
|
|
||||||
sed -i.bak \
|
|
||||||
-e "s|from '\\(\\.[./][^']*\\.js\\)'|from '\\1?v=${VERSION}'|g" \
|
|
||||||
-e "s|from '\\(\\.[./][^']*\\.js\\)?[^']*'|from '\\1?v=${VERSION}'|g" \
|
|
||||||
"$file"
|
|
||||||
|
|
||||||
# Handle double quote imports: from "./path.js"
|
|
||||||
sed -i.bak \
|
|
||||||
-e "s|from \"\\(\\.[./][^\"]*\\.js\\)\"|from \"\\1?v=${VERSION}\"|g" \
|
|
||||||
-e "s|from \"\\(\\.[./][^\"]*\\.js\\)?[^\"]*\"|from \"\\1?v=${VERSION}\"|g" \
|
|
||||||
"$file"
|
|
||||||
|
|
||||||
# Handle dynamic imports: import('./path.js')
|
|
||||||
sed -i.bak \
|
|
||||||
-e "s|import('\\(\\.[./][^']*\\.js\\)')|import('\\1?v=${VERSION}')|g" \
|
|
||||||
-e "s|import('\\(\\.[./][^']*\\.js\\)?[^']*')|import('\\1?v=${VERSION}')|g" \
|
|
||||||
-e "s|import(\"\\(\\.[./][^\"]*\\.js\\)\")|import(\"\\1?v=${VERSION}\")|g" \
|
|
||||||
-e "s|import(\"\\(\\.[./][^\"]*\\.js\\)?[^\"]*\")|import(\"\\1?v=${VERSION}\")|g" \
|
|
||||||
"$file"
|
|
||||||
|
|
||||||
# Remove backup file
|
|
||||||
rm -f "${file}.bak"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Cache busting complete! All JS imports now include ?v=${VERSION}"
|
|
||||||
|
|
||||||
519
index.html
519
index.html
|
|
@ -1,346 +1,241 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>3D Coin Collector Game</title>
|
<title>3D Coin Collector Game</title>
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
|
||||||
body {
|
|
||||||
overflow: hidden;
|
|
||||||
font-family: "Arial", sans-serif;
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
}
|
|
||||||
#ui {
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
left: 20px;
|
|
||||||
color: white;
|
|
||||||
font-size: 24px;
|
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
#combo {
|
|
||||||
position: absolute;
|
|
||||||
top: 100px;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
color: #ffd700;
|
|
||||||
font-size: 32px;
|
|
||||||
font-weight: bold;
|
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
|
|
||||||
z-index: 100;
|
|
||||||
display: none;
|
|
||||||
animation: comboPulse 0.5s ease-in-out;
|
|
||||||
}
|
|
||||||
@keyframes comboPulse {
|
|
||||||
0%,
|
|
||||||
100% {
|
|
||||||
transform: translateX(-50%) scale(1);
|
|
||||||
}
|
}
|
||||||
50% {
|
body {
|
||||||
transform: translateX(-50%) scale(1.2);
|
overflow: hidden;
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
}
|
}
|
||||||
}
|
#ui {
|
||||||
#startMenu,
|
position: absolute;
|
||||||
#pauseMenu,
|
top: 20px;
|
||||||
#gameOver {
|
left: 20px;
|
||||||
position: absolute;
|
color: white;
|
||||||
top: 50%;
|
font-size: 24px;
|
||||||
left: 50%;
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||||
transform: translate(-50%, -50%);
|
z-index: 100;
|
||||||
background: rgba(0, 0, 0, 0.9);
|
}
|
||||||
padding: 50px;
|
#combo {
|
||||||
border-radius: 20px;
|
position: absolute;
|
||||||
text-align: center;
|
top: 100px;
|
||||||
color: white;
|
left: 50%;
|
||||||
z-index: 200;
|
transform: translateX(-50%);
|
||||||
min-width: 400px;
|
color: #FFD700;
|
||||||
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
|
font-size: 32px;
|
||||||
}
|
font-weight: bold;
|
||||||
#startMenu {
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
|
||||||
display: block;
|
z-index: 100;
|
||||||
}
|
display: none;
|
||||||
#pauseMenu,
|
animation: comboPulse 0.5s ease-in-out;
|
||||||
#gameOver {
|
}
|
||||||
display: none;
|
@keyframes comboPulse {
|
||||||
}
|
0%, 100% { transform: translateX(-50%) scale(1); }
|
||||||
#startMenu h1,
|
50% { transform: translateX(-50%) scale(1.2); }
|
||||||
#pauseMenu h1,
|
}
|
||||||
#gameOver h1 {
|
#startMenu, #pauseMenu, #gameOver {
|
||||||
font-size: 48px;
|
position: absolute;
|
||||||
margin-bottom: 20px;
|
top: 50%;
|
||||||
color: #4caf50;
|
left: 50%;
|
||||||
}
|
transform: translate(-50%, -50%);
|
||||||
#pauseMenu h1 {
|
background: rgba(0,0,0,0.9);
|
||||||
color: #ffa500;
|
padding: 50px;
|
||||||
}
|
border-radius: 20px;
|
||||||
#gameOver h1 {
|
text-align: center;
|
||||||
color: #ff6b6b;
|
color: white;
|
||||||
}
|
z-index: 200;
|
||||||
#startMenu p,
|
min-width: 400px;
|
||||||
#pauseMenu p,
|
box-shadow: 0 10px 40px rgba(0,0,0,0.5);
|
||||||
#gameOver p {
|
}
|
||||||
font-size: 20px;
|
#startMenu {
|
||||||
margin-bottom: 30px;
|
display: block;
|
||||||
line-height: 1.6;
|
}
|
||||||
}
|
#pauseMenu, #gameOver {
|
||||||
#startMenu button,
|
display: none;
|
||||||
#pauseMenu button,
|
}
|
||||||
#restartBtn {
|
#startMenu h1, #pauseMenu h1, #gameOver h1 {
|
||||||
background: #4caf50;
|
font-size: 48px;
|
||||||
border: none;
|
margin-bottom: 20px;
|
||||||
color: white;
|
color: #4CAF50;
|
||||||
padding: 15px 40px;
|
}
|
||||||
font-size: 20px;
|
#pauseMenu h1 {
|
||||||
border-radius: 10px;
|
color: #FFA500;
|
||||||
cursor: pointer;
|
}
|
||||||
transition: all 0.3s;
|
#gameOver h1 {
|
||||||
margin: 10px;
|
color: #ff6b6b;
|
||||||
}
|
}
|
||||||
#startMenu button:hover,
|
#startMenu p, #pauseMenu p, #gameOver p {
|
||||||
#pauseMenu button:hover,
|
font-size: 20px;
|
||||||
#restartBtn:hover {
|
margin-bottom: 30px;
|
||||||
background: #45a049;
|
line-height: 1.6;
|
||||||
transform: scale(1.1);
|
}
|
||||||
}
|
#startMenu button, #pauseMenu button, #restartBtn {
|
||||||
#pauseMenu button.resumeBtn {
|
background: #4CAF50;
|
||||||
background: #2196f3;
|
border: none;
|
||||||
}
|
color: white;
|
||||||
#pauseMenu button.resumeBtn:hover {
|
padding: 15px 40px;
|
||||||
background: #1976d2;
|
font-size: 20px;
|
||||||
}
|
border-radius: 10px;
|
||||||
#instructions {
|
cursor: pointer;
|
||||||
position: absolute;
|
transition: all 0.3s;
|
||||||
bottom: 20px;
|
margin: 10px;
|
||||||
left: 50%;
|
}
|
||||||
transform: translateX(-50%);
|
#startMenu button:hover, #pauseMenu button:hover, #restartBtn:hover {
|
||||||
color: white;
|
background: #45a049;
|
||||||
text-align: center;
|
transform: scale(1.1);
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
|
}
|
||||||
}
|
#pauseMenu button.resumeBtn {
|
||||||
#version {
|
background: #2196F3;
|
||||||
position: absolute;
|
}
|
||||||
top: 20px;
|
#pauseMenu button.resumeBtn:hover {
|
||||||
right: 20px;
|
background: #1976D2;
|
||||||
color: rgba(255, 255, 255, 0.7);
|
|
||||||
font-size: 14px;
|
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
|
|
||||||
z-index: 100;
|
|
||||||
font-family: "Courier New", monospace;
|
|
||||||
}
|
|
||||||
#soundStatus {
|
|
||||||
display: none;
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 90px;
|
|
||||||
background: rgba(0, 0, 0, 0.7);
|
|
||||||
border: 2px solid white;
|
|
||||||
color: white;
|
|
||||||
font-size: 24px;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-radius: 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
z-index: 100;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
transition: all 0.2s;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
#soundStatus:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.9);
|
|
||||||
transform: scale(1.1);
|
|
||||||
}
|
|
||||||
#soundStatus:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
}
|
|
||||||
#pauseBtn {
|
|
||||||
display: none;
|
|
||||||
position: absolute;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
background: rgba(0, 0, 0, 0.7);
|
|
||||||
border: 2px solid white;
|
|
||||||
color: white;
|
|
||||||
font-size: 24px;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-radius: 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
z-index: 100;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
transition: all 0.2s;
|
|
||||||
}
|
|
||||||
#pauseBtn:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.9);
|
|
||||||
transform: scale(1.1);
|
|
||||||
}
|
|
||||||
#pauseBtn:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
}
|
|
||||||
/* Show buttons when game is active */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
#pauseBtn {
|
|
||||||
display: block;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#perfMonitor {
|
|
||||||
position: absolute;
|
|
||||||
top: 60px;
|
|
||||||
right: 20px;
|
|
||||||
background: rgba(0, 0, 0, 0.7);
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
color: #00ff00;
|
|
||||||
font-size: 12px;
|
|
||||||
font-family: "Courier New", monospace;
|
|
||||||
z-index: 100;
|
|
||||||
display: none;
|
|
||||||
min-width: 120px;
|
|
||||||
}
|
|
||||||
#perfMonitor.visible {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
#perfMonitor .label {
|
|
||||||
color: #888;
|
|
||||||
}
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
#instructions {
|
#instructions {
|
||||||
font-size: 14px;
|
position: absolute;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||||
}
|
}
|
||||||
#version {
|
#version {
|
||||||
font-size: 12px;
|
position: absolute;
|
||||||
top: 10px;
|
top: 20px;
|
||||||
right: 10px;
|
right: 20px;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
font-size: 14px;
|
||||||
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
|
||||||
|
z-index: 100;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
}
|
}
|
||||||
#soundStatus {
|
#soundStatus {
|
||||||
top: 10px;
|
position: absolute;
|
||||||
right: 80px;
|
top: 20px;
|
||||||
font-size: 20px;
|
right: 100px;
|
||||||
padding: 8px 12px;
|
font-size: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
z-index: 100;
|
||||||
|
user-select: none;
|
||||||
|
opacity: 0.8;
|
||||||
|
transition: opacity 0.2s;
|
||||||
}
|
}
|
||||||
#pauseBtn {
|
#soundStatus:hover {
|
||||||
top: 10px;
|
opacity: 1;
|
||||||
right: 10px;
|
|
||||||
font-size: 20px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
}
|
||||||
#perfMonitor {
|
#perfMonitor {
|
||||||
top: 40px;
|
position: absolute;
|
||||||
right: 10px;
|
top: 60px;
|
||||||
font-size: 11px;
|
right: 20px;
|
||||||
|
background: rgba(0, 0, 0, 0.7);
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
color: #00ff00;
|
||||||
|
font-size: 12px;
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
z-index: 100;
|
||||||
|
display: none;
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
#perfMonitor.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
#perfMonitor .label {
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
#instructions {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
#version {
|
||||||
|
font-size: 12px;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
#soundStatus {
|
||||||
|
top: 10px;
|
||||||
|
right: 60px;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
#perfMonitor {
|
||||||
|
top: 40px;
|
||||||
|
right: 10px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="ui" style="display: none">
|
<div id="ui" style="display: none;">
|
||||||
<div>Score: <span id="score">0</span></div>
|
<div>Score: <span id="score">0</span></div>
|
||||||
<div>High Score: <span id="highScore">0</span></div>
|
<div>High Score: <span id="highScore">0</span></div>
|
||||||
<div>Health: <span id="health">100</span></div>
|
<div>Health: <span id="health">100</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="combo">1x COMBO!</div>
|
<div id="combo">1x COMBO!</div>
|
||||||
|
|
||||||
<div id="version">v<span id="versionNumber">-</span></div>
|
<div id="version">v<span id="versionNumber">-</span></div>
|
||||||
|
|
||||||
<div id="soundStatus" title="Sound ON (Press M to mute)">🔊</div>
|
<div id="soundStatus" title="Sound ON (Press M to mute)">🔊</div>
|
||||||
|
|
||||||
<button id="pauseBtn" title="Pause Game">⏸️</button>
|
|
||||||
|
|
||||||
<div id="perfMonitor">
|
<div id="perfMonitor">
|
||||||
<div><span class="label">FPS:</span> <span id="fps">60</span></div>
|
<div><span class="label">FPS:</span> <span id="fps">60</span></div>
|
||||||
<div>
|
<div><span class="label">Frame:</span> <span id="frameTime">16.7</span>ms</div>
|
||||||
<span class="label">Frame:</span> <span id="frameTime">16.7</span>ms
|
<div><span class="label">Entities:</span> <span id="entityCount">0</span></div>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span class="label">Entities:</span> <span id="entityCount">0</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="startMenu">
|
<div id="startMenu">
|
||||||
<h1>🎮 Coin Collector</h1>
|
<h1>🎮 Coin Collector</h1>
|
||||||
<p>Collect coins, avoid obstacles, and survive as long as you can!</p>
|
<p>Collect coins, avoid obstacles, and survive as long as you can!</p>
|
||||||
<p style="font-size: 16px; opacity: 0.8; margin-top: 20px">
|
<p style="font-size: 16px; opacity: 0.8; margin-top: 20px;">
|
||||||
<strong>Controls:</strong><br />
|
<strong>Controls:</strong><br>
|
||||||
WASD or Arrow Keys to move<br />
|
WASD or Arrow Keys to move<br>
|
||||||
Touch and drag (mobile)<br />
|
Touch and drag (mobile)<br>
|
||||||
ESC or P to pause
|
ESC or P to pause
|
||||||
</p>
|
</p>
|
||||||
<button id="startBtn">Start Game</button>
|
<button id="startBtn">Start Game</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="pauseMenu">
|
<div id="pauseMenu">
|
||||||
<h1>⏸️ Paused</h1>
|
<h1>⏸️ Paused</h1>
|
||||||
<p>Game is paused</p>
|
<p>Game is paused</p>
|
||||||
<button class="resumeBtn" id="resumeBtn">Resume</button>
|
<button class="resumeBtn" id="resumeBtn">Resume</button>
|
||||||
<button id="pauseMenuBtn">Main Menu</button>
|
<button id="pauseMenuBtn">Main Menu</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="gameOver">
|
<div id="gameOver">
|
||||||
<h1>Game Over!</h1>
|
<h1>Game Over!</h1>
|
||||||
<p
|
<p id="newHighScore" style="display: none; color: #FFD700; font-size: 28px; margin-bottom: 10px;">🏆 New High Score! 🏆</p>
|
||||||
id="newHighScore"
|
<p>Final Score: <span id="finalScore">0</span></p>
|
||||||
style="
|
<button id="restartBtn">Play Again</button>
|
||||||
display: none;
|
|
||||||
color: #ffd700;
|
|
||||||
font-size: 28px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
🏆 New High Score! 🏆
|
|
||||||
</p>
|
|
||||||
<p>Final Score: <span id="finalScore">0</span></p>
|
|
||||||
<button id="restartBtn">Play Again</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="instructions" style="display: none">
|
<div id="instructions" style="display: none;">
|
||||||
<p>
|
<p><strong>Controls:</strong> WASD or Arrow Keys to move | Touch and drag to move (mobile) | Collect yellow coins | Avoid red obstacles!</p>
|
||||||
<strong>Controls:</strong> WASD or Arrow Keys to move | Touch and drag
|
<p style="margin-top: 5px; font-size: 11px; opacity: 0.7;">Press "T" to toggle performance monitor | Press "M" to toggle sound | Press "ESC" or "P" to pause</p>
|
||||||
to move (mobile) | Collect yellow coins | Avoid red obstacles!
|
|
||||||
</p>
|
|
||||||
<p style="margin-top: 5px; font-size: 11px; opacity: 0.7">
|
|
||||||
Press "T" to toggle performance monitor | Press "M" to toggle sound |
|
|
||||||
Press "ESC" or "P" to pause
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
// Import Three.js from CDN
|
// Import Three.js from CDN
|
||||||
|
|
||||||
import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.181.2/build/three.module.js";
|
import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.181.2/build/three.module.js';
|
||||||
|
|
||||||
// Make THREE globally available for our modules
|
// Make THREE globally available for our modules
|
||||||
window.THREE = THREE;
|
window.THREE = THREE;
|
||||||
|
|
||||||
// Load version for cache busting
|
// Load the game after THREE is loaded
|
||||||
async function loadGame() {
|
import('./src/main.js').catch(err => {
|
||||||
try {
|
console.error('Failed to load game:', err);
|
||||||
// Try to get version from version.json for cache busting
|
});
|
||||||
const versionResponse = await fetch(`/version.json?t=${Date.now()}`, {
|
|
||||||
cache: "no-store",
|
|
||||||
});
|
|
||||||
let cacheBuster = `?t=${Date.now()}`;
|
|
||||||
|
|
||||||
if (versionResponse.ok) {
|
|
||||||
const versionData = await versionResponse.json();
|
|
||||||
if (versionData.version) {
|
|
||||||
// Use version for cache busting (more reliable than timestamp)
|
|
||||||
cacheBuster = `?v=${versionData.version}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the game with cache busting
|
|
||||||
await import(`./src/main.js${cacheBuster}`);
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Failed to load game:", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the game after THREE is loaded
|
|
||||||
loadGame();
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
||||||
18
nginx.conf
18
nginx.conf
|
|
@ -9,19 +9,11 @@ server {
|
||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cache JavaScript files with version query params for 1 year (immutable)
|
# Prevent caching of JavaScript files and version.json
|
||||||
# Files without version params are not cached
|
location ~* \.(js|mjs)$ {
|
||||||
location ~* \.(js|mjs)(\?v=[^&]+)?$ {
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||||
if ($args ~ "v=") {
|
add_header Pragma "no-cache";
|
||||||
# Has version param - cache for 1 year (immutable)
|
add_header Expires "0";
|
||||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
|
||||||
}
|
|
||||||
if ($args !~ "v=") {
|
|
||||||
# No version param - don't cache
|
|
||||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
||||||
add_header Pragma "no-cache";
|
|
||||||
add_header Expires "0";
|
|
||||||
}
|
|
||||||
add_header Vary "Accept-Encoding";
|
add_header Vary "Accept-Encoding";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ name: threejs-test
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: git.jusemon.com/jusemon/threejs-test:1.0.4
|
image: git.jusemon.com/jusemon/threejs-test:0.5.0
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
|
|
||||||
|
|
@ -411,16 +411,6 @@ export class Game {
|
||||||
document.getElementById('instructions').style.display = 'block';
|
document.getElementById('instructions').style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show pause and sound buttons when game starts
|
|
||||||
const pauseBtn = document.getElementById('pauseBtn');
|
|
||||||
if (pauseBtn) {
|
|
||||||
pauseBtn.style.display = 'block';
|
|
||||||
}
|
|
||||||
const soundStatus = document.getElementById('soundStatus');
|
|
||||||
if (soundStatus) {
|
|
||||||
soundStatus.style.display = 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset UI
|
// Reset UI
|
||||||
this.updateUI();
|
this.updateUI();
|
||||||
document.getElementById('combo').style.display = 'none';
|
document.getElementById('combo').style.display = 'none';
|
||||||
|
|
@ -446,13 +436,6 @@ export class Game {
|
||||||
this.soundSystem.stopBackgroundMusic();
|
this.soundSystem.stopBackgroundMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update pause button text
|
|
||||||
const pauseBtn = document.getElementById('pauseBtn');
|
|
||||||
if (pauseBtn) {
|
|
||||||
pauseBtn.textContent = '▶️';
|
|
||||||
pauseBtn.title = 'Resume Game';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.uiSystem) {
|
if (this.uiSystem) {
|
||||||
this.uiSystem.setState('paused');
|
this.uiSystem.setState('paused');
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -475,13 +458,6 @@ export class Game {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update pause button text
|
|
||||||
const pauseBtn = document.getElementById('pauseBtn');
|
|
||||||
if (pauseBtn) {
|
|
||||||
pauseBtn.textContent = '⏸️';
|
|
||||||
pauseBtn.title = 'Pause Game';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.uiSystem) {
|
if (this.uiSystem) {
|
||||||
this.uiSystem.setState('playing');
|
this.uiSystem.setState('playing');
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -500,16 +476,6 @@ export class Game {
|
||||||
this.isPaused = false;
|
this.isPaused = false;
|
||||||
this.timeScale = 0; // Stop time in menu
|
this.timeScale = 0; // Stop time in menu
|
||||||
|
|
||||||
// Hide pause and sound buttons when returning to menu
|
|
||||||
const pauseBtn = document.getElementById('pauseBtn');
|
|
||||||
if (pauseBtn) {
|
|
||||||
pauseBtn.style.display = 'none';
|
|
||||||
}
|
|
||||||
const soundStatus = document.getElementById('soundStatus');
|
|
||||||
if (soundStatus) {
|
|
||||||
soundStatus.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update UI state
|
// Update UI state
|
||||||
if (this.uiSystem) {
|
if (this.uiSystem) {
|
||||||
this.uiSystem.setState('menu');
|
this.uiSystem.setState('menu');
|
||||||
|
|
@ -550,20 +516,6 @@ export class Game {
|
||||||
pauseMenuBtn.addEventListener('click', () => this.returnToMenu());
|
pauseMenuBtn.addEventListener('click', () => this.returnToMenu());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause button (for mobile)
|
|
||||||
const pauseBtn = document.getElementById('pauseBtn');
|
|
||||||
if (pauseBtn) {
|
|
||||||
pauseBtn.addEventListener('click', () => {
|
|
||||||
if (this.gameActive && !this.inMenu) {
|
|
||||||
if (this.isPaused) {
|
|
||||||
this.resumeGame();
|
|
||||||
} else {
|
|
||||||
this.pauseGame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('restartBtn').addEventListener('click', () => this.restart());
|
document.getElementById('restartBtn').addEventListener('click', () => this.restart());
|
||||||
|
|
||||||
// Toggle performance monitor with 'T' key
|
// Toggle performance monitor with 'T' key
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue