Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. class Rectangle{
  2. constructor(x, y, sx, sy, color){
  3. this.x = x;
  4. this.y = y;
  5. this.sx = sx;
  6. this.sy = sy;
  7. this.color = color;
  8. }
  9. draw(){
  10. context.fillStyle = this.color;
  11. context.fillRect(this.x, this.y, this.sx, this.sy);
  12. }
  13. }
  14.  
  15. var rect = new Rectangle(400, 300, 30, 30, 'green');
  16. console.log(rect);
  17. // Creating variables
  18. var myX = 0, myY = 0;
  19.  
  20. var obj = {}
  21. obj['x'] = 100;
  22. obj['y'] = 200;
  23. obj['asdf'] = "text100200";
  24. obj.obj2 = {a: 5, b: 6, c: 7};
  25.  
  26. console.log(obj);
  27.  
  28. function update() {
  29. myX = myX+(mouseX-myX)/10;
  30. myY = myY+(mouseY-myY)/10;
  31. }
  32.  
  33. function draw() {
  34. // This is how you draw a rectangle
  35. rect.draw();
  36. };
  37.  
  38. function keyup(key) {
  39. // Show the pressed keycode in the console
  40. console.log("Pressed", key);
  41. };
  42.  
  43. function mouseup() {
  44. // Show coordinates of mouse on click
  45. console.log("Mouse clicked at", mouseX, mouseY);
  46. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement