Skip to content

Instantly share code, notes, and snippets.

//Atari Breakout Clone, by Benjamint
//Helper Functions
function AABBIntersect(ax, ay, aw, ah, bx, by, bw, bh) {
return ax < bx+bw && ay < by+bh && bx < ax+aw && by < ay+ah;
}
//Constants
var WIDTH=400, HEIGHT=600;
var canvas, ctx, keystate, frames;
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Breakout!</title>
<style>
canvas {
border-color: black;
position: absolute;
margin: auto;
//Helper Functions
//Display
function Display(width, height) {
this.canvas = document.createElement("canvas");
this.canvas.width = this.width = width;
this.canvas.height = this.height = height;
this.ctx = this.canvas.getContext("2d");
document.body.appendChild(this.canvas);
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Snake Game</title>
<!-- Basic styling, centering of the canvas. -->
<style>
canvas {
display: block;