onsdag 7 december 2016
Kod Rymdspelet
var cat = {x: 100, y: 100, speed: 30};
hideMouse();
playSound("http://spelprogrammering.nu/ljud/musik/Arkanoid_PSID_01", 0.5);
preloadSound('http://www.freespecialeffects.co.uk/soundfx/explosions/explosion_15.mp3');
function update()
{
picture(0, 0, "http://koda.nu/bilder/stars.jpg", totalWidth, totalHeight);
picture(mouse.x, mouse.y, "http://spelprogrammering.nu/bilder/xwing.png");
picture(cat.x, cat.y, "http://spelprogrammering.nu/bilder/tie.png");
if (keyboard.d)
cat.x += cat.speed;
if (keyboard.a)
cat.x -= cat.speed;
if (keyboard.w)
cat.y -= cat.speed;
if (keyboard.s)
cat.y += cat.speed;
var d = distance(mouse, cat);
if (d < 40)
{
playSound('http://www.freespecialeffects.co.uk/soundfx/explosions/explosion_15.mp3');
text(50, 50, 45, "Game over!!", "red");
showMouse();
stopSound("http://spelprogrammering.nu/ljud/musik/Arkanoid_PSID_01");
stopUpdate();
}
}
Prenumerera på:
Kommentarer till inlägget (Atom)
Inga kommentarer:
Skicka en kommentar