Use the arrow keys to move around and eat the green balls to get fatter. This is multiplayer and the goal is to be the first one to get as big as the map. Watch out, because other balls can eat you too.
xxxxxxxxxx
mapHeight = 5000
mapWidth = 5000
winTimer = 100
winner = null
winnerId = -1
screen = 'start'
deathTimer = 100
updateNeeded = false
updateT = 20
canUpdate = true
canUpdateT = 0
sentWarn = false
myFrames = 1
version = 12
slowDown2 = 0
updateTimer = 0
sp = false;
function draw() {
betterServer.hide()
updateTimer -= 1
if(updateTimer == 5 && canUpdate){
//print('I am updating the server')
updateServer() // This updates the database with the current positions of the bots
canUpdate = false
canUpdateT = 0
sentWarn = false
recivedAlready = true
slowDown = true
updateTimer = 0
}
if(myFrames % 45 == 15){
slowDown = false
slowDown2 = false
}
if(winTimer < 100){
for(let i = 0; i < players.length; i++){
players[i].size = 100
}
}
if(screen == 'start'){
updatePlayers()
}
cursor(ARROW)
if(canUpdateT > 200 +(45*(players.length+1)) + updateT){
canUpdate = true
canUpdateT = 0
}
canUpdateT ++
if(((myFrames%(140*(players.length+1)) == updateT) && (myFrames > 360)) && screen == 'play' && canUpdate && updateTimer < 4){ // every second or so
recivedAlready = false
// print('Sent warn singal')
socket.emit('warn', User.id)
sentWarn = true
recivedAlready = false
}
calcScale()
translate(width/2, height/2)
scale(scaleFactor, scaleFactor)
calcAvgFrames()
if(User.name.toLowerCase() != 'night'){
background(180)
}
if(screen == 'reload'){
fill(0)
textSize(30)
scale(1/scaleFactor, 1/ scaleFactor)
textAlign(CENTER)
text('Please reload the entire page to continue playing', 0, 0)
}
if(screen == 'start'){
background(120)
scale(1/scaleFactor,1/scaleFactor)
push()
startScreen()
if(sp){
kkmath();
}
pop()
}
else if(screen == 'play'){
if(User.dead == false){
User.updateForces()
User.updatePos()
}
else if(deathTimer <= -50){
screen = 'start'
}
drawGrid()
User.draw()
updateBots()
updatePlayers()
leaderBoard()
if(deathTimer > -50 && User.dead){
push()
scale(1/scaleFactor, 1/scaleFactor)
deathScreen()
pop()
deathTimer -= (0.8 / avgFrames) * 60
}
push()
scale(1/scaleFactor,1/scaleFactor)
drawMiniMap()
pop()
}
if(winTimer < 100){
winScreen(winner, winnerId)
winTimer -= (1 / avgFrames) * 9
}
if(winTimer < 40){
screen = 'gameEnded'
socket.emit('gameEnded', winTimer)
for(let i = 0; i < players.length; i++){
players[i].size = 100
}
}
if(screen == 'gameEnded'){
if(winTimer < -100){
screen = 'start'
resetGame()
screen = 'start'
winTimer = 100
}
}
// Every 5 frames or if the player is on the edge of the map
if(frameCount % 15 == 0 || ((User.x + User.size/2 > mapWidth)||(User.x - User.size/2 < 0)||(User.y + User.size/2 > mapHeight)||(User.y - User.size/2 < 0))){
updateLocation(null, null) // send singal of where I am
}
myFrames++
}
var socket = io.connect($OP.getEchoServerURL(1528232));
Learn more See an example