diff --git a/JinxEngine.js b/JinxEngine.js index e852752..5adbb68 100644 --- a/JinxEngine.js +++ b/JinxEngine.js @@ -9,9 +9,9 @@ function GameEngine(){ this.displayDomId; this.requestID; this.keys = new Array(400); - this.keysDown=[];//future depracation - this.keysUp=[];//future depracation - this.keysPressed=[];//future depracation + //this.keysDown=[];//future depracation + //this.keysUp=[];//future depracation + //this.keysPressed=[];//future depracation this.engineMode="live"; this.frameCount=0; this.eventStack=[]; @@ -32,7 +32,6 @@ function GameEngine(){ }); this.init = function(){ - for(var x=0;x=ranges.x1&&point.x<=ranges.x2&&point.y>=ranges.y1&&point.y<=ranges.y2){ + //work on this + } + return false; + } + + this.pointIn = function(x,y){ + if(this.g){ + return this.g.isPointInPath(this.path,x,y); + } + } + + this.rectIntersects = function(rect){ + //work on this + } + + this.getPath = function(g){ + this.g=g; + return this.path; + } +} + +function Rectangle(x,y,h,w){ + this.x=x; + this.y=y; + this.height=h; + this.width=w; + this.path = new Path2D(); + this.path.rect(x,y,h,w); + this.path.closePath(); + this.g=false; + this.roundedSides={tl:0,tr:0,bl:0,br:0}; + + this.getObjType = function(){ + return "Rectangle"; + } + + this.rounding = function(side,radius){ + switch(side){ + case "tl": + this.roundedSides.tl=radius; + break; + case "tr": + this.roundedSides.tr=radius; + break; + case "bl": + this.roundedSides.bl=radius; + break; + case "br": + this.roundedSides.br=radius; + break; + case "all": + default: + this.roundedSides.tl=radius; + this.roundedSides.tr=radius; + this.roundedSides.bl=radius; + this.roundedSides.br=radius; + } + if(this.hasRoundedCorners()){ + this.path.moveTo(x,y+radius); + this.path.lineTo(x,y+height-radius); + this.path.quadraticCurveTo(x,y+height,x+radius,y+height); + this.path.lineTo(x+width-radius,y+height); + this.path.quadraticCurveTo(x+width,y+height,x+width,y+height-radius); + this.path.lineTo(x+width,y+radius); + this.path.quadraticCurveTo(x+width,y,x+width-radius,y); + this.path.lineTo(x+radius,y); + this.path.quadraticCurveTo(x,y,x,y+radius); + this.path.closePath(); + }else{ + this.path.rect(this.x,this.y,this.h,this.w); + } + } + + this.hasRoundedCorners = function(){ + if(this.roundedSides.tl>0||this.roundedSides.tr>0||this.roundedSides.bl>0||this.roundedSides.br>0){ + return true; + } + return false; + } + + this.RectIntersects = function(rect){ + if(typeof(rect)==="undefined"){ + return false; + }else{ + if(this.x < rect.x + rect.width && this.x + this.width > rect.x && this.y < rect.y + rect.height && this.height + this.y > rect.y){ + return true; + } + } + return false; + } + + this.pointIn = function(x,y){ + if(this.g){ + return this.g.isPointInPath(this.path,x,y); + } + } + + this.getPath = function(g){ + this.g=g; + return this.path; + } +} + +/* +*Basic Texture object that is used to define a texture that will be drawn by a sprite +*/ +function Texture(src,x,y,h,w){ + var img = new Image(); + img.src=src; + this.img = img; + this.x=x; + this.y=y; + this.h=h; + this.w=w; +} + +/* +*Sprite sheet that is a more complex texture that holds many small textures that are used by a sprite for animation +*/ +function SpriteSheet(src){ + var img = new Image(); + img.src=src; + this.texture=img; + this.spriteGroups=[]; + this.sheetItems=[]; + + this.addAnimation = function(obj){//{name:,matrix:[{x,y,h,w}...,],loop,delay} + this.spriteGroups.push(obj); + } + + this.getAnimation = function(name){ + for(x=0;xcurrentAnimation.delay||this.firstRun==1){ + this.firstRun=0; + this.timelaps=0; + var curMa = currentAnimation.matrix; + var curAnSize = curMa.length-1; + if(this.frameCount>curAnSize){ + if(currentAnimation.loop==true){ + this.frameCount=0; + }else{ + this.frameCount=curAnSize; + } + } + var crm = curMa[this.frameCount]; + this.curTexPos={ + x:crm.x, + y:crm.y, + h:crm.h, + w:crm.w + } + this.frameCount++; + } + } + + this.setAnimation = function(animation){ + this.animation = animation; + } + + this.setPos = function(x,y,h,w){ + this.canvasPos={x:x,y:y,h:h,w:w} + } + + this.getPos = function(){ + return this.canvasPos; + } + + //this.isHover + + this.draw = function(g){ + var texture,tx,ty,tw,th,cx,cy,cw,ch; + cx = this.canvasPos.x; + cy = this.canvasPos.y + cw = this.canvasPos.w; + ch = this.canvasPos.h; + if(this.isSpriteSheet){ + tx = this.curTexPos.x; + ty = this.curTexPos.y; + tw = this.curTexPos.w; + th = this.curTexPos.h; + texture = this.spriteSheet.texture; + }else{ + tx = this.texture.x; + ty = this.texture.y; + tw = this.texture.w; + th = this.texture.h; + texture = this.texture.img; + } + g.drawImage(texture,tx,ty,tw,th,cx,cy,cw,ch); + } +} diff --git a/examples/Effects/background.js b/examples/Effects/background.js new file mode 100644 index 0000000..21cef70 --- /dev/null +++ b/examples/Effects/background.js @@ -0,0 +1,44 @@ +function Background(){ + //this.gameEngine; + var mySprite; + + this.init = function(e){ + //this.gameEngine = e; + var mySpriteSheet = new SpriteSheet("textures/coin-sprite-animation-sprite-sheet.png"); + mySpriteSheet.addAnimation( + { + name:"spin", + matrix:[ + {x:0,y:0,h:44,w:44}, + {x:44*2,y:0,h:44,w:44}, + {x:44*3,y:0,h:44,w:44}, + {x:44*4,y:0,h:44,w:44}, + {x:44*5,y:0,h:44,w:44}, + {x:44*6,y:0,h:44,w:44}, + {x:44*7,y:0,h:44,w:44}, + {x:44*8,y:0,h:44,w:44}, + {x:44*9,y:0,h:44,w:44} + ], + loop:true, + delay:2 + } + ); + mySprite = new Sprite("coin"); + mySprite.init(e); + mySprite.setPos(100,100,30,30); + mySprite.setAnimation("spin"); + mySprite.isSpriteSheet=true; + mySprite.spriteSheet = mySpriteSheet; + //mySprite.texture = new Texture("textures/coin-sprite-animation-sprite-sheet.png",0,0,50,50); + } + + this.update = function(){ + mySprite.update(); + //var pos = this.mySprite.getPos(); + //this.mySprite.setPos(pos.x+1,pos.y+1,pos.h,pos.w); + } + + this.draw = function(g){ + mySprite.draw(g); + } +} diff --git a/examples/Effects/hud.js b/examples/Effects/hud.js index d123e48..85ef82a 100644 --- a/examples/Effects/hud.js +++ b/examples/Effects/hud.js @@ -16,4 +16,4 @@ function HUD(){ g.fillText(""+this.objCount,10,18); } -} +} \ No newline at end of file diff --git a/examples/Effects/index.html b/examples/Effects/index.html index 002433c..12aae01 100644 --- a/examples/Effects/index.html +++ b/examples/Effects/index.html @@ -7,6 +7,7 @@ + @@ -16,7 +17,7 @@

Effects Demo

diff --git a/examples/Effects/main.js b/examples/Effects/main.js index 6325bf9..ac267f4 100644 --- a/examples/Effects/main.js +++ b/examples/Effects/main.js @@ -6,6 +6,7 @@ myDom.OnReady(function(){ myEngine.setDisplay("screen"); myDom.getId("newFireButton").addEventListener("click", function(){ myEngine.stop(); + var backgroundId = myEngine.addObject(new Background()); var particalId = myEngine.addObject(new SpawnPoint()); var hudId = myEngine.addObject(new HUD()); myEngine.init(); @@ -24,4 +25,4 @@ myDom.OnReady(function(){ myDom.getId("quitButton").addEventListener("click", function(){ myEngine.stop(); }, false); -}); +}); \ No newline at end of file diff --git a/examples/Effects/partical.js b/examples/Effects/partical.js index cb02353..868ca2c 100644 --- a/examples/Effects/partical.js +++ b/examples/Effects/partical.js @@ -13,6 +13,9 @@ function Partical(){ this.gravityDirection=55; this.gravityStrength=1; this.useGravity=true; + this.img; + this.displayType="image"; + this.imgSize; this.init = function(e){ @@ -24,6 +27,10 @@ function Partical(){ this.direction = Math.randomNumberRange(0,360); this.x_spawn=this.x; this.y_spawn=this.y; + if(this.displayType=="image"){ + this.img = new Image(); + this.imgSize = Math.randomNumberRange(1,40); + } } this.InScreenViewTest = function(){ @@ -55,7 +62,17 @@ function Partical(){ this.radius=.01; } - + if(this.displayType=="image"){ + if(this.life>50){ + this.img.src = "textures/fire"+Math.randomNumberRange(1,3)+".png"; + }else if(this.life>40){ + this.img.src = "textures/dark_smoke1.png"; + this.imgSize=40; + }else{ + this.img.src = "textures/smoke"+Math.randomNumberRange(1,3)+".png"; + this.imgSize=40; + } + } } this.deleteObj = function(){ @@ -66,25 +83,29 @@ function Partical(){ } this.draw = function(g){ - if(this.life>50){ - g.fillStyle = "red"; - } - if(this.life<=30){ - g.fillStyle = "orange"; - } - if(this.life<=20){ - g.fillStyle = "yellow"; - } - if(this.life<=10){ - g.fillStyle = "gray"; - } - if(this.life<=0){ - g.fillStyle = "black"; + if(this.displayType=="image"){ + g.drawImage(this.img,this.x-10,this.y-10,this.imgSize,this.imgSize); + }else{ + if(this.life>50){ + g.fillStyle = "red"; + } + if(this.life<=30){ + g.fillStyle = "orange"; + } + if(this.life<=20){ + g.fillStyle = "yellow"; + } + if(this.life<=10){ + g.fillStyle = "gray"; + } + if(this.life<=0){ + g.fillStyle = "black"; + } + + //g.fillRect(this.x,this.y,this.radius*2,this.radius*2); + g.beginPath(); + g.arc(this.x,this.y,this.radius,0,2*Math.PI); + g.fill(); } - - //g.fillRect(this.x,this.y,this.radius*2,this.radius*2); - g.beginPath(); - g.arc(this.x,this.y,this.radius,0,2*Math.PI); - g.fill(); } -} +} \ No newline at end of file diff --git a/examples/Effects/spawnPoint.js b/examples/Effects/spawnPoint.js index 8f192de..8e809ec 100644 --- a/examples/Effects/spawnPoint.js +++ b/examples/Effects/spawnPoint.js @@ -8,14 +8,21 @@ function SpawnPoint(){ this.buttonHover=false; this.spawnGen=4; this.mousePos; + this.img; + this.displayType="image"; this.init = function(e){ this.gameEngine = e; this.x = this.gameEngine.getDisplay("widthCenter"); this.y = this.gameEngine.getDisplay("heightCenter")+100; - for(x=0;x<15;x++){ - this.genStick(); + if(this.displayType=="image"){ + this.img = new Image(); + this.img.src = "textures/logs.png"; + }else{ + for(x=0;x<15;x++){ + this.genStick(); + } } } @@ -36,7 +43,7 @@ function SpawnPoint(){ for(x=0;xthis.ball.y){ + return "up"; + } + if(this.player.y+this.player.paddleLength + + + Tic Tac Toe + + + + + + + + + + + + + + + + + + +

Tic Tac Toe Example

+ + +

your browser will not support canvas, upgrade your browser.

+
+ + diff --git a/examples/Tic_Tac_Toe/main.js b/examples/Tic_Tac_Toe/main.js new file mode 100644 index 0000000..667c97c --- /dev/null +++ b/examples/Tic_Tac_Toe/main.js @@ -0,0 +1,38 @@ +var myDom = new DOM(); +var myEngine = new GameEngine(); +myEngine.engineMode="live"; +var gamePaused=0; +myDom.OnReady(function(){ + myEngine.setDisplay("screen"); + myDom.getId("newGameButton").addEventListener("click", function(){ + myEngine.stop(); + var mainMenu = new Scene(); + var menuUI = mainMenu.addObject(new MenuUI()); + var tmpCur = new Cursor("image"); + tmpCur.imgSrc="cursor.png"; + var cursor = mainMenu.addObject(tmpCur); + /* + var gameScene = new Scene(); + var hudId = gameScene.addObject(new HUD()); + var playerOneId = gameScene.addObject(new Player("left","red","Player One")); + var playerTwoId = gameScene.addObject(new Player("right","blue","Player Two")); + var ballId = gameScene.addObject(new Ball()); + */ + myEngine.setScene(mainMenu); + myEngine.init(); + myEngine.start(); + }, false); + myDom.getId("PauseButton").addEventListener("click", function(){ + if(gamePaused){ + myEngine.start(); + gamePaused=0; + }else{ + myEngine.pause(); + gamePaused=1; + } + + }, false); + myDom.getId("quitButton").addEventListener("click", function(){ + myEngine.stop(); + }, false); +}); \ No newline at end of file diff --git a/examples/Tic_Tac_Toe/menuUI.js b/examples/Tic_Tac_Toe/menuUI.js new file mode 100644 index 0000000..7c84c87 --- /dev/null +++ b/examples/Tic_Tac_Toe/menuUI.js @@ -0,0 +1,197 @@ +function MenuUI(){ + this.gameEngine; + this.mousePos; + this.buttonHover=false; + //this.buttionPos = {x:0,y:100,height:50,width:200} + this.buttons=[]; + var buttonXPos; + var player1=0,player2=0; + + this.init = function(e){ + this.gameEngine = e; + //this.buttionPos.x = (this.gameEngine.getDisplayWidth()/2)-100; + buttonXPos = (this.gameEngine.getDisplayWidth()/2)-100; + this.buttons.push(new Button({ + id:"startGameButton", + x:buttonXPos, + y:100, + height:50, + width:200, + baseColor:"darkGreen", + hoverColor:"green", + fontColor:"white", + borderColor:"black", + text:"Start Game" + })); + + this.buttons.push(new Button({ + id:"pxSelect", + x:buttonXPos, + y:160, + height:50, + width:200, + baseColor:"darkGreen", + hoverColor:"green", + fontColor:"white", + borderColor:"black", + text:"Player X" + })); + + this.buttons.push(new Button({ + id:"poSelect", + x:buttonXPos, + y:220, + height:50, + width:200, + baseColor:"darkGreen", + hoverColor:"green", + fontColor:"white", + borderColor:"black", + text:"Player O" + })); + for(x=0;xthis.buttionPos.x&&this.mousePos.xthis.buttionPos.y&&this.mousePos.ythis.ball.y){ + return "up"; + } + if(this.player.y+this.player.paddleLengththis.gameEngine.getDisplayHeight()){ - var v=this.direction; + /*var v=this.direction; var n=90; var u = (v*n/n*n)*n; var w=v-u; - this.direction=w; + this.direction=w;*/ //this.direction = 2 * (90 - this.direction) + 180; + this.direction+= this.direction; } var errorBuffer = 3; if(this.x<-errorBuffer||this.y<-errorBuffer||this.x>this.gameEngine.getDisplay("width")+errorBuffer||this.y>this.gameEngine.getDisplay("height")+errorBuffer){ @@ -81,8 +84,44 @@ function Ball(){ this.y = this.gameEngine.getDisplay("heightCenter"); this.direction = Math.randomNumberRange(0,360); } + + var player1 = this.gameEngine.getEventInStack("player_Player One",false); + var player2 = this.gameEngine.getEventInStack("player_Player Two",false); + + this.player1CollitionBox ={ + x:player1.x-9, + y:player1.y-9, + width:player1.width, + height:player1.height + } + + this.player2CollitionBox ={ + x:player2.x-9, + y:player2.y-9, + width:player2.width, + height:player2.height + } + + this.ballCollitionBox={ + x:this.x-9, + y:this.y-9, + width:8, + height:8, + } + + if(this.gameEngine.collitionDetection(this.player1CollitionBox,this.ballCollitionBox)){//player One + this.direction+= this.direction; + } + + if(this.gameEngine.collitionDetection(this.player2CollitionBox,this.ballCollitionBox)){//player Two + this.direction+= this.direction; + } + + this.gameEngine.getEventInStack("ball",true); + this.gameEngine.addEvent({name:"ball",x:this.x,y:this.y}); } + } @@ -93,4 +132,4 @@ function Ball(){ g.arc(this.x,this.y,this.radius,0,2*Math.PI); g.fill(); } -} +} \ No newline at end of file diff --git a/examples/pong2/cursor.png b/examples/pong2/cursor.png new file mode 100644 index 0000000..5a24d6e Binary files /dev/null and b/examples/pong2/cursor.png differ diff --git a/examples/pong2/hud.js b/examples/pong2/hud.js index 72919fc..310f213 100644 --- a/examples/pong2/hud.js +++ b/examples/pong2/hud.js @@ -77,4 +77,4 @@ function HUD(){ } -} +} \ No newline at end of file diff --git a/examples/pong2/index.html b/examples/pong2/index.html index 9b567f5..20b9793 100644 --- a/examples/pong2/index.html +++ b/examples/pong2/index.html @@ -8,6 +8,8 @@ + + diff --git a/examples/pong2/menuUI.js b/examples/pong2/menuUI.js index 1e31394..10e00ce 100644 --- a/examples/pong2/menuUI.js +++ b/examples/pong2/menuUI.js @@ -2,15 +2,107 @@ function MenuUI(){ this.gameEngine; this.mousePos; this.buttonHover=false; - this.buttionPos = {x:0,y:100,height:50,width:200} + //this.buttionPos = {x:0,y:100,height:50,width:200} + this.buttons=[]; + var buttonXPos; this.init = function(e){ this.gameEngine = e; - this.buttionPos.x = (this.gameEngine.getDisplayWidth()/2)-100; + //this.buttionPos.x = (this.gameEngine.getDisplayWidth()/2)-100; + buttonXPos = (this.gameEngine.getDisplayWidth()/2)-100; + this.buttons.push(new Button({ + id:"PvP", + x:buttonXPos, + y:100, + height:50, + width:200, + baseColor:"darkGreen", + hoverColor:"green", + fontColor:"white", + borderColor:"black", + text:"Play PvP" + })); + + this.buttons.push(new Button({ + id:"PvC", + x:buttonXPos, + y:160, + height:50, + width:200, + baseColor:"darkGreen", + hoverColor:"green", + fontColor:"white", + borderColor:"black", + text:"Play PvC" + })); + + this.buttons.push(new Button({ + id:"CvP", + x:buttonXPos, + y:220, + height:50, + width:200, + baseColor:"darkGreen", + hoverColor:"green", + fontColor:"white", + borderColor:"black", + text:"Play CvP" + })); + this.buttons.push(new Button({ + id:"CvC", + x:buttonXPos, + y:280, + height:50, + width:200, + baseColor:"darkGreen", + hoverColor:"green", + fontColor:"white", + borderColor:"black", + text:"Play CvC" + })); + for(x=0;xthis.buttionPos.x&&this.mousePos.xthis.buttionPos.y&&this.mousePos.ythis.gameEngine.getDisplayHeight()){ - this.y=this.gameEngine.getDisplayHeight()-this.paddleLength; + if(keys[this.upKey]){//up key + this.move("up"); } + if(keys[this.downKey]){//down key + this.move("down"); + } + }else{//computer player + this.ai.update(); + this.move(this.ai.getMove()); + } + this.gameEngine.getEventInStack("player_"+this.name,true); + this.gameEngine.addEvent({name:"player_"+this.name,x:this.x,y:this.y,height:this.paddleLength,width:this.paddleThickness}); + } + + this.move = function(direction){ + switch(direction){ + case "up": + this.y-=this.speed; + if(this.y<0){ + this.y=0; + } + break; + case "down": + this.y+=this.speed; + if(this.y+this.paddleLength>this.gameEngine.getDisplayHeight()){ + this.y=this.gameEngine.getDisplayHeight()-this.paddleLength; + } + break; } } diff --git a/examples/pong2/pong.js b/examples/pong2/pong.js index 38dd684..667c97c 100644 --- a/examples/pong2/pong.js +++ b/examples/pong2/pong.js @@ -8,12 +8,16 @@ myDom.OnReady(function(){ myEngine.stop(); var mainMenu = new Scene(); var menuUI = mainMenu.addObject(new MenuUI()); - + var tmpCur = new Cursor("image"); + tmpCur.imgSrc="cursor.png"; + var cursor = mainMenu.addObject(tmpCur); + /* var gameScene = new Scene(); var hudId = gameScene.addObject(new HUD()); var playerOneId = gameScene.addObject(new Player("left","red","Player One")); var playerTwoId = gameScene.addObject(new Player("right","blue","Player Two")); var ballId = gameScene.addObject(new Ball()); + */ myEngine.setScene(mainMenu); myEngine.init(); myEngine.start(); @@ -31,4 +35,4 @@ myDom.OnReady(function(){ myDom.getId("quitButton").addEventListener("click", function(){ myEngine.stop(); }, false); -}); +}); \ No newline at end of file diff --git a/examples/pong2/scene_main_menu.js b/examples/pong2/scene_main_menu.js new file mode 100644 index 0000000..9cf0170 --- /dev/null +++ b/examples/pong2/scene_main_menu.js @@ -0,0 +1,5 @@ + function MainMenu(){ + + + } + MainMenu.extends(Scene) \ No newline at end of file diff --git a/extras/ChartPackage/BarChart.js b/extras/ChartPackage/BarChart.js new file mode 100644 index 0000000..c55aeb0 --- /dev/null +++ b/extras/ChartPackage/BarChart.js @@ -0,0 +1,202 @@ +function BarChart(data){ + this.gameEngine; + this.data=data; + this.mousePos; + this.barWidth=10; + this.barSpacing=10; + + this.init = function(e){ + this.gameEngine = e; + //this.getChartData(); + } + + this.update = function(){ + //this.getChartData(); + this.mousePos=this.gameEngine.getMouse(); + } + + this.getChartData = function(){ + this.chartData=[]; + for(var x=10;x-1){//pause button + console.log("pause button"); + this.gameEngine.addEvent({name:"GameEngine",message:"pause"}); + } + } + + this.EventLisener = function(e){ + var pointEvent = this.gameEngine.getEventInStack("point",true); + if(pointEvent){ + if(pointEvent.player==1){ + this.playerOneScore++; + }else{ + this.playerTwoScore++; + } + } + } + + this.drawChartBox = function(g,area,data){ + g.strokeStyle="black"; + g.fillStyle="black"; + g.lineWidth = 2; + g.rect(area.x,area.y,area.w,area.h); + g.stroke(); + g.save(); + var rotate = -1.55; + g.rotate(rotate); + g.translate(-335, -10); + var fontSize = Math.floor(area.h / 25); + g.font=fontSize + "pt Helvetica"; + g.fillText(data.yAxis_label,area.x-20,area.y); + g.restore(); + for(var i=0;ibiggest){ + biggest=num; + } + }); + for(var x=0;xbiggest){ + biggest=data.data[x][y]; + } + } + } + return biggest; + } + + this.drawBarGroup = function(g,area,data){ + for(var i=0;i-1){//pause button + console.log("pause button"); + this.gameEngine.addEvent({name:"GameEngine",message:"pause"}); + } + } + + this.EventLisener = function(e){ + + var pointEvent = this.gameEngine.getEventInStack("point",true); + if(pointEvent){ + if(pointEvent.player==1){ + this.playerOneScore++; + }else{ + this.playerTwoScore++; + } + } + } + + this.drawChartArea = function(g){ + g.fillStyle = "black"; + g.strokeStyle="black"; + g.lineWidth = 2; + g.beginPath(); + g.moveTo(10,0); + g.lineTo(10,this.gameEngine.getDisplayHeight()-10); + g.lineTo(this.gameEngine.getDisplayWidth()-10,this.gameEngine.getDisplayHeight()-10); + g.lineTo(10,this.gameEngine.getDisplayHeight()-10); + g.stroke(); + g.closePath(); + g.lineWidth = 1; + g.fillText(""+this.chartData.length+" data points",this.gameEngine.getDisplayWidth()-60,9); + g.fillText("X:"+this.mousePos.x+" Y:"+this.mousePos.y,this.gameEngine.getDisplayWidth()-60,20); + } + + this.drawChartedLine = function(g,x,oldVal,newVal){ + g.beginPath(); + g.strokeStyle="black"; + g.fillStyle="black"; + g.fillText(""+newVal,x*10,newVal); + if(((x-1)*10)this.data[i].value){ + this.animatedData[i].value=this.data[i].value; + } + if(this.animatedData[i].value==this.data[i].value){ + if(i>this.displayedPoints){ + this.displayedPoints=i; + } + } + var dataProcessed=Math.PI*2*(this.data[i].value/this.dataTotal); + var animatedDataProcessed=Math.PI*2*(this.animatedData[i].value/this.dataTotal); + var finalValue; + if(animatedDataProcessed