3 <TITLE>Quake Demo
</TITLE>
5 <script type=
"text/javascript">
9 // Before scripting the loaded module, ensure the Native Client module is loaded.
12 var Completion = function(files_array
) {
15 this.seen
= new Array();
16 this.files
= files_array
;
17 this.num_left
= files_array
.length
;
19 for (i
= 0; i
< this.num_left
; ++i
) {
23 this.done = function(name
) {
26 for (i
= 0; i
< this.files
.length
; ++i
) {
30 if (name
== this.files
[i
]) {
36 return (0 == this.num_left
) ? 1 : 0;
40 var FileLoadCallback = function(filename
, url
, completion_pred
) {
41 this.filename
= filename
;
43 this.pred
= completion_pred
;
45 this.onload = function(nacl_desc
) {
46 nacl_elt
.file(this.filename
, nacl_desc
, this.pred
.done(this.filename
));
48 this.onfail = function(object
) {
49 window
.alert('Failed to load URL: ' + this.url
+ ', error ' + object
);
53 var StartLoad = function(filename
, url
, comp
) {
54 nacl_elt
.__urlAsNaClDesc(url
,
55 new FileLoadCallback(filename
, url
, comp
));
58 var PostLoadInit = function() {
59 if (nacl_elt
.__moduleReady
== 1) {
60 clearTimeout(startupTimeout
);
61 var load_array
= new Array('./id1/pak0.pak');
62 var comp
= new Completion(load_array
);
64 for (i
= 0; i
< load_array
.length
; ++i
) {
65 StartLoad(load_array
[i
], load_array
[i
], comp
);
69 if (nacl_elt
.__moduleReady
== undefined) {
70 window
.alert('The Native Client plugin was unable to load');
73 startupTimeout
= setTimeout(PostLoadInit
, 100);
77 // Init is called when the document has completed loading. It downloads the
78 // NativeClient modules.
79 var Init = function() {
80 // service_url contains the location of the NativeClient module to be
81 // loaded as a service.
82 nacl_elt
= document
.getElementById('embed1');
90 <BODY onload=
"Init();" onunload=
"" id=
"bodyId" bgcolor=
"#333333" >
91 <span style=
"color:CCCCCC">
92 <h1>Native Client Quake Demo
</h1>
93 <span style=
"color:999999">
95 Quake, a classic first person shooter released in
1996 by Id Software.
96 Now open source, this demo is playable in the browser as a Native Client
100 Click the game area below to give it keyboard focus, then press the
101 spacebar to activate the game menu. Select single player (hit return
102 to select) then select new game. Controls: arrow keys to move, space
103 to jump, control key to fire, numeric keys to select various weapons
104 aquired along the way. Audio is also supported on systems with audio
105 drivers installed. Multiplayer mode is not supported. Loading and
106 saving game progress is not supported.
111 <embed id=
"embed1" src=
"nacl_quake" type=
"application/x-nacl-srpc" width=
800 height=
600>