Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Rectangle{
- constructor(x, y, sx, sy, color){
- this.x = x;
- this.y = y;
- this.sx = sx;
- this.sy = sy;
- this.color = color;
- }
- draw(){
- context.fillStyle = this.color;
- context.fillRect(this.x, this.y, this.sx, this.sy);
- }
- }
- var rect = new Rectangle(400, 300, 30, 30, 'green');
- console.log(rect);
- // Creating variables
- var myX = 0, myY = 0;
- var obj = {}
- obj['x'] = 100;
- obj['y'] = 200;
- obj['asdf'] = "text100200";
- obj.obj2 = {a: 5, b: 6, c: 7};
- console.log(obj);
- function update() {
- myX = myX+(mouseX-myX)/10;
- myY = myY+(mouseY-myY)/10;
- }
- function draw() {
- // This is how you draw a rectangle
- rect.draw();
- };
- function keyup(key) {
- // Show the pressed keycode in the console
- console.log("Pressed", key);
- };
- function mouseup() {
- // Show coordinates of mouse on click
- console.log("Mouse clicked at", mouseX, mouseY);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement