Public
Edited
Dec 1, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable allowedTime = 1000 + totalPause + addedTime
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
redTextURL = await FileAttachment("redtanktexture.png").url()
Insert cell
ruggedTextURL = await FileAttachment("tanktexture.png").url()
Insert cell
greenTextURL = await FileAttachment("greentanktexture.png").url()
Insert cell
grayTextURL = await FileAttachment("graytanktexture.png").url()
Insert cell
defaultTextURL = await FileAttachment("Allied - Mirage Tank (rtank).png").url()
Insert cell
camoTextURL = await FileAttachment("camotanktexture.png").url()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
modelMatrixPause = matrixStill(modelExtents);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewMatrixStart = m4.inverse(m4.lookAt(eyePositionStart, lookAtPositionStart, [0,1,0]));
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lookAtPositionStart = [0, 1.2, 0]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
eyePosition = (hasFired && viewParameters.camFollow == "Follow") ? [(eyeDistHori*Math.sin(deg2rad(bul_yRot+70)))-bul_xPos, bul_yPos+(eyeDistVert), (eyeDistHori*Math.cos(deg2rad(bul_yRot+70)))-bul_zPos] :[(5*Math.sin(deg2rad(yRot+90)))-xPos, 1.3, (5*Math.cos(deg2rad(yRot+90)))-zPos]
Insert cell
eyePositionStart = [deg2rad(-179), deg2rad(33), deg2rad(-68)]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
invViewMatrixStart = m4.lookAt(eyePositionStart, lookAtPositionStart, [0,1,0]);
Insert cell
Insert cell
uniformStartbox = ({
cubemap,
invViewProjectionMatrix: m4.multiply(
invViewMatrixStart,
invProjectionMatrix)
});
Insert cell
Insert cell
mutable scoreMultiplier = 1;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function matrixStill(modelExtents) {
const scaleMatrix = m4.scaling([ 2/modelExtents.dia, 2/modelExtents.dia, 2/modelExtents.dia ]);
const translationMatrix = m4.translation( [0, 0, 0]);
const y_R = m4.rotationY(deg2rad(10));
const matrix = m4.multiply(translationMatrix, m4.multiply(y_R, m4.multiply(scaleMatrix, translationMatrix)));
return matrix;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function collisionDetection (bullet_X, bullet_Y, bullet_Z) {
for (let i = 0; i < targetsModelsMatrix.length; i++) {
const obstacleMinX = -randomTranslationArr[i][12] + targetsModelsMatrix[i].extents.min[0]//25;
const obstacleMaxX = -randomTranslationArr[i][12] + targetsModelsMatrix[i].extents.max[0]//25;
const obstacleMinY = targetsModelsMatrix[i].extents.min[1]-0.03//25;
const obstacleMaxY = targetsModelsMatrix[i].extents.max[1]-0.03//25;
const obstacleMinZ = -randomTranslationArr[i][14] + targetsModelsMatrix[i].extents.min[2]//25;
const obstacleMaxZ = -randomTranslationArr[i][14] + targetsModelsMatrix[i].extents.max[2]//25;
if ((bullet_X >= obstacleMinX && bullet_X <= obstacleMaxX) &&
(bullet_Z >= obstacleMinZ && bullet_Z <= obstacleMaxZ) &&
(bullet_Y >= obstacleMinY && bullet_Y <= obstacleMaxY)){
randomizeTargetPos(i+1)
//randomTranslationArr[i] = m4.translation([Math.floor(Math.random() * 120 - 60), 0, Math.floor(Math.random() * 120 -60)]);
//mutable score += 10 * scoreMultiplier;
//mutable scoreMultiplier += 1;
return false;
}
}
// mutable scoreMultiplier = 1;
return true;
}
Insert cell
resetGame = () => {
mutable xPos = 0;
mutable zPos = 0;
mutable score = 0;
mutable scoreMultiplier = 1;
mutable totalPause = 0;
mutable addedTime = 0;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
coolPicture = await FileAttachment("GLOBE OF ARMORED VEHICLES.png").image()
Insert cell
credits = await FileAttachment("GLOBE OF ARMORED VEHICLES CREDITS.png").image()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more