This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://spelprogrammering.nu/simple.js"> | |
fill("white"); | |
rectangle(5, 50, totalWidth-10, totalHeight-55, "black"); | |
var p1 = {x: random(5, totalWidth-5), y: random(50, totalHeight-5), size: 5, xSpeed: 5, ySpeed: 0}; | |
var p2 = {x: random(5, totalWidth-5), y: random(50, totalHeight-5), size: 5, xSpeed: 5, ySpeed: 0}; | |
if(p1.x > totalWidth/2) { p1.xSpeed = -5; } //Om dessa står i en update function så dör man så fort man kommer in i den | |
if(p2.x > totalWidth/2) { p2.xSpeed = -5; } //högra delen av planen för att man då få negativ xSpeed fastän spelet är igång. |