Index: GameLogic.js ================================================================== --- GameLogic.js +++ GameLogic.js @@ -1,104 +1,78 @@ +// copyright (c)) 2015 jadon belezos, tom burris /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ var circleX = 400; -var circleY = 250; +var circleY = 25 var mouseX = 400; var mouseY = 250; -var close = 0; +var mass = 5; +var radius = 0; -function start() -{ +function start() { + drawCircles(); - var loop = setInterval(mainloop, 50); + var interval = setInterval(mainloop, 50); } function mainloop() { - moveTheCircles(); - if (close == 0) { - clearCanvas(); - drawCircles(); - } - sleep(100); + moveCircles(); + clearCanvas(); + drawCircles(); } function getCoordinates(e) { - mouseX = e.clientX; mouseY = e.clientY; - document.getElementById("xycoordinates").innerHTML="Coordinates: (" + mouseX + "," + mouseY + ")"; -} - -function clearCoordinates() { - - document.getElementById("xycoordinates").innerHTML=""; } function clearCanvas() { var c = document.getElementById("canvas"); var ctx = c.getContext("2d"); ctx.clearRect(0, 0, 801, 501); } -function moveTheCircles() { +function moveCircles() { var speed = .08; + radius = Math.sqrt((mass * 100) / Math.PI); + if ( mouseX > circleX ) { var difX = mouseX - circleX; - if (difX > 5) { + if (difX > 5) circleX = circleX + difX * speed; - } + } else { var difX = circleX - mouseX; - if (difX > 5) { + if (difX > 5) circleX = circleX - difX * speed; - } } if ( mouseY > circleY ) { - var difY = mouseY - circleY; - if (difY > 5) { - circleY = circleY + difY * speed; - close = 0; - } else if (difX < 5) { - close = 1; - } + if (difY > 5) + circleY = circleY + difY * speed; } else { var difY = circleY - mouseY; - if (difY > 5) { - circleY = circleY - difY * speed; - close = 0; - } else { - close = 1; - } + if (difY > 5) + circleY = circleY - difY * speed; + } } function drawCircles() { - var c = document.getElementById("canvas"); var ctx = c.getContext("2d"); - ctx.beginPath(); - ctx.arc(circleX, circleY, 50, 0, 2 * Math.PI); + ctx.beginPath(); //draw the player + ctx.arc(circleX, circleY, radius, 0, 2 * Math.PI); ctx.closePath(); ctx.lineWidth = 5; ctx.fillStyle = 'green'; ctx.fill(); ctx.strokeStyle = 'darkgreen'; ctx.stroke(); - -} - -function sleep(milliseconds) { - var start = new Date().getTime(); - for (var i = 0; i < 1; i++) { - if ((new Date().getTime() - start) > milliseconds){ - break; - } - } } Index: GetCoordinates.html ================================================================== --- GetCoordinates.html +++ GetCoordinates.html @@ -1,5 +1,6 @@ + @@ -6,19 +7,17 @@ -your browser does not support the canvas tag -
+ your browser does not support the canvas tag ADDED Main.html Index: Main.html ================================================================== --- Main.html +++ Main.html @@ -0,0 +1,45 @@ + + + + + +Cell Game + + + +
+
+

Cell Game

+
+
+
+ +
+
+ + ADDED readme.md Index: readme.md ================================================================== --- readme.md +++ readme.md @@ -0,0 +1,16 @@ +

cell

+this is the game cell. +it is based on the game agario. +you are cell that is trying to get big and collect as much mass +as possible to become the biggest baddest cell. + + +one thing that might be added to our game are viruses that +reduce mass instead of add to it. +another potential will be zombie cells. so there cells that can only grow + +the game is entirely web based so all you need is a relatively modern web browser. +we might add speed boost. +mass boost. +speed boost game modes. +the one person with loses faster as he becomes bigger than everyone else.