Difference between revisions of "Game"

From CodeStuff
Jump to: navigation, search
(Created page with "<edcode> var ball_1 = {cx:320, cy:240, dx:3, dy:-3}; var ball_2 = {cx:330, cy:340, dx:-3, dy:-3}; var ball_3 = {cx:340, cy:440, dx:-3, dy:3}; var ball_4 = {cx:350, cy:140, dx...")
 
Line 1: Line 1:
 
<edcode>
 
<edcode>
 +
 +
// todo
 +
// make player stay in box
 +
// make player hit balls
 +
 +
 +
  
 
var ball_1 = {cx:320, cy:240, dx:3, dy:-3};
 
var ball_1 = {cx:320, cy:240, dx:3, dy:-3};
Line 5: Line 12:
 
var ball_3 = {cx:340, cy:440, dx:-3, dy:3};
 
var ball_3 = {cx:340, cy:440, dx:-3, dy:3};
 
var ball_4 = {cx:350, cy:140, dx:3, dy:3};
 
var ball_4 = {cx:350, cy:140, dx:3, dy:3};
 +
 +
var player = {x:320, y:200, speed:3};
  
 
var boxTop=130, boxLeft=120;  //the top left corner of the box is 130,120
 
var boxTop=130, boxLeft=120;  //the top left corner of the box is 130,120
Line 28: Line 37:
 
   moveBall(ball_3);
 
   moveBall(ball_3);
 
   moveBall(ball_4);
 
   moveBall(ball_4);
 +
 
 +
  if (keyIsDown(38)) player.y-=player.speed;
 +
  if (keyIsDown(40)) player.y+=player.speed;
 +
  if (keyIsDown(37)) player.x-=player.speed;
 +
  if (keyIsDown(39)) player.x+=player.speed;
 
}
 
}
  
Line 42: Line 56:
 
   setColour('red');
 
   setColour('red');
 
   drawRectangle(boxLeft,boxTop,boxWidth,boxHeight);
 
   drawRectangle(boxLeft,boxTop,boxWidth,boxHeight);
 +
 
 +
 
 +
  drawCircle(player.x,player.y,20);
 +
 
 
}
 
}
  
 
run(move,draw);
 
run(move,draw);
 +
  
 
</edcode>
 
</edcode>

Revision as of 02:07, 3 May 2012