Difference between revisions of "Today"
From CodeStuff
| Line 1: | Line 1: | ||
<edcode> | <edcode> | ||
| − | var player = {x:300,y:400} | + | var player = {x:300,y:400} // The starting position of the player |
| − | var alien = {x:200,y:100} | + | |
| + | var alien = {x:200,y:100} // The starting position of the alien | ||
| + | |||
var bullet = {x:200, y:200} | var bullet = {x:200, y:200} | ||
function move() { | function move() { | ||
| − | + | ||
| + | //37 is the key code of the left arrow key | ||
| + | if ( keyIsDown(37) ) { | ||
| + | player.x-=2; | ||
| + | } | ||
| + | |||
| + | //39 is the key code of the right arrow key | ||
| + | if ( keyIsDown(39) ) { | ||
| + | player.x+=2; | ||
| + | } | ||
| + | |||
} | } | ||
function draw() { | function draw() { | ||
| + | clear(); | ||
print("player"); | print("player"); | ||
print(player.x); | print(player.x); | ||
| − | |||
drawPlayerShip(player.x,player.y); | drawPlayerShip(player.x,player.y); | ||