-
Notifications
You must be signed in to change notification settings - Fork 8
/
aiGame.html
executable file
·90 lines (72 loc) · 3.83 KB
/
aiGame.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<html>
<style type="text/css">
canvas {
margin-left: auto;
margin-right: auto;
margin-top: 5px;
<!-- margin-bottom: auto; -->
}
</style>
<head>
<!-- Title, so we can keep track of what page this is, even if PhoneGap doesn't display it. -->
<title>VirPong Mobile Client: AI Opponent</title>
<!-- Defining the size of the viewport. This is useful for -->
<!-- mobile devices for the sake of scaling and disabling resizing. -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" charset="utf-8" />
<!-- Defining our main styles. "main.css" is basic stuff, -->
<!-- and the two others provide sizing relativity for the iPad -->
<!-- and Android respectively. Also, we have gameplay.css, -->
<!-- which contains the styling for the game board. -->
<link rel="stylesheet" href="css/main.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="css/ipad.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="css/android.css" type="text/css" />
<link rel="stylesheet" href="css/gameplay.css" type="text/css" />
<!-- Include PhoneGap, and 2Player1PhonePong.js -->
<script type="text/javascript" charset="utf-8" src="phonegap-1.2.0-android.js"></script>
<script type="text/javascript" charset="utf-8" src="aiGame.js"></script>
<!-- Some JS for this page -->
<script type="text/javascript">
/*
* This function takes an event and disables the default behavior.
* @param event e The event we're preventing the behavior of.
*/
function preventBehavior(e) {
e.preventDefault();
};
/*
* When the body element loads, create an event listener
* to fire off function "onDeviceReady" when the device
* reports ready.
*/
function onBodyLoad(){
document.addEventListener("deviceready", onDeviceReady, false);
};
function zoomAndroid(){
var devicePlatform = device.platform;
if(devicePlatform == "Android"){
var wdth = 1200; //Change this variable to match your configuration
document.body.style.zoom = screen.width/wdth;
}
};
/*
* This gets fired off when the device reports ready.
*/
function onDeviceReady(){
// Grab the device's local store and point to it with localStorage.
var localStorage = window.localStorage;
// Add the listener for a touch move so that we can disable its behavior.
document.addEventListener("touchmove", preventBehavior, false);
initClient();
};
</script>
</head>
<body onload="onBodyLoad();"> <!-- When body element loads, call "onBodyLoad()" -->
<div id="topBar">
<a class="topBarButton" href="index.html">Main Menu</a>
</div>
<!-- Our game canvas. We grab the id with JS and do everything we need -->
<!-- that way, so we don't really need to define much in the way of -->
<!-- attributes here. -->
<canvas id="gameCanvas" height="100" width="100"></canvas>
</body>
</html>