Update receiver with Phaser tank

This commit is contained in:
oliverbye committed 2018-11-17 16:12:47 +00:00
1 parent 5d9387b74a
commit 982f3d589d
5 files changed
+23 -43

No files matched your search

+2 -17
View File
@@ -1,22 +1,7 @@
<!--
Copyright (C) 2014 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<title>CasTrax</title>
<style type="text/css">
html, body, #wrapper {
height:100%;
@@ -46,7 +31,7 @@ limitations under the License.
</style>
<script type="text/javascript" src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<script type="text/javascript">
var applicationID = '794B7BBF';
var applicationID = 'A19256CC';
var namespace = 'urn:x-cast:com.google.cast.sample.helloworld';
var session = null;
-2
View File
@@ -10,5 +10,3 @@ var config = {
},
scene: [Field]
};
var game = new Phaser.Game(config);
+6 -4
View File
@@ -14,9 +14,11 @@ class Field extends Phaser.Scene {
this.image.x +=10;
}, this);
this.input.keyboard.on('keyup_P', function () {
var pi = this.physics.add.image(this.image.x, this.image.y, 'Bullet')
pi.setVelocity(Phaser.Math.RND.integerInRange(-100,100), -300);
}, this);
this.input.keyboard.on('keyup_P', this.fire, this);
}
fire() {
var pi = this.physics.add.image(this.image.x, this.image.y, 'Bullet')
pi.setVelocity(Phaser.Math.RND.integerInRange(-100,100), -300);
}
}
+7 -2
View File
@@ -3,8 +3,13 @@
<head>
<title>CastTrax</title>
<script src="phaser.js"></script>
<script src="field.js"></script>
<script src="game.js"></script>
<script src="field.js"></script>
<script src="config.js"></script>
<script>
window.onload = function() {
const game = new Phaser.Game(config);
};
</script>
</head>
<body>
</body>
+8 -18
View File
@@ -1,18 +1,3 @@
<!--
Copyright (C) 2014 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<html>
<head>
@@ -34,18 +19,23 @@ limitations under the License.
font-size:40px;
}
</style>
<title>Cast Hello Text</title>
<title>CasTrax</title>
<script src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
<script src="phaser.js"></script>
<script src="field.js"></script>
<script src="config.js"></script>
</head>
<body>
<div id="message">Talk to me</div>
<script type="text/javascript" src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
<script type="text/javascript">
window.onload = function() {
cast.receiver.logger.setLevelValue(0);
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
console.log('Starting Receiver Manager');
// handler for the 'ready' event
const game = new Phaser.Game(config);
// handler for the 'ready' event
castReceiverManager.onReady = function(event) {
console.log('Received Ready event: ' + JSON.stringify(event.data));
window.castReceiverManager.setApplicationState('Application status is ready...');