Skip to content

Commit

Permalink
Add Dockerfile for running the game in the browser
Browse files Browse the repository at this point in the history
  • Loading branch information
mlesniew committed Sep 6, 2021
1 parent b92d30d commit 8e06879
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# this file is based on https://earthly.dev/blog/dos-gaming-in-docker/

FROM node:16-alpine

WORKDIR site

# js-dos
ADD https://js-dos.com/6.22/current/js-dos.js .
ADD https://js-dos.com/6.22/current/wdosbox.js .
ADD https://js-dos.com/6.22/current/wdosbox.wasm.js .

# the game itself
ADD https://github.com/mlesniew/kosmici/releases/download/1.0/kosmita.zip kosmita.zip

# add the index
COPY index.html .

# entrypoint
ENTRYPOINT npx serve -l tcp://0.0.0.0:8000
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Kosmici
# Kosmici Atakują

`Kosmici` is a simple shoot 'em up DOS game that I wrote in high school.

Expand All @@ -19,6 +19,22 @@ curl -L https://github.com/mlesniew/kosmici/releases/download/1.0/kosmita.tgz |
dosbox kosmita.exe
```


## Running with js-dos in the browser

The game can also be run with [js-dos](https://js-dos.com/) in the browser. The required server setup can be easily
done with Docker:
```
git clone [email protected]:mlesniew/kosmici.git
cd kosmici
docker build -t kosmita .
docker run --rm -p8000:8000 kosmita
```

The game will be available at [http://localhost:8000](http://localhost:8000). Unfortunately, the game can be very
slow when it's run this way.


## How to play

* Use the mouse to move your space ship
Expand Down
25 changes: 25 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<style type="text/css" media="screen">
canvas {
width: 400px;
height: 300px;
}
</style>
<head>
<title>Kosmici Atakują!</title>
<script src="js-dos.js"></script>
</head>
<body>
<canvas id="jsdos" width="400" height="300" ></canvas>
<script>
Dos(document.getElementById("jsdos"), {
autolock: true,
cycles: "max"
}).ready((fs, main) => {
fs.extract("kosmita.zip").then(() => {
main(["-c", "kosmita.exe"])
});
});
</script>
</body>
</html>

0 comments on commit 8e06879

Please sign in to comment.