Skip to content

Commit

Permalink
seperate js13k build
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel committed Sep 28, 2024
1 parent 0602096 commit ec3cf37
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 71 deletions.
33 changes: 1 addition & 32 deletions code/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const debug = 1;
let enhancedMode = 1;
let enableAsserts = 1;
let devMode = 0;
let autoPause = 1;
let downloadLink, debugMesh, debugTile, debugCapture, debugCanvas;
let debugGenerativeCanvas=0, debugInfo=0, debugSkipped=0;
let debugGenerativeCanvasCached, showMap;
let freeCamPos, freeCamRot, mouseDelta;
const js13kBuildLevel2 = 0; // more space is needed for js13k

function ASSERT(assert, output)
{ enableAsserts&&(output ? console.assert(assert, output) : console.assert(assert)); }
Expand All @@ -24,39 +24,8 @@ function debugInit()
debugCanvas = document.createElement('canvas');
downloadLink = document.createElement('a');
}

function enhancedModeUpdate()
{
if (!enhancedMode)
return;

if (autoPause && !document.hasFocus() && !titleScreenMode && !isTouchDevice)
paused = 1; // pause when losing focus

if (keyWasPressed('Home')) // dev mode
devMode || (debugInfo = devMode = 1);
if (keyWasPressed('KeyI')) // debug info
debugInfo = !debugInfo;
if (keyWasPressed('KeyM')) // toggle mute
{
if (soundVolume)
sound_bump.play(.4,3);
soundVolume = soundVolume ? 0 : .3;
if (soundVolume)
sound_bump.play();
}
if (keyWasPressed('KeyR')) // restart
{
titleScreenMode = 0;
sound_lose.play(1,2);
gameStart();
}
}

function debugUpdate()
{
enhancedModeUpdate();

if (!devMode)
return;

Expand Down
45 changes: 37 additions & 8 deletions code/game.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
'use strict';

// debug settings
let testLevel = 0;
let quickStart = 0;
let aiVehicles = 1;
let testDrive = 0;
let freeCamMode = 0;
let testLevel;
let quickStart;
let disableAiVehicles;
let testDrive;
let freeCamMode;
let testLevelInfo;
let testQuick = 0;
const js13kBuild = 1; // hacks made when building for js13k
const js13kBuildLevel2 = 0; // if more space is needed for js13k
let testQuick;
const js13kBuild = 1; // fixes for legacy code made during js13k

///////////////////////////////////////////////////

Expand All @@ -22,6 +21,7 @@ const pixelateScale = 3;
const clampAspectRatios = enhancedMode;
const optimizedCulling = 1;
const random = new Random;
let autoPause = enhancedMode;
let autoFullscreen = 0;

// setup
Expand Down Expand Up @@ -332,6 +332,7 @@ function gameUpdate(frameTimeMS=0)
// increment frame and update time
time = frame++ / frameRate;
gameUpdateInternal();
enhancedModeUpdate();
debugUpdate();
inputUpdate();

Expand Down Expand Up @@ -362,6 +363,34 @@ function gameUpdate(frameTimeMS=0)
debugDraw();
}

function enhancedModeUpdate()
{
if (!enhancedMode)
return;

if (autoPause && !document.hasFocus() && !titleScreenMode && !isTouchDevice)
paused = 1; // pause when losing focus

if (keyWasPressed('Home')) // dev mode
devMode || (debugInfo = devMode = 1);
if (keyWasPressed('KeyI')) // debug info
debugInfo = !debugInfo;
if (keyWasPressed('KeyM')) // toggle mute
{
if (soundVolume)
sound_bump.play(.4,3);
soundVolume = soundVolume ? 0 : .3;
if (soundVolume)
sound_bump.play();
}
if (keyWasPressed('KeyR')) // restart
{
titleScreenMode = 0;
sound_lose.play(1,2);
gameStart();
}
}

function updateCamera()
{
// update camera
Expand Down
1 change: 0 additions & 1 deletion code/generative.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ function generateTetures()
drawRock(x,random.float(.03),random.float(.05),.005,.4,.3,.3,y,z,500,cHSL,.4);
}
setupContext(5,4);
random.setSeed(9);
for(let i=99; i--;) // water
{
const p = i/99;
Expand Down
25 changes: 15 additions & 10 deletions code/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function drawHUD()
for(let i=0;i<text.length;i++)
{
const p = Math.sin(i-time*2-j*2);
const size2 = size + p*mainCanvasSize.y/20;
let size2 = (size + p*mainCanvasSize.y/20);
if (enhancedMode)
size2 *= lerp(time*2-2+j,0,1)
context.font = `${style} ${weight} ${size2}px ${font}`;
const c = text[i];
const w = context.measureText(c).width;
Expand All @@ -58,16 +60,19 @@ function drawHUD()
}
}

