Grand Prix Circuit
27 Aug 2017Play in the legendary game Grand Prix Circuit in browser. (Uploaded by: colin)
Read morePlay in the legendary game Grand Prix Circuit in browser. (Uploaded by: colin)
Read morePlay in the legendary game Risk The Word Conquest in browser. (Uploaded by: @nib)
Read morePlay in the legendary game Utopia in browser. (Uploaded by: @BlockHeadVincent)
Read morePlay in the legendary game Donkey Kong in browser. (Uploaded by: @megalanya)
Read morePlay in the legendary game Dangerous Dave in the Haunted Mansion in browser.
Read moreIn getting started tutorial we will launch Digger game in browser.
Digger is one of the first PC game. The game was created in 1983. Let`s try to bring this legendary game in our time.
To run this game in browser you will need a zip archive with game, and a server that can host static web page. You can start with a template plunk, codepen:
1 <!doctype html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8">
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>js-dos api</title>
7 <style type="text/css">
8 .dosbox-container { width: 640px; height: 400px; }
9 </style>
10 </head>
11 <body>
12 <div id="dosbox"></div>
13 <br/>
14 <button onclick="dosbox.requestFullScreen();">Make fullscreen</button>
15
16 <script type="text/javascript" src="https://js-dos.com/cdn/js-dos-api.js"></script>
17 <script type="text/javascript">
18 var dosbox = new Dosbox({
19 id: "dosbox",
20 onload: function (dosbox) {
21 dosbox.run("https://js-dos.com/cdn/digger.zip", "./DIGGER.COM");
22 },
23 onrun: function (dosbox, app) {
24 console.log("App '" + app + "' is runned");
25 }
26 });
27 </script>
28 </body>
29 </html>
First of all we should prepare viewport where dosbox will render the game. Look at line 8 we set the dosbox-container
size to 640x400 px. This means that Digger will runs in screen with resolution 640x400 px.
At line 16 the js-dos-api.js
was included. After processing this line, browser will download js-dos internals and prepare js-dos engine to work.
Finally we should bootstrap Digger game in browser.
1 var dosbox = new Dosbox({
2 id: "dosbox",
3 onload: function (dosbox) {
4 dosbox.run("https://js-dos.com/cdn/digger.zip", "./DIGGER.COM");
5 },
6 onrun: function (dosbox, app) {
7 console.log("App '" + app + "' is runned");
8 }
9 });
On line 4 we actually start the game:
1 dosbox.run("https://js-dos.com/cdn/digger.zip", "./DIGGER.COM");
Now you can run Digger or any other dos game in browser.
Have fun!