Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var wormHead = createSprite(200,200)
- wormHead.setAnimation("wormHead")
- l = 0;
- Point();
- PointAdder();
- var negspeed = -5;
- var posspeed = 5;
- function draw() {
- var yr = wormHead.y;
- var xr = wormHead.x;
- background("black");
- fill("red")
- rect(0,0,400,6)
- rect(0,0,6,400)
- rect(0,394,400,6)
- rect(394,0,6,400)
- function gameOver(){
- textSize(30); text("GameOver", 200, 50)
- wormPoint.destroy();
- }
- text("Score:" + z, 30 ,30);
- if (xr == x1 || xr == x2 || xr == x3 || xr == x4 || xr == x5 || xr == x6 || xr == x7 || xr == x8 || xr == x9 || xr == x10 || xr == x11 || xr == x12 || yr == y1 || yr == y2 || yr == y3 || yr == y4 || yr == y5 || yr == y6 || yr == y7 || yr == y8 || yr == y9 || yr == y10 || yr == y11 || xr == x12 ) {
- PointAdder();
- }
- var Time = World.seconds
- if (Time < 4 || Time == 0){ textSize(30); text(Time, 200, 50); wormHead.x = 200; wormHead.y = 200 }
- else if (Time == 4 ) {
- textSize(30); text("GO", 200, 50)
- }
- drawSprites()
- var xTest = wormHead.x;
- var yTest = wormHead.y;
- if (Time > 3){
- if (keyDown("W")) { wormHead.velocityY = negspeed; wormHead.velocityX = 0; } else if (keyDown("up")) { wormHead.velocityY = negspeed; wormHead.velocityX = 0; }
- if (keyDown("S")) { wormHead.velocityY = posspeed; wormHead.velocityX = 0; } else if (keyDown("down")) { wormHead.velocityY = posspeed; wormHead.velocityX = 0; }
- if (keyDown("A")) { wormHead.velocityX = negspeed; wormHead.velocityY = 0;} else if (keyDown("left")) { wormHead.velocityX = negspeed; wormHead.velocityY = 0; }
- if (keyDown("D")) { wormHead.velocityX = pospeed; wormHead.velocityY = 0; } else if (keyDown("right")) { wormHead.velocityX = posspeed; wormHead.velocityY = 0;}
- if (xTest < 5 || xTest > 395) {wormHead.velocityY = 0; wormHead.velocityX = 0; wormHead.setAnimation("wormDead"); gameOver();}
- if (yTest < 5 || yTest > 395){ wormHead.velocityY = 0; wormHead.velocityX = 0; wormHead.setAnimation("wormDead"); gameOver();}
- }
- }
- function randX(a) {
- return randomNumber(10,380)
- }
- function randY(a) {
- return randomNumber(10,380)
- }
- setInterval(randX,1000)
- setInterval(randY,1000)
- setInterval(Point,2200)
- function Point(){
- x = randX()
- x1 = x + 1; x2 = x + 2; x3 = x + 3; x4 = x + 4; x5 = x + 5; x6 = x + 6;
- x7 = x - 1; x8 = x - 2; x9 = x - 3; x10 = x - 4; x11 = x - 5; x12 = x - 6;
- y = randX()
- y1 = y + 1; y2 = y + 2; y3 = y + 3; y4 = y + 4; y5 = y + 5; y6 = y + 6;
- y7 = y - 1; y8 = y - 2; y9 = y - 4; y10 = y - 4; y11 = y - 5; y12 = y - 6;
- var target = createSprite(x,y);
- target.setAnimation("Point")
- target.scale = 0.3;
- target.setlifetime = 1;
- setInterval(function(){target.remove()},2000)
- }
- function PointAdder() {
- z = l++
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement