Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var cobra;
- var posX;
- var posY;
- var x = 50;
- var y = 50;
- var vel = 1;
- var vidas = 3;
- var txt;
- function setup() {
- createCanvas(400, 400);
- background(220)
- }
- function draw() {
- txt = text(vidas,350,50);
- posX = mouseX;
- posY = mouseY;
- cobra = ellipse(x,y,50,50);
- cobra = fill(66, 201, 75)
- if(mouseX > x)
- {
- x += vel;
- }
- if(mouseX < x)
- {
- x -= vel;
- }
- if(mouseY > y)
- {
- y += vel;
- }
- if (mouseY < y)
- {
- y -= vel;
- }
- if((mouseX == x) && (mouseY == y))
- {
- text("GAME OVER", width/2,height/2)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement