GitLab system status is available here and here

Commit c9d171e9 authored by wbtate's avatar wbtate
Browse files

background scroll

parent 435d7b24
......@@ -4,10 +4,17 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<title>Rocket Patrol</title>
<style>
body {
background-color: beige;
}
</style>
</head>
<body>
<script src=“./lib/phaser.js”></script>
<script src = "./src/scenes/Menu.js"></script>
<script src = "./src/scenes/Play.js"></script>
<script src = "./src/main.js"></script>
</body>
</html>
\ No newline at end of file
let config = {
type: Phaser.CANVAS,
width: 640,
height: 480
height: 480,
scene: [ Menu, Play ]
}
let game = new Phaser.Game(config);
let borderUISize = game.config.height / 15;
let borderPadding = borderUISize / 3;
class Play extends Phaser.Scene {
constructor() {
super("playScene");
}
preload() {
// load images/tile sprites
this.load.image('rocket', './assets/rocket.png');
this.load.image('spaceship', './assets/spaceship.png');
this.load.image('starfield', './assets/starfield.png');
}
create() {
// place tile sprite
this.starfield = this.add.tileSprite(0, 0, 640, 480, 'starfield').setOrigin(0, 0);
// green UI background
this.add.rectangle(0, borderUISize + borderPadding, game.config.width, borderUISize * 2, 0x00FF00).setOrigin(0, 0);
// white borders
this.add.rectangle(0, 0, game.config.width, borderUISize, 0xFFFFFF).setOrigin(0, 0);
this.add.rectangle(0, game.config.height - borderUISize, game.config.width, borderUISize, 0xFFFFFF).setOrigin(0, 0);
this.add.rectangle(0, 0, borderUISize, game.config.height, 0xFFFFFF).setOrigin(0, 0);
this.add.rectangle(game.config.width - borderUISize, 0, borderUISize, game.config.height, 0xFFFFFF).setOrigin(0, 0);
}
update() {
this.starfield.tilePositionX -= 4;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment