Repository: dwmkerr/spaceinvaders
Branch: master
Commit: c1bf211a2ea0
Files: 12
Total size: 36.1 KB
Directory structure:
gitextract_h53fahbv/
├── .github/
│ ├── FUNDING.yml
│ └── workflows/
│ └── main.yml
├── .gitignore
├── .replit
├── LICENSE
├── README.md
├── css/
│ ├── core.css
│ └── typeography.css
├── index.html
├── js/
│ ├── spaceinvaders.js
│ └── starfield.js
└── makefile
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
# Support 'GitHub Sponsors' funding.
github: dwmkerr
================================================
FILE: .github/workflows/main.yml
================================================
name: Publish to GitHub Pages
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Build and Deploy
uses: JamesIves/github-pages-deploy-action@releases/v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_BRANCH: master # Deploy from master...
BRANCH: gh-pages # ...to GitHub pages...
BUILD_SCRIPT: make build # ...run the build action...
FOLDER: artifacts/dist # ...copy the distribution folder.
================================================
FILE: .gitignore
================================================
spaceinvaders.sublime-project
spaceinvaders.sublime-workspace
================================================
FILE: .replit
================================================
language = "html"
run = ""
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2019 Dave Kerr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Space Invaders
The classic Space Invaders game written in JavaScript as a learning exercise.
No jQuery or any other third party libraries, just raw JavaScript, CSS and HTML.
See it Live: [https://dwmkerr.github.io/spaceinvaders/](https://dwmkerr.github.io/spaceinvaders/)
[](https://dwmkerr.github.io/spaceinvaders/)
## Intro
[](https://repl.it/github/dwmkerr/spaceinvaders)
What's there to say? It's Space Invaders in JavaScript!
Create the game, give it a `div` to draw to, tell it when the keyboard is mashed and that's all you need to add Space Invaders to a website.
This is a simple learning exercise, so the JavaScript is deliberate kept all one file. There's no linting, testing, CI, or anything like that. If you want to see such patterns in front-end JavaScript, check out something like [angular-modal-service](https://github.com/dwmkerr/angular-modal-service).
## Adding Space Invaders to a Web Page
First, drop the `spaceinvaders.js` file into the website.
Now add a canvas to the page.
```html
```
Next, add the Space Invaders game code. You create the game, initialise it with the canvas, start it and make sure you tell it when a key is pressed or released. That's it!
```html
```
## References
Other bits and pieces that are useful can be dropped here.
- The sounds came from [http://www.classicgaming.cc/classics/spaceinvaders/sounds.php](http://www.classicgaming.cc/classics/spaceinvaders/sounds.php)
## Publishing
On changes to the `master` branch, the GitHub Pages site will be automatically updated.
================================================
FILE: css/core.css
================================================
/* core.css */
/* lean and simple css reset, based on Tantek Celik's reset - see comments below. */
/* (c) 2004-2010 Tantek Çelik. Some Rights Reserved. http://tantek.com */
/* This style sheet is licensed under a Creative Commons License. */
/* http://creativecommons.org/licenses/by/2.0 */
/* Purpose: undo some of the default styling of common browsers */
:link,:visited,ins { text-decoration:none }
nav ul,nav ol { list-style:none }
dl,ul,ol,li,
h1,h2,h3,h4,h5,h6,
html,body,pre,p,blockquote,
form,fieldset,input,label
{ margin:0; padding:0 }
abbr, img, object,
a img,:link img,:visited img,
a object,:link object,:visited object
{ border:0 }
address,abbr { font-style:normal }
iframe:not(.auto-link) { display:none ! important; visibility:hidden ! important; margin-left: -10000px ! important }
a {
color: #0088cc;
text-decoration: none;
}
a:hover,
a:focus {
color: #005580;
text-decoration: underline;
}
================================================
FILE: css/typeography.css
================================================
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 20px;
color: #333333;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 10px 0;
font-family: inherit;
font-weight: bold;
line-height: 20px;
color: inherit;
text-rendering: optimizelegibility;
}
h1,
h2,
h3 {
line-height: 40px;
}
h1 {
font-size: 38.5px;
}
h2 {
font-size: 31.5px;
}
h3 {
font-size: 24.5px;
}
h4 {
font-size: 17.5px;
}
h5 {
font-size: 14px;
}
h6 {
font-size: 11.9px;
}
================================================
FILE: index.html
================================================
Space Invaders
Move with arrow keys or swipe, fire with the space bar or touch. The invaders get faster and drop
more bombs as you complete each level!