This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// retrieve menu item custom url attribute when a | |
add_filter( 'wp_setup_nav_menu_item', 'alphasmanifesto_setup_nav_menu_item' ); | |
function alphasmanifesto_setup_nav_menu_item($menu_item) { | |
$attrName = 'image_url'; // property name | |
$genericProperty = "alphasmanifesto_menu_item_$attrName"; // unique property name -- avoid colliding with other plugins/themes | |
// get it from the database with its id, set it to the menu item | |
$menu_item->image_url = get_post_meta($menu_item->ID, $genericProperty, true); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Arkanoid with canvas</title> | |
<link rel="stylesheet" type="text/css" href="arkanoid.css"> | |
<script type="text/javascript" src="arkanoid.js"></script> | |
</head> | |
<body onload="arkanoid.init();"> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* from http://stackoverflow.com/questions/4288253/html5-canvas-100-width-height-of-viewport */ | |
* { | |
margin: 0; | |
padding: 0; | |
} | |
html, body { | |
width: 100%; | |
height: 100%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.arkanoid = (function(userOptions) { | |
// private fields | |
var canvas = null; | |
var ctx = null; | |
var options = null; | |
var defaultOptions = { | |
fullWidth: true, | |
fullHeight: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ArkanoidStage | |
+function ArkanoidStage(drawingContext, height, width) { | |
+ this.blockWidth = width / 10; | |
+ this.blockHeight = height / 50; | |
+ this.ballRadius = this.blockHeight * 0.8; | |
+ | |
+ var player = new ArkanoidPlayer(drawingContext, "#000", this.blockHeight, this.blockWidth, width, height); | |
+ player.draw(); | |
+ | |
+ return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DrawableEntityBase | |
function DrawableEntityBase(drawingContext, color) { | |
if (!drawingContext) throw "A drawing context needs to be provided."; | |
this.ctx = drawingContext; | |
this.color = color; | |
this.draw = function() { | |
throw "DrawableEntityBase is an abstract class -- needs an implementation!" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DrawableBlock: DrawableEntityBase | |
DrawableBlock.prototype = Object.create(DrawableEntityBase.prototype); | |
DrawableBlock.prototype.constructor = DrawableEntityBase; | |
function DrawableBlock(drawingContext, color, posX, posY, height, width) { | |
DrawableEntityBase.call(this, drawingContext, color); | |
var self = this; | |
self.posX = posX; | |
self.posY = posY; | |
self.height = height; |