Spaces:
Running
Running
<title>E.MOji.Monster.Squad</title> | |
<head><meta charset="utf-8"/> | |
<style>#javas { top: 0; left: 0; position: absolute; z-index: 1000; width: 100%; height: 100%; }</style> | |
</head><body encoding='utf8'> | |
<canvas id="javas"></canvas> | |
<script type='text/javascript'> | |
var javas = document.querySelector('#javas'); | |
javas.height = window.innerHeight; | |
javas.width = window.innerWidth; | |
var c = javas.getContext('2d'); | |
var mouse = { | |
x: undefined, | |
y: undefined | |
}; | |
var newX = 0; | |
var newY = 0; | |
var traker = 0; | |
var score = 0; | |
var level = 1; | |
var instant = Date.now(); | |
var startTime=Date.now(); | |
var cycleTime=1000*1; | |
var elapsed = 0; | |
var elapsedCycle=0; | |
var elapsedCyclePercent=0; | |
var moment = 0; | |
var frame = 0; | |
var squareArray = []; | |
var togle = 0; | |
var kit; | |
var tik; | |
var farts = []; | |
var muf; | |
var guf; | |
var trip = 0; | |
var intro = 1; | |
var tod = 0; | |
var tgt = 0; | |
var rrror = ""; | |
var hscore = 0; | |
var emi = []; | |
var cuboids = []; | |
var kills = 0; | |
var marq = 0; | |
var barq = 0; | |
var bigX; | |
var bigY; | |
var vit; | |
var darq = 0; | |
var ppp; | |
var noob; | |
var emos = []; | |
var tempArr = []; | |
var many = 0; | |
var word = "heureux"; | |
var who = new Request('https://api.dictionaryapi.dev/api/v2/entries/en/victory'); | |
var wha = new Request('https://api.dictionaryapi.dev/api/v2/entries/en/happy'); | |
async function cookie() { | |
try{ | |
var [vicResponse, hapResponse] = await Promise.all([fetch(who),fetch(wha)]); | |
var vic = await vicResponse.json(); | |
var hap = await hapResponse.json(); | |
return [vic, hap]; | |
} catch(e) { console.log(e); }; | |
}; | |
cookie().then(([vic, hap]) => { | |
var flob = document.createElement('ul'); | |
var goo = vic[0].meanings[3].synonyms; | |
var foo = hap[0].meanings[3].synonyms; | |
if (goo){ | |
for (let i = 0; i < goo.length; i++) { | |
emos.push(''+goo[i]+''); | |
}; | |
} | |
if (foo){ | |
for (let j = 0; j < foo.length; j++) { | |
emos.push(''+foo[j]+''); | |
}; | |
} | |
}).catch(console.error); | |
if(localStorage.SqrScore) { | |
hscore = localStorage.SqrScore; | |
} else { | |
localStorage.SqrScore = score; | |
}; | |
window.addEventListener('resize', function(){ | |
javas.height = window.innerHeight; | |
javas.width = window.innerWidth; | |
event.preventDefault(); | |
init(); | |
//var tag = document.createElement('meta'); | |
//tag.name = "viewport"; | |
//tag.content = "user-scalable=0"; | |
//document.head.appendChild(tag); | |
}); | |
window.addEventListener('mousemove', | |
function (event) { | |
mouse.x = event.x; | |
mouse.y = event.y; | |
//bobd(); | |
}); | |
window.addEventListener('touchstart', | |
function (event) { | |
let touchtart = event.touches[0]; | |
event.preventDefault(); | |
mouse.x = touchtart.clientX; | |
mouse.y = touchtart.clientY; | |
newX = mouse.x; | |
newY = mouse.y; | |
for (var jy in squareArray) { | |
var a = 0; | |
var b = 0; | |
var c = 0; | |
var d = 50 + squareArray[jy].height; | |
if(newX < squareArray[jy].x && newY < squareArray[jy].y){ | |
a = squareArray[jy].x - newX; | |
b = squareArray[jy].y - newY; | |
} | |
if(newX > squareArray[jy].x && newY < squareArray[jy].y){ | |
a = newX - squareArray[jy].x; | |
b = squareArray[jy].y - newY; | |
} | |
if(newX > squareArray[jy].x && newY > squareArray[jy].y){ | |
a = newX - squareArray[jy].x; | |
b = newY - squareArray[jy].y; | |
} | |
if(newX < squareArray[jy].x && newY > squareArray[jy].y){ | |
a = squareArray[jy].x - newX; | |
b = newY - squareArray[jy].y; | |
} | |
var asq = a*a; | |
var bsq = b*b; | |
var summ = asq + bsq; | |
if(summ < 0){ | |
summ = summ *(0-1); | |
} | |
c = Math.sqrt(summ); | |
if(c <= d){ | |
traker -= 1; | |
kills += 1; | |
darq = frame+25; | |
barq = frame+15; | |
marq = 1; | |
bigX = squareArray[jy].x; | |
bigY = squareArray[jy].y; | |
explode(squareArray[jy].x, squareArray[jy].y); | |
navigator.vibrate([50]); | |
(function (){ | |
var audioCtx = new(window.AudioContext || window.webkitAudioContext)(); | |
function playNote(frequency, duration) { | |
// create Oscillator node | |
var oscillator = audioCtx.createOscillator(); | |
let gain = audioCtx.createGain(); | |
gain.gain.value = 0.1; | |
oscillator.type = 'sine'; | |
oscillator.frequency.value = frequency; // value in hertz | |
//oscillator.connect(audioCtx.destination); | |
oscillator.connect(gain); | |
gain.connect(audioCtx.destination); | |
oscillator.start(); | |
setTimeout( | |
function() { | |
oscillator.stop(); | |
playMelody(); | |
}, duration); | |
}; | |
function playMelody() { | |
if (notes.length > 0) { | |
note = notes.pop(); | |
playNote(note[0], 1000 * 256 / (note[1] * tempo)); | |
} | |
}; | |
notes = [ | |
[1280, 256], | |
[768, 256], | |
[1024, 256], | |
[512, 256], | |
[256, 256] | |
]; | |
//notes.reverse(); | |
tempo = 100; | |
playMelody(); | |
})(); | |
if(kills == 10){ | |
congrat(0, 0); | |
navigator.vibrate([250]); | |
level += 1; | |
document.body.style.backgroundColor = "black"; | |
} | |
if(kills == 50){ | |
congrat(0, 0); | |
navigator.vibrate([250]); | |
level += 1; | |
} | |
if(kills == 100){ | |
congrat(0, 0); | |
navigator.vibrate([250]); | |
level += 1; | |
document.body.style.backgroundColor = "white"; | |
} | |
if(kills == 300){ | |
congrat(0, 0); | |
navigator.vibrate([250]); | |
level += 1; | |
document.body.style.backgroundColor = "black"; | |
} | |
if(kills == 400){ | |
congrat(0, 0); | |
navigator.vibrate([250]); | |
level += 1; | |
} | |
if(trip == 1){ | |
trip = 0; | |
level = 1; | |
score = 0; | |
intro = 1; | |
frame = 0; | |
} | |
if(squareArray[jy].golf == 0){ | |
vit = 0; | |
ppp = Math.floor(frame/squareArray[jy].eater); | |
score -= ppp; | |
} | |
if(squareArray[jy].golf > 0){ | |
vit = Math.floor(frame/squareArray[jy].height)*level; | |
score += vit; | |
} | |
delete squareArray[jy]; | |
} | |
}; | |
//bobd(); | |
}, false); | |
window.addEventListener("touchmove", | |
function (event) { | |
let touchmvo = event.touches[0]; | |
event.preventDefault(); | |
mouse.x = touchmvo.clientX; | |
mouse.y = touchmvo.clientY; | |
}, false); | |
window.addEventListener('touchend', | |
function (event) { | |
let touchtend = event.touches[0]; | |
event.preventDefault(); | |
mouse.x = touchtend.clientX; | |
mouse.y = touchtend.clientY; | |
}, false); | |
var ze = 0; | |
function color(r, g, b, a){ | |
this.r = r; | |
this.g = g; | |
this.b = b; | |
this.a = a; | |
} | |
function point2D(x, y){ | |
this.x = x; | |
this.y = y; | |
} | |
point2D.prototype.move = function(p2D){ | |
this.x += p2D.x; | |
this.y += p2D.y; | |
} | |
function point3D(x, y, z){ | |
this.x = x; | |
this.y = y; | |
this.z = z; | |
} | |
point3D.prototype.move = function(p3D){ | |
this.x += p3D.x; | |
this.y += p3D.y; | |
this.z += p3D.z; | |
} | |
point3D.prototype.swap = function(p3D){ | |
this.x = p3D.x; | |
this.y = p3D.y; | |
this.z = p3D.z; | |
} | |
point3D.prototype.rotate = function(axis, angleGr){ | |
angleRad = angleGr * Math.PI / 180; | |
switch (axis) | |
{ | |
case "x":{ | |
var tempPoint = new point3D( | |
this.x, | |
this.y * Math.cos(angleRad) - this.z * Math.sin(angleRad), | |
this.y * Math.sin(angleRad) + this.z * Math.cos(angleRad) | |
); | |
this.swap(tempPoint); | |
break; | |
} | |
case "y":{ | |
var tempPoint = new point3D( | |
this.x * Math.cos(angleRad) + this.z * Math.sin(angleRad), | |
this.y, | |
-this.x * Math.sin(angleRad) + this.z * Math.cos(angleRad) | |
); | |
this.swap(tempPoint); | |
break; | |
} | |
case "z":{ | |
var tempPoint = new point3D( | |
this.x * Math.cos(angleRad) - this.y * Math.sin(angleRad), | |
this.x * Math.sin(angleRad) + this.y * Math.cos(angleRad), | |
this.z | |
); | |
this.swap(tempPoint); | |
break; | |
} | |
} | |
} | |
function normal3D(p3D, length){ | |
this.point = p3D; | |
this.length = length; | |
} | |
function poly(){ | |
var points = []; | |
for(var i = 0; i < arguments.length; i++) | |
points.push(arguments[i]); | |
this.points = points; | |
// Calculating normal | |
var v1 = new point3D(points[2].x - points[1].x, points[2].y - points[1].y, points[2].z - points[1].z); | |
var v2 = new point3D(points[0].x - points[1].x, points[0].y - points[1].y, points[0].z - points[1].z); | |
var normalP3D = new point3D(v1.y*v2.z-v2.y*v1.z, v1.z*v2.x-v2.z*v1.x, v1.x*v2.y-v2.x*v1.y); | |
var normalLen = Math.sqrt(normalP3D.x*normalP3D.x + normalP3D.y*normalP3D.y + normalP3D.z*normalP3D.z); | |
this.normal = new normal3D(normalP3D, normalLen); | |
} | |
poly.prototype.move = function(p3D){ | |
for(var i = 0; i < this.points.length; i++) | |
{ | |
var point = this.points[i]; | |
point.move(p3D); | |
} | |
} | |
poly.prototype.rotate = function(axis, angle){ | |
for(var i = 0; i < this.points.length; i++) | |
{ | |
var point = this.points[i]; | |
point.rotate(axis, angle); | |
} | |
this.normal.point.rotate(axis, angle); | |
} | |
poly.prototype.put = function(center, fillColor, edgeColor){ | |
// Calulate visibility | |
var normalAngleRad = Math.acos(this.normal.point.z/this.normal.length); | |
if(normalAngleRad / Math.PI * 180 >= 90) | |
return; | |
var lightIntensity = 1 - 2 * (normalAngleRad / Math.PI); | |
c.fillStyle = 'rgba('+fillColor.r+','+fillColor.g+','+fillColor.b+','+(fillColor.a*lightIntensity)+')'; | |
c.beginPath(); | |
for(var i = 0; i < this.points.length; i++) | |
{ | |
var point = this.points[i]; | |
if(i) | |
c.lineTo(center.x + parseInt(point.x), center.y - parseInt(point.y)); | |
else | |
c.moveTo(center.x + parseInt(point.x), center.y - parseInt(point.y)); | |
} | |
c.fill(); | |
c.lineWidth = 1; | |
c.strokeStyle = 'rgba('+edgeColor.r+','+edgeColor.g+','+edgeColor.b+','+(edgeColor.a*lightIntensity)+')'; | |
c.beginPath(); | |
var point = this.points[this.points.length-1]; | |
c.moveTo(center.x + parseInt(point.x), center.y - parseInt(point.y)); | |
for(var i = 0; i < this.points.length; i++) | |
{ | |
var point = this.points[i]; | |
c.lineTo(center.x + parseInt(point.x), center.y - parseInt(point.y)); | |
} | |
c.stroke(); | |
} | |
function Cube(size, fillColor, edgeColor){ | |
var p000 = new point3D(0,0,0); | |
var p0S0 = new point3D(0,size,0); | |
var pSS0 = new point3D(size,size,0); | |
var pS00 = new point3D(size,0,0); | |
var p00S = new point3D(0,0,size); | |
var p0SS = new point3D(0,size,size); | |
var pSSS = new point3D(size,size,size); | |
var pS0S = new point3D(size,0,size); | |
var polys = []; | |
polys.push(new poly(p000,p0S0,pSS0,pS00)); | |
polys.push(new poly(pS00,pSS0,pSSS,pS0S)); | |
polys.push(new poly(pS0S,pSSS,p0SS,p00S)); | |
polys.push(new poly(p00S,p0SS,p0S0,p000)); | |
polys.push(new poly(p0S0,p0SS,pSSS,pSS0)); | |
polys.push(new poly(p00S,p000,pS00,pS0S)); | |
this.polys = polys; | |
var points = []; | |
points.push(p000); | |
points.push(p0S0); | |
points.push(pSS0); | |
points.push(pS00); | |
points.push(p00S); | |
points.push(p0SS); | |
points.push(pSSS); | |
points.push(pS0S); | |
for(var i = 0; i < polys.length; i++) | |
{ | |
points.push(polys[i].normal.point); | |
} | |
this.points = points; | |
this.fillColor = fillColor; | |
this.edgeColor = edgeColor; | |
} | |
function move(o3D, p3D){ | |
for(var i = 0; i < o3D.points.length - o3D.polys.length; i++) | |
{ | |
var point = o3D.points[i]; | |
point.move(p3D); | |
} | |
} | |
function put(o3D, center) | |
{ | |
for(var i = 0; i < o3D.polys.length; i++) | |
{ | |
var poly = o3D.polys[i]; | |
poly.put(center, o3D.fillColor, o3D.edgeColor); | |
} | |
} | |
function rotate(o3D, axis, angle){ | |
for(var i = 0; i < o3D.points.length; i++) | |
{ | |
var point = o3D.points[i]; | |
point.rotate(axis, angle); | |
} | |
} | |
function pnit(){ | |
ze += 1; | |
cube = new Cube(100, new color(38,161,220,1), new color(38,161,220,1)); | |
move(cube, new point3D(-javas.width/2,-50,-50)); | |
rotate(cube, 'x', 45); | |
rotate(cube, 'y', 45); | |
rotate(cube, 'z', 45); | |
centerScreen = new point2D((javas.width / 2)+ze, javas.height / 2); | |
put(cube, centerScreen); | |
//timer = setInterval(nextFrame, 1000 / 60); | |
} | |
function nextFrame(){ | |
ze += 1; | |
rotate(cube, 'x', 0.4); | |
rotate(cube, 'y', 0.6); | |
rotate(cube, 'z', 0.3); | |
c.fillStyle = 'rgba(50, 50, 200, 1)'; | |
c.strokeStyle = 'rgba(60, 60, 210, 1)'; | |
put(cube, new point2D((javas.width / 2)+Math.random()*2, javas.height / 2)); | |
move(cube, new point3D(0+ze,0,0)); | |
} | |
function explode(x, y){ | |
togle = 1; | |
kit = x; | |
tik = y; | |
ash(); | |
}; | |
function congrat(x, y){ | |
togle = 1; | |
muf = x; | |
guf = y; | |
upgra(); | |
}; | |
function drawScore() { | |
c.font = "120px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("Score: "+score, 20, 120); | |
c.fill(); | |
}; | |
function drawHcore() { | |
c.font = "60px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("HighScore: "+hscore, javas.width-450, 220); | |
c.fill(); | |
}; | |
function drawLevel() { | |
c.font = "32px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("Level: "+level, 30, 160); | |
c.fill(); | |
}; | |
function drawFrames() { | |
c.font = "16px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("Frame: "+frame, 30, 180); | |
c.fill(); | |
}; | |
function drawMomentos() { | |
c.font = "16px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("Elapsed: "+elapsed+"ms", 30, 195); | |
c.fill(); | |
}; | |
function drawFps() { | |
c.font = "16px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("fps: "+elapsed/frame, 30, 210); | |
c.fill(); | |
}; | |
function drawOver() { | |
c.font = "170px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("GAME OVER", 10, (javas.height/2)-100); | |
c.fill(); | |
}; | |
function newLev() { | |
c.font = "170px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("LEVEL: "+level, 40, (javas.height/2)-100); | |
c.fill(); | |
}; | |
function newIntro(){ | |
c.fillStyle = 'rgb(38,161,220)'; | |
c.fillRect(0,0,javas.width,javas.height); | |
c.fill(); | |
c.font = "120px Arial"; | |
c.fillStyle = "#FFFFFF"; | |
c.fillText("SQUARE HEADS", 20, (javas.height/2)-100); | |
c.fill(); | |
c.font = "150px Arial"; | |
c.fillStyle = "#FFFFFF"; | |
c.fillText("Loading..."+Math.floor((frame/100)*100)+"%", 20, (javas.height/2)+100); | |
c.fill(); | |
}; | |
function drawGoodies(x, y, hoot) { | |
c.font = "130px Arial"; | |
c.fillStyle = "#0095DD"; | |
c.fillText("+"+hoot+"points", x-100, y-100); | |
c.fill(); | |
}; | |
function drawNoogies(x, y, boot) { | |
c.font = "150px Arial"; | |
c.fillStyle = 'red'; | |
c.fillText("-"+boot+"points", x-100, y-100); | |
c.fill(); | |
}; | |
function ters(x, y, vx, vy){ | |
this.x = x; | |
this.y = y; | |
this.vx = vx*((0-1)*(Math.random()*3)); | |
this.vy = vy*((0-1)*(Math.random()*2)); | |
this.live = 0; | |
this.die = 6+(Math.random()*10); | |
}; | |
ters.prototype.draw = function() { | |
this.x += this.vx; | |
this.y += this.vy; | |
this.live += 1; | |
if(kills < 10){ | |
c.fillStyle = 'rgba(38,161,220,'+(1/(this.live/this.die))+')'; | |
} | |
if(kills > 10){ | |
c.fillStyle = 'orange'; | |
} | |
if(kills > 50){ | |
c.fillStyle = 'red'; | |
} | |
if(kills > 100){ | |
c.fillStyle = 'pink'; | |
} | |
if(kills > 200){ | |
c.fillStyle = 'green'; | |
} | |
if(kills > 300){ | |
c.fillStyle = 'hsl('+Math.floor(Math.random()*360)+',100%,'+Math.floor(Math.random()*100)+'%)'; | |
} | |
c.fillRect(this.x,this.y, Math.floor(Math.random()*10),Math.floor(Math.random()*10)); | |
}; | |
ters.prototype.update = function(){ | |
this.draw(); | |
}; | |
function vixul(x, y){ | |
this.x = x; | |
this.y = y; | |
this.vx = Math.random(); | |
this.vy = Math.random()*4; | |
this.live = 0; | |
this.die = 30+(Math.random()*10); | |
}; | |
vixul.prototype.draw = function() { | |
this.x -= this.vx; | |
this.y += this.vy; | |
this.live += 1; | |
if(kills < 10){ | |
c.fillStyle = 'rgba(38,161,220,'+(1/(this.live/this.die))+')'; | |
} | |
if(kills >= 10){ | |
c.fillStyle = 'orange'; | |
} | |
if(kills >= 50){ | |
c.fillStyle = 'red'; | |
} | |
if(kills >= 100){ | |
c.fillStyle = 'pink'; | |
} | |
if(kills >= 200){ | |
c.fillStyle = 'green'; | |
} | |
if(kills >= 300){ | |
c.fillStyle = 'hsl('+Math.floor(Math.random()*360)+',100%,'+Math.floor(Math.random()*100)+'%)'; | |
} | |
c.fillRect(this.x,this.y, Math.floor(Math.random()*12),Math.floor(Math.random()*12)); | |
}; | |
vixul.prototype.update = function(){ | |
this.draw(); | |
}; | |
function ash() { | |
for(var dr = 0; dr < 60; dr++){ | |
farts.push(new vixul((kit+(Math.random()*100)), (tik+(Math.random()*100)))); | |
}; | |
}; | |
function upgra() { | |
for(var pr = 0; pr < 1000; pr++){ | |
farts.push(new vixul((muf+(Math.random()*javas.width)), (guf+(Math.random()*javas.height)))); | |
}; | |
}; | |
function square(){ | |
var mpo = 0; | |
traker += 1; | |
mpo = traker+0; | |
//var emos = ['\+','\#','\@','\%','\&','\?','$','\*','\~','\-','\π','\∆','\√','\°','\÷','\×']; | |
//var emos = ['word','crazy','beast','warlock']; | |
var emos = ['🦖','🌑','🦎','🐙','🐙','🎈','👾','👾','🐊','🐍','🦇','🐌','🕷️','🐡']; | |
var moas = Math.floor(Math.random()*100); | |
this.x = Math.floor(Math.random()*window.innerWidth); | |
this.y = 1; | |
if(moas <= 25){ | |
this.x = 1; | |
this.y = Math.floor(Math.random() * javas.height); | |
this.vx = ((Math.random()*5)*level)+3; | |
this.vy = 0; | |
} | |
if(moas >= 26 && moas <= 50){ | |
this.x = Math.floor(Math.random() * javas.width); | |
this.y = 1; | |
this.vx = 0; | |
this.vy = (Math.random()*5)*level+3; | |
} | |
if(moas >= 51 && moas <= 75){ | |
this.x = javas.width-1; | |
this.y = Math.floor(Math.random()*javas.height); | |
this.vx = 0-1*Math.random()*5*level+3; | |
this.vy = 0; | |
} | |
if(moas >= 76 && moas <= 100){ | |
this.x = Math.floor(Math.random()*javas.width); | |
this.y = javas.height-1; | |
this.vx = 0; | |
this.vy = 0-1*Math.random()*5*level+3; | |
} | |
this.id = mpo; | |
this.height = Math.floor((50+(Math.random()*200))/level); | |
this.live = 0; | |
this.die = (300+(Math.random()*100))-(score/100); | |
this.golf = 1; | |
this.eater = 0; | |
this.char = emos[Math.floor(Math.random() * emos.length)]; | |
}; | |
square.prototype.draw = function() { | |
this.x += this.vx; | |
this.y += this.vy; | |
if(kills < 10){ | |
c.fillStyle = 'rgb(38,161,220)'; | |
} | |
if(kills >= 10){ | |
c.fillStyle = 'orange'; | |
} | |
if(kills >= 50){ | |
c.fillStyle = 'red'; | |
} | |
if(kills >= 100){ | |
c.fillStyle = 'pink'; | |
} | |
if(kills >= 200){ | |
c.fillStyle = 'green'; | |
} | |
if(kills >= 300){ | |
c.fillStyle = 'hsl('+Math.floor(Math.random()*360)+',100%,'+Math.floor(Math.random()*100)+'%)'; | |
} | |
if(this.live >= this.die/4){ | |
c.fillStyle = 'hsl(360,0%,50%)'; | |
this.golf = 0; | |
this.eater += 1; | |
} | |
c.font = ""+this.height+"px Arial"; | |
c.fillText(""+this.char+"", this.x, this.y); | |
//c.fillRect(this.x,this.y,this.height,this.height); | |
}; | |
square.prototype.update = function(){ | |
this.draw(); | |
}; | |
if(traker < 3){ | |
squareArray.push(new square()); | |
} | |
for(var de in squareArray){ | |
for(var ml = 0; ml < 10; ml++){ | |
emi.push(new ters(squareArray[de].x, squareArray[de].y, squareArray[de].vx, squareArray[de].vy)); | |
}; | |
}; | |
noob = setInterval(function(){ | |
draw(); | |
}, 32/1000); | |
(function init() { | |
c.clearRect(0, 0, javas.width, javas.height); | |
ze += 1; | |
cube = new Cube((Math.random()*100)+50, new color(38,161,220,0.8), new color(38,161,220,0.8)); | |
move(cube, new point3D(-javas.width/2,-50,-50)); | |
rotate(cube, 'x', 45); | |
rotate(cube, 'y', 45); | |
rotate(cube, 'z', 45); | |
centerScreen = new point2D(-javas.width / 2, javas.height * Math.random()); | |
put(cube, centerScreen); | |
cabe = new Cube((Math.random()*100)+50, new color(38,161,220,0.8), new color(38,161,220,0.8)); | |
move(cabe, new point3D(-javas.width/2,-50,-50)); | |
rotate(cabe, 'x', 45); | |
rotate(cabe, 'y', 45); | |
rotate(cabe, 'z', 45); | |
centerScreen = new point2D(-javas.width / 2, -(javas.height/2) + (Math.random()*javas.height)); | |
put(cabe, centerScreen); | |
cebe = new Cube((Math.random()*100)+50, new color(38,161,220,0.8), new color(38,161,220,0.8)); | |
move(cebe, new point3D(+javas.width/2,-50,-50)); | |
rotate(cebe, 'x', 45); | |
rotate(cebe, 'y', 45); | |
rotate(cebe, 'z', 45); | |
centerScreen = new point2D(+javas.width / 2, -javas.height/2); | |
put(cebe, centerScreen); | |
recordCanvas(javas, 30000); | |
requestAnimationFrame(noob); | |
})(); | |
function draw(){ | |
frame += 1; | |
elapsed=Date.now()-startTime; | |
elapsedCycle=elapsed%cycleTime; | |
elapsedCyclePercent=elapsedCycle/cycleTime; | |
moment += elapsed; | |
if(score > localStorage.SqrScore){ | |
localStorage.SqrScore = score; | |
hscore = score; | |
} | |
c.clearRect(0, 0, javas.width, javas.height); | |
if(trip == 1){ | |
drawOver(); | |
} | |
if(traker < 3 && intro == 0){ | |
squareArray.push(new square()); | |
} | |
for (var uy in squareArray) { | |
squareArray[uy].live += 1; | |
squareArray[uy].height += Math.random(); | |
if(squareArray[uy].y >= javas.height){ | |
squareArray[uy].y = 1; | |
} | |
if(squareArray[uy].y < 1){ | |
squareArray[uy].y = javas.height-1; | |
} | |
if(squareArray[uy].x < 1){ | |
squareArray[uy].x = javas.width-1; | |
} | |
if(squareArray[uy].x >= javas.width){ | |
squareArray[uy].x = 1; | |
} | |
for(var ml = 0; ml < 3; ml++){ | |
emi.push(new ters((squareArray[uy].x+(squareArray[uy].height/2)), (squareArray[uy].y+(squareArray[uy].height/2)), squareArray[uy].vx, squareArray[uy].vy)); | |
emi.push(new ters(squareArray[uy].x, squareArray[uy].y, squareArray[uy].vx, squareArray[uy].vy)); | |
emi.push(new ters((squareArray[uy].x+(squareArray[uy].height)), (squareArray[uy].y+(squareArray[uy].height)), squareArray[uy].vx, squareArray[uy].vy)); | |
}; | |
if(marq == 1 && frame <= barq && squareArray[uy].golf == 1 && vit > 1){ | |
drawGoodies(bigX, bigY, vit); | |
} | |
if(marq == 1 && frame <= darq && squareArray[uy].golf == 0 && vit == 0){ | |
drawNoogies(bigX, bigY, ppp); | |
} | |
if(squareArray[uy].live >= squareArray[uy].die){ | |
delete squareArray[uy]; | |
trip = 1; | |
tgt = 1; | |
traker -= 1; | |
drawOver(); | |
intro = 1; | |
} else{ | |
squareArray[uy].draw(); | |
}; | |
}; | |
if(frame > 100){ | |
ze += 1; | |
rotate(cube, 'x', -0.4*3); | |
rotate(cube, 'y', -0.6*3); | |
rotate(cube, 'z', -0.3*3); | |
put(cube, new point2D(0, javas.height/2)); | |
move(cube, new point3D(0+ze/50,0,0)); | |
rotate(cabe, 'x', -0.4); | |
rotate(cabe, 'y', -0.6); | |
rotate(cabe, 'z', -0.3); | |
put(cabe, new point2D((javas.width/2)-50, javas.height)); | |
move(cabe, new point3D(0,0+ze/10,0)); | |
rotate(cebe, 'x', 0.4); | |
rotate(cebe, 'y', 0.6); | |
rotate(cebe, 'z', 0.3); | |
put(cebe, new point2D(javas.width, javas.height/2)); | |
move(cebe, new point3D(0-ze/50,0,0)); | |
} | |
if(cabe.y > 0){ | |
put(cabe, new point2D((javas.width/2)-50, javas.height)); | |
move(cabe, new point3D(0,1,0)); | |
} | |
for(var zx in farts){ | |
if(farts[zx].live >= farts[zx].die){ | |
delete farts[zx]; | |
} else { | |
farts[zx].draw(); | |
}; | |
}; | |
for(var ix in emi){ | |
if(emi[ix].live >= emi[ix].die){ | |
delete emi[ix]; | |
} else { | |
emi[ix].draw(); | |
}; | |
}; | |
var beaut = c.createRadialGradient(mouse.x, mouse.y, 200, mouse.x, mouse.y, 700); | |
beaut.addColorStop(0, "hsla(111,100%,40%,0.1)"); | |
beaut.addColorStop(1, "hsla(111,100%,0%,1.0)"); | |
c.fillStyle = beaut; | |
//c.fillStyle = '#000'; | |
c.beginPath(); | |
c.fillRect(0,0,javas.width,javas.height); | |
c.closePath(); | |
c.fill(); | |
bobd(); | |
drawFrames(); | |
drawLevel(); | |
drawScore(); | |
drawMomentos(); | |
drawFps(); | |
drawHcore(); | |
if(tgt == 1 && frame > 1 && trip == 1){ | |
(function (){ | |
var oudioCtx = new(window.AudioContext || window.webkitAudioContext)(); | |
function playNote(frequency, duration) { | |
// create Oscillator node | |
var osxillator = oudioCtx.createOscillator(); | |
let goin = oudioCtx.createGain(); | |
goin.gain.value = 0.3; | |
osxillator.type = 'sine'; | |
osxillator.frequency.value = frequency; // value in hertz | |
//osxillator.connect(oudioCtx.destination); | |
osxillator.connect(goin); | |
goin.connect(oudioCtx.destination); | |
osxillator.start(); | |
setTimeout( | |
function() { | |
osxillator.stop(); | |
playMelody(); | |
}, duration); | |
} | |
function playMelody() { | |
if (notes.length > 0) { | |
note = notes.pop(); | |
playNote(note[0], 1000 * 256 / (note[1] * tempo)); | |
} | |
} | |
notes = [ | |
[1280, 32], | |
[1024, 32], | |
[896, 32], | |
[768, 32], | |
[512, 32], | |
[384, 32] | |
]; | |
notes.reverse(); | |
tempo = 100; | |
playMelody(); | |
})(); | |
tgt = 0; | |
} | |
if(intro == 1 && frame < 100){ | |
c.clearRect(0, 0, javas.width, javas.height); | |
newIntro(); | |
} else { | |
intro = 0; }; | |
if(frame == 60){ | |
(function (){ | |
var uudioCtx = new(window.AudioContext || window.webkitAudioContext)(); | |
function playNote(frequency, duration) { | |
// create Oscillator node | |
var osvillator = uudioCtx.createOscillator(); | |
let guin = uudioCtx.createGain(); | |
guin.gain.value = 0.3; | |
osvillator.type = 'sine'; | |
osvillator.frequency.value = frequency; // value in hertz | |
//osvillator.connect(uudioCtx.destination); | |
osvillator.connect(guin); | |
guin.connect(uudioCtx.destination); | |
osvillator.start(); | |
setTimeout( | |
function() { | |
osvillator.stop(); | |
playMelody(); | |
}, duration); | |
} | |
function playMelody() { | |
if (notes.length > 0) { | |
note = notes.pop(); | |
playNote(note[0], 1000 * 256 / (note[1] * tempo)); | |
} | |
} | |
notes = [ | |
[2048, 32], | |
[1024, 32], | |
[896, 32], | |
[768, 32], | |
[896, 32], | |
[1024, 32], | |
[1280, 32], | |
[1024, 32], | |
[768, 32], | |
[512, 32], | |
[256, 32], | |
[128, 32] | |
]; | |
//notes.reverse(); | |
tempo = 100; | |
playMelody(); | |
})(); | |
} | |
//requestAnimationFrame(draw); | |
}; | |
function bobd(){ | |
c.fillStyle = '#FFF'; | |
c.font = "16px Arial"; | |
c.fillText("This is Title Graph",javas.width/4,18); | |
c.fill(); | |
c.save(); | |
c.translate(18,javas.height*3/4); | |
c.rotate(-6.35/4); | |
c.fillStyle = '#FFF'; | |
c.font = "16px Arial"; | |
c.fillText("this is Title Y",0,0); | |
c.fill(); | |
c.restore(); | |
c.fillStyle = '#000'; | |
c.beginPath(); | |
c.fillRect(mouse.x-300,mouse.y,600,1); | |
c.closePath(); | |
c.fill(); | |
c.fillStyle = '#000'; | |
c.beginPath(); | |
c.fillRect(mouse.x,mouse.y-300,1,100); | |
c.closePath(); | |
c.fill(); | |
for(var qw = 0; qw < 30; qw++){ | |
c.fillStyle = '#000'; | |
c.beginPath(); | |
c.fillRect(mouse.x+(qw*10),((mouse.y)-5)-qw,1,10+qw+qw); | |
c.closePath(); | |
c.fill(); | |
}; | |
for(var ww = 0; ww < 30; ww++){ | |
c.fillStyle = '#000'; | |
c.beginPath(); | |
c.fillRect(mouse.x-(ww*10),((mouse.y)-5)-ww,1,10+ww+ww); | |
c.closePath(); | |
c.fill(); | |
}; | |
for(var ow = 0; ow < 30; ow++){ | |
c.fillStyle = '#000'; | |
c.beginPath(); | |
c.fillRect(((mouse.x)-5)-(ow),mouse.y+(ow*10),10+ow+ow,1); | |
c.closePath(); | |
c.fill(); | |
}; | |
for(var lw = 0; lw < 30; lw++){ | |
c.fillStyle = '#000'; | |
c.beginPath(); | |
c.fillRect(((mouse.x)-5)-(lw),mouse.y-(lw*10),10+lw+lw,1); | |
c.closePath(); | |
c.fill(); | |
}; | |
c.fillStyle = '#FFF'; | |
c.font = "16px Arial"; | |
c.fillText("This is Title X",javas.width/4,javas.height-2); | |
c.fill(); | |
}; | |
function recordCanvas(canvas, videoLength) { | |
const recordedChunks = []; | |
const mediaRecorder = new MediaRecorder( | |
canvas.captureStream(32), {mimeType: 'video/webm; codecs=vp8'}); | |
mediaRecorder.ondataavailable = event => recordedChunks.push(event.data); | |
mediaRecorder.onstop = () => { | |
const url = URL.createObjectURL( | |
new Blob(recordedChunks, {type: "video/webm"})); | |
const anchor = document.createElement("a"); | |
anchor.href = url; | |
anchor.download = "video.webm"; | |
anchor.click(); | |
window.URL.revokeObjectURL(url); | |
} | |
mediaRecorder.start(); | |
window.setTimeout(() => {mediaRecorder.stop();}, 30000); | |
}; | |
</script> | |
</body> | |
</html> |