if (bestTime && (!enhancedMode || time%20<10))
if (!enhancedMode || time > 5)
{
const timeString = formatTimeString(bestTime);
if (!js13kBuildLevel2)
drawHUDText('BEST TIME', vec3(.5,.9), .07, undefined, 'monospace',undefined,900,undefined,undefined,undefined,3);
drawHUDText(timeString, vec3(.5,.97), .07, undefined, 'monospace',undefined,900,undefined,undefined,undefined,3);
}
else if (enhancedMode && !isTouchDevice)
{
drawHUDText('CLICK TO PLAY', vec3(.5,.97), .07, undefined, 'monospace',undefined,900,undefined,undefined,undefined,3);
if (bestTime && (!enhancedMode || time%20<10))
{
const timeString = formatTimeString(bestTime);
if (!js13kBuildLevel2)
drawHUDText('BEST TIME', vec3(.5,.9), .07, undefined, 'monospace',undefined,900,undefined,undefined,undefined,3);
drawHUDText(timeString, vec3(.5,.97), .07, undefined, 'monospace',undefined,900,undefined,undefined,undefined,3);
}
else if (enhancedMode && !isTouchDevice)
{
drawHUDText('CLICK TO PLAY', vec3(.5,.97), .07, undefined, 'monospace',undefined,900,undefined,undefined,undefined,3);
}
}
}
else if (startCountdownTimer.active() || startCountdown)
Expand Down
2 changes: 1 addition & 1 deletion code/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Features
//debugGenerativeCanvas = 1
//autoPause = 0
//quickStart = 1
//aiVehicles = 0
//disableAiVehicles = 1

///////////////////////////////////////////////////

Expand Down
4 changes: 3 additions & 1 deletion code/release.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

const debug = 0;
let debugInfo, debugMesh, debugTile, debugGenerativeCanvas, devMode, enhancedMode;
const enhancedMode = 1;
let debugInfo, debugMesh, debugTile, debugGenerativeCanvas, devMode;
const js13kBuildLevel2 = 0; // more space is needed for js13k

// disable debug features
function ASSERT() {}
Expand Down
15 changes: 15 additions & 0 deletions code/releaseJS13K.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const debug = 0;
let debugInfo, debugMesh, debugTile, debugGenerativeCanvas, devMode, enhancedMode;
const js13kBuildLevel2 = 1; // more space is needed for js13k

// disable debug features
function ASSERT() {}
function debugInit() {}
function drawDebug() {}
function debugUpdate() {}
function debugSaveCanvas() {}
function debugSaveText() {}
function debugDraw() {}
function debugSaveDataURL() {}
2 changes: 1 addition & 1 deletion code/vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function updateCars()

function spawnVehicle(z)
{
if (!aiVehicles)
if (disableAiVehicles)
return;

const v = new Vehicle(z);
Expand Down
Binary file modified favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 17 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title>Dr1v3n Wild! 🚗🌴</title>
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=mobile-web-app-capable content=yes>
<link rel=icon type=image/png href=favicon.png?227>
<link rel=icon type=image/png href=favicon.png?228>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

<meta name="twitter:title" content="Dr1v3n Wild">
Expand All @@ -27,19 +27,19 @@
document.body.style.backgroundColor = '#222';
}
</script>
<script src=code/debug.js?227></script>
<script src=code/utilities.js?227></script>
<script src=code/webgl.js?227></script>
<script src=code/draw.js?227></script>
<script src=code/scene.js?227></script>
<script src=code/track.js?227></script>
<script src=code/levels.js?227></script>
<script src=code/trackGen.js?227></script>
<script src=code/generative.js?227></script>
<script src=code/input.js?227></script>
<script src=code/audio.js?227></script>
<script src=code/sounds.js?227></script>
<script src=code/vehicle.js?227></script>
<script src=code/hud.js?227></script>
<script src=code/game.js?227></script>
<script src=code/main.js?227></script>
<script src=code/debug.js?228></script>
<script src=code/utilities.js?228></script>
<script src=code/webgl.js?228></script>
<script src=code/draw.js?228></script>
<script src=code/scene.js?228></script>
<script src=code/track.js?228></script>
<script src=code/levels.js?228></script>
<script src=code/trackGen.js?228></script>
<script src=code/generative.js?228></script>
<script src=code/input.js?228></script>
<script src=code/audio.js?228></script>
<script src=code/sounds.js?228></script>
<script src=code/vehicle.js?228></script>
<script src=code/hud.js?228></script>
<script src=code/game.js?228></script>
<script src=code/main.js?228></script>

0 comments on commit ec3cf37

Please sign in to comment.