Difference between revisions of "Today"
From CodeStuff
| Line 19: | Line 19: | ||
<edcode>var c = {x:320, y:240, lastx:320, lasty:240, power:0.1, penSize:4}; | <edcode>var c = {x:320, y:240, lastx:320, lasty:240, power:0.1, penSize:4}; | ||
| + | var gameOver = { image : loadImage("http://fingswotidun.com/images/GameOver.png"), | ||
| + | x:0, y: -10000, | ||
| + | endx: 0, endy: 150}; | ||
| + | |||
var gameAge=0; | var gameAge=0; | ||
var stillAlive=true; | var stillAlive=true; | ||
| Line 113: | Line 117: | ||
for (var meep of chasers) { | for (var meep of chasers) { | ||
moveTowards(meep,c); | moveTowards(meep,c); | ||
| + | |||
| + | if ( distance(meep,c) < 8) { | ||
| + | stillAlive=false; | ||
| + | } | ||
} | } | ||
if ( (gameAge %300) === 0) { | if ( (gameAge %300) === 0) { | ||
| − | addChaser( | + | var newX = Math.random() * 640; |
| + | var newY = Math.random() * 480; | ||
| + | |||
| + | addChaser(newX,newY,0.45+ gameAge/3000,"magenta"); | ||
} | } | ||
} | } | ||
| Line 134: | Line 145: | ||
print("the game age is "+gameAge); | print("the game age is "+gameAge); | ||
print(gameAge % 300); | print(gameAge % 300); | ||
| + | |||
| + | drawImage(gameOver.image,gameOver.x,gameOver.y); | ||
} | } | ||
| Line 140: | Line 153: | ||
if (stillAlive) { | if (stillAlive) { | ||
play(); | play(); | ||
| + | } else { | ||
| + | |||
} | } | ||
| + | |||
if (keyIsDown(32)) { | if (keyIsDown(32)) { | ||
stillAlive=false; | stillAlive=false; | ||
| Line 148: | Line 164: | ||
run(move); | run(move); | ||
| + | |||
</edcode> | </edcode> | ||
Latest revision as of 22:51, 6 July 2017
Useful things to refer to.
The API page has a list of some of the functions you can use such as