Kalkyl

Kalkylspelet

Länk spelet

Kopiera URL: http://koda.nu/labbet/guide/kalkyl_utmaning

Kod (kopiera och klistra in i kodalabbet):

<meta charset=”utf-8″ />
<script src=”http://koda.nu/simple.js”>

var sabine = {x: 100, y: 300};
var fotboll = {x: random(50,totalWidth-50), y: random(50,totalHeight-50)};
var highscore = 0;
var timer = 500;

function update()
{
fill(“pink”);
picture(10, 10, “http://koda.nu/bilder/plan.jpg”, totalWidth-20, totalHeight-20);

text(80, 70, 20, “Tid kvar: “+timer, “black”);
text(80, 120, 20, “Antal fotbollar: “+highscore, “black”);

picture(fotboll.x-25, fotboll.y-25, “http://koda.nu/bilder/fotboll.png”, 50, 50);
picture(sabine.x-100, sabine.y-100, “http://koda.nu/bilder/kalkyl.png”, 200, 200);

if (keyboard.right)
{
sabine.x += 5;
}

timer -= 1;

if (distance(sabine, fotboll) < 50)
{
fotboll.x = random(50,totalWidth-50);
fotboll.y = random(50,totalHeight-50);
highscore += 1;
}

if (timer == 0)
{
stopUpdate();
fill(“black”);
picture(0, 50, “http://koda.nu/bilder/kalkyl_vinst.png”, totalWidth, totalWidth*(1080/1920));
text(150, 175, 130, highscore, “white”);
}
}

</script>