Free javascript Hosting


pongv6mod.js

Uploaded on Jan 30 2022 05:26 by yoand453

function startGame() {
sndLoader = new BufferLoader(context,[soundURL + "games/GameshowBellDing3.mp3", soundURL + "games/heartBeat.mp3", soundURL + "games/shiny-ding-mono.mp3", soundURL + "games/drip.mp3", soundURL + "games/small_blast.mp3", soundURL + "games/shortBang1.mp3", soundURL + "games/bombBang.mp3"],soundsLoaded),
sndLoader.load()
}
function soundsLoaded(t) {
for (startSound = createSound(t[0], context, 1, 0, 1, function() {
d(!(gState = 2)),
bgSound.play(),
s(1)
}),
bgSound = createSound(t[1], context, 1, 1, 1),
qBoxS = createSound(t[2], context),
drip = createSound(t[3], context),
small_blast = createSound(t[4], context),
shortBang1 = createSound(t[5], context),
bombBang = createSound(t[6], context),
$("#bgColour").css("background", "#000"),
gState = 1,
$(".speaker").html(speaker(100, "#fff")).on(pStart, function(t) {
prevDef(t),
$(this).css({
"background-color": groundCol
})
}).on(pEnd, function(t) {
prevDef(t),
$(this).css({
"background-color": "#000"
})
}).on(pUp, function() {
1 == newAudioLoaded ? ansaAudio.play() : playAudio("t", picsarray[answers[ans]])
}),
1 == hSO && ($("#cHSBox,#cHSBtn,#overlay").css("display", "none"),
$("#cHSBtn").css({
top: "5px",
right: "270px",
left: "auto",
width: "40px",
height: "40px",
"line-height": "20px",
"border-width": "0",
"background-color": "transparent"
})),
bricks[0] = [],
r = 0; r < brickColumns; r++)
bricks[0][r] = {
x: 0,
y: 0,
status: 1,
col: sBrickCol
},
i++;
i = brickRows * brickColumns - 16;
var e = Array.apply(null, {
length: i
}).map(Function.call, Number);
for (shuffle(e),
i = 0,
c = 1; c < brickRows - 1; c++)
for (bricks[c] = [],
r = 0; r < brickColumns; r++)
e[i] < 10 ? thisCol = qBrickCol : thisCol = brickCol,
bricks[c][r] = {
x: 0,
y: 0,
status: 1,
col: thisCol
},
i++;
for (bricks[brickRows - 1] = [],
r = 0; r < brickColumns; r++)
bricks[brickRows - 1][r] = {
x: 0,
y: 0,
status: 1,
col: brickCol
},
i++;
function s(t) {
isRunning = t,
n(),
1 == isRunning && (fpsInterval = 1e3 / fps,
then = performance.now(),
startTime = then,
showBall = frameCount = 0,
setBall = 1,
w(),
setTimeout(function() {
showBall = 1
}, 1e3))
}
function n() {
x = relativeX < canvas.width && 0 < relativeX ? relativeX : canvas.width / 2,
y = startBallY,
resetGoLeft = x > canvas.width / 2 ? 0 : 1,
dx = 1 == resetGoLeft ? -iSpeed : iSpeed,
dy = -iSpeed
}
function o() {
for (shuffle(myArray),
b = answersArray.shift(),
answers = [b],
i = 0; answers.length < 4; )
myArray[i] != b && answers.push(myArray[i]),
i++;
shuffle(answers),
ans = jQuery.inArray(b, answers),
newAudioLoaded = 0,
i = soundURL + ilanguage + "/" + picsarray[answers[ans]] + ".mp3",
bufferLoader = new BufferLoader(context,[i],function(t) {
newAudioLoaded = 1,
ansaAudio = createSound(t[0], context)
}
),
bufferLoader.load()
}

function(qactivate){
o();

}

node.addEventListener('keydown', function(qactivate) {
const key = "l"; // "a", "1", "Shift", etc.
});


function l(t) {
score += t,
0 < t ? (i = Col1,
t = "+" + t) : i = "#f00",
$("#scoreChng").css({
display: "block",
color: i
}).text(t).animate({
opacity: 0,
left: "+=80",
top: "-=6"
}, 500, function() {
$("#scoreChng").css({
display: "none",
top: "10px",
left: "150px",
opacity: "1"
})
}),
$("#s_score").css({
background: i
}).text(score),
score <= 0 && B(),
setTimeout(function() {
$("#s_score").css({
background: "transparent"
}),
$("#scoreChng").css({
display: "none"
})
}, 500)
}
function d(t) {
1 == t ? clearInterval(timerID) : timerID = setInterval(function() {
secs = ((timerTime += 10) / 1e3).toFixed(2),
ab = Math.floor(secs),
$("#s_time").text(secs),
prev + 1 < ab && (l(-1),
prev = ab,
speedIncrementTimer += 1,
9 <= speedIncrementTimer && (iSpeed += speedIncrement,
speedIncrementTimer = 0))
}, 10)
}
function f(t) {
for ($("#pongCanvas").css("display", "none"),
$("#overlay").css("display", "block").find(".ovPic").css("display", "block"),
1 == hSO && $("#cHSBtn").css("display", "block"),
gState = 3,
$("#statusBar").text(modStrings[4]),
1 == newAudioLoaded && ansaAudio.play(),
i = 0; i < 4; i++)
a = i + 1,
html = '<img src="' + smallPicsURL + picsarray[answers[i]] + '.png" width="115px" height="115px" />',
$("#ovPic" + a).html(html)
}
function u() {
highPop.play(),
l(raS),
correctAnswers += 1,
totalAnswers += 1,
setTimeout(function() {
$("#pongCanvas").css("display", "block"),
$("#overlay,#cHSBtn").css("display", "none"),
10 <= correctAnswers ? B() : (o(),
gState = 2,
$("#statusBar").text(defaultStatusString),
s(1))
}, 500)
}
function p(t) {
wrong.play(),
l(waS),
totalAnswers += 1;
var e = parseInt(t) + 1;
$("#ovPic" + e).html("")
}
function h() {
for (r = 0; r < brickColumns; r++)
bricks[0][r].status = 1;
gbSL = brickColumns
}
function g() {
deltaX = 0
}
function m(t) {
paddleX = relativeX - paddleWidth / 2,
clearInterval(touchInterval),
touchInterval = setInterval(g, 10),
void 0 !== last_position.x && (deltaX = (last_position.x - t.clientX).toFixed(1)),
last_position = {
x: t.clientX,
y: t.clientY
}
}
function v() {
ctx.beginPath(),
ctx.rect(0, canvas.height - paddlePad, canvas.width, canvas.height),
ctx.fillStyle = "#ffffff",
ctx.fill(),
ctx.closePath()
}
function S() {
ctx.beginPath(),
ctx.arc(x, y, ballRadius + 2, 0, 2 * Math.PI),
ctx.fillStyle = "#000000",
ctx.fill(),
ctx.closePath()
}
function w() {
if (isRunning && (requestId = requestAnimationFrame(w),
now = performance.now(),
fpsInterval < (elapsed = now - then))) {
then = now - elapsed % fpsInterval,
ctx.clearRect(0, 0, canvas.width, canvas.height),
function() {
for (var t = 0; t < brickRows; t++)
for (var e = 0; e < brickColumns; e++)
if (1 == bricks[t][e].status) {
var a = e * (brickWidth + brickPadding) + brickOffsetLeft
, s = t * (brickHeight + brickPadding) + brickOffsetTop;
bricks[t][e].x = a,
bricks[t][e].y = s,
ctx.beginPath(),
ctx.rect(a, s, brickWidth, brickHeight),
ctx.fillStyle = bricks[t][e].col,
ctx.fill(),
ctx.closePath()
}
}(),
ctx.beginPath(),
ctx.rect(paddleX, canvas.height - paddleHeight - paddlePad, paddleWidth, paddleHeight),
ctx.fillStyle = Col1,
ctx.fill(),
ctx.closePath(),
1 == showBall && (1 == setBall && (setBall = 0,
n()),
ctx.beginPath(),
ctx.arc(x, y, ballRadius, 0, 2 * Math.PI),
ctx.fillStyle = "#ffffff",
ctx.fill(),
ctx.closePath()),
v(),
function() {
for (var t = 0; t < brickRows; t++)
for (var e = 0; e < brickColumns; e++) {
var a = bricks[t][e];
1 == a.status && x > a.x && x < a.x + brickWidth && y > a.y && y < a.y + brickHeight && (a.status = 0,
a.col == qBrickCol ? (S(),
C(x, y, 10, 16, 8, "#ff0", "#f00"),
s(0),
qBoxS.play(),
setTimeout(function() {
f()
}, 300),
l(qbS)) : a.col == sBrickCol ? (small_blast.play(),
--gbSL <= 0 && h(),
dy = -dy,
l(sbS)) : (shortBang1.play(),
dy = -dy,
l(bS)))
}
}(),
(x + dx > canvas.width - ballRadius || x + dx < ballRadius) && (1 == showBall && drip.play(),
dx = -dx),
y + dy < ballRadius ? (1 == showBall && drip.play(),
dy = -dy) : y + dy > canvas.height - ballRadius - paddleHeight - paddlePad && paddleX < x && x < paddleX + paddleWidth ? (1 == showBall && drip.play(),
dy = -dy,
0 !== deltaX ? deltaX < 0 ? dx += .1 * Math.abs(deltaX) : dx -= .1 * deltaX : dx = dx) : y + dy > canvas.height - ballRadius - paddlePad && (locX = x,
S(),
s(0),
C(locX, y + 20, 10, 16, 8, "#fff", "#fff"),
bombBang.play(),
$heart = $("#heart" + lives),
$(".heartPath", $heart).attr("style", "fill:#ccc"),
lives--,
l(llS),
setTimeout(function() {
lives ? s(1) : B()
}, 600)),
1 == showBall && (x += dx),
1 == showBall && (y += dy),
frameCount++;
var t = now - startTime;
currentFps = Math.round(1e3 / (t / ++frameCount) * 100) / 100
}
}
function B() {
gState = 4,
d(1),
setTimeout(function() {
bgSound.stop()
}, 4e3),
defaultStatusString = modStrings[5],
$("#statusBar").text(defaultStatusString),
$("#cHSBox,#cHSBtn").css("display", "none"),
1 == hSO ? offerHighScore(score, 2, 167, 53) : gameEnd2()
}
function C(t, e, a, s, n, o, r) {
var c = Math.PI / 2 * 3
, l = t
, d = e
, f = Math.PI / a;
for (ctx.beginPath(),
ctx.moveTo(t, e - s),
i = 0; i < a; i++)
l = t + Math.cos(c) * s,
d = e + Math.sin(c) * s,
ctx.lineTo(l, d),
c += f,
l = t + Math.cos(c) * n,
d = e + Math.sin(c) * n,
ctx.lineTo(l, d),
c += f;
ctx.lineTo(t, e - s),
ctx.closePath(),
ctx.lineWidth = 5,
ctx.strokeStyle = o,
ctx.stroke(),
ctx.fillStyle = r,
ctx.fill()
}
"primary" == level ? myArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] : myArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
answersArray = myArray.slice(0),
shuffle(answersArray),
defaultStatusString = modStrings[3],
$("#statusBar").text(defaultStatusString),
$("#back").css("visibility", "visible"),
game = document.getElementById("game"),
$("#loading").remove(),
document.addEventListener("keydown", function(t) {
39 == t.keyCode ? rightPressed = !0 : 37 == t.keyCode && (leftPressed = !0);
t.keyCode <= 49 <= 52 && 3 == gState && (49 == t.keyCode ? i = 1 : 50 == t.keyCode ? i = 2 : 51 == t.keyCode ? i = 3 : 52 == t.keyCode && (i = 4),
k = String(i - 1),
k == ans ? u() : p(k))
}, !1),
document.addEventListener("keyup", function(t) {
39 == t.keyCode ? rightPressed = !1 : 37 == t.keyCode ? leftPressed = !1 : 105 == t.keyCode && s(0)
}, !1),
window.PointerEvent ? game.addEventListener("pointermove", function(t) {
t.preventDefault(),
offset = cJQ.offset(),
0 < (relativeX = t.clientX - offset.left) && relativeX < canvas.width && m(t)
}) : (document.addEventListener("touchstart", function(t) {
t.preventDefault();
var e = t.touches[0];
offset = cJQ.offset(),
relativeX = e.clientX - offset.left
}, {
passive: !1
}),
document.addEventListener("touchmove", function(t) {
t.preventDefault();
var e = t.touches[0];
offset = cJQ.offset(),
0 < (relativeX = e.clientX - offset.left) && relativeX < canvas.width && m(e)
}, {
passive: !1
})),
function() {
for (var t = 0; t < brickRows; t++)
for (var e = 0; e < brickColumns; e++)
if (1 == bricks[t][e].status) {
bn += 1;
var a = e * (brickWidth + brickPadding) + brickOffsetLeft
, s = t * (brickHeight + brickPadding) + brickOffsetTop;
bricks[t][e].x = a,
bricks[t][e].y = s,
ctx.beginPath(),
ctx.rect(a, s, brickWidth, brickHeight),
ctx.fillStyle = bricks[t][e].col,
ctx.fill(),
ctx.closePath()
}
v()
}(),
startSound.play(),
o(),
$(".ovPic").on(pUp, function(t) {
prevDef(t),
k = $(this).attr("name"),
k == ans ? u() : p(k)
})
}
var c, r, ans, timerID, secs, touchInterval, offset, relativeX, startSound, drip, shortBang1, bombBang, small_blast, bgSound, qBoxS, sIdBg, ansaAudio, requestId, deltaX, deltaY, fpsInterval, startTime, now, then, elapsed, currentFps, canvas = document.getElementById("pongCanvas"), ctx = canvas.getContext("2d"), cJQ = $("#pongCanvas"), x = canvas.width / 2, y = startBallY = canvas.height - 60, ballRadius = 4, paddleHeight = 10, paddleWidth = 75, paddleX = (canvas.width - paddleWidth) / 2, paddlePad = 30, rightPressed = !1, leftPressed = !1, brickRows = 6, brickColumns = 8, brickWidth = 72, brickHeight = 20, brickPadding = 10, brickOffsetTop = 25, brickOffsetLeft = 27, brickCol = Col1 = "#008C00", qBrickCol = "#fff", sBrickCol = "#ff0", bn = 0, score = 1e3, lives = 5, isRunning = !1, bricks = [], gState = 0, hsFlag = 0, correctAnswers = 0, totalAnswers = 0, timerTime = speedIncrementTimer = 0, ab = 0, prev = 0, last_position = {}, moveLeft = 0, moveRight = 0, gbSL = brickColumns, dx = iSpeed, dy = -iSpeed, resetGoLeft = 1, setBall = 0, showBall = 0, sIdBgRate = 1, raS = 50, waS = -25, llS = -200, bS = 2, qbS = 10, sbS = 50, newAudioLoaded = 0, fps = 60, iSpeed = 3.2, speedIncrement = .2, frameCount = 0;
1 == hSO && $("#cHSBtn,#cHSBox").on(pUp, function(t) {
prevDef(t),
"none" == $("#cHSBox").css("display") ? $("#cHSBox").css("display", "block") : $("#cHSBox").css("display", "none")
});

Back to list