Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added whack html5

  • Loading branch information...
commit 76b29a00ba205b218248cf09f7fe11453f52f5ba 1 parent 5593d46
Allan Callaghan authored
4 development.ini
View
@@ -20,10 +20,10 @@ mako.directories = teachprogramming:templates
# false seems to do **** all, but this isnt a problem because mako is smart and can tell when a template has changed
beaker.cache.enabled = false
beaker.cache.type = memory
-beaker.cache.expire = 86400
+beaker.cache.expire = 300
etag_enabled = false
-etag_expire = day
+etag_expire = hour
[server:main]
30 teachprogramming/static/projects/temp.txt
View
@@ -0,0 +1,30 @@
+ /*
+ var mouse = {};
+ canvas.addEventListener('mousedown', eventMouseDown, true);
+ canvas.addEventListener('mouseup' , eventMouseUp , true);
+ canvas.addEventListener('mousemove', eventMouseMove, true);
+ function eventMouseDown(event) {mouse['B'+event.button]=true; }
+ function eventMouseUp(event) {mouse['B'+event.button]=false;}
+ function eventMouseMove(event) {mouse['X']=event.layerX; mouse['Y']=event.layerY;}
+ */
+
+ /*
+ //var mouse_release = {};
+ function eventMouseUp(event) {mouse_release['B'+event.button]=true; event.preventDefault();}
+ function eventRelease() {
+ for (key in mouse_release) {mouse[key]=false;}
+ mouse_release = {}
+ //for (key in keys_pressed) {if (keys_pressed[key]<0) {keys_pressed[key]=false;}}
+ }
+ //eventRelease();
+ */
+
+
+ /*
+ if (
+ mx>=ball_x && mx<(ball_x+ball_image.width)
+ &&
+ my>=ball_y && my<(ball_y+ball_image.height)
+ ) {
+ */
+
57 teachprogramming/static/projects/whack.html
View
@@ -0,0 +1,57 @@
+<canvas id="canvas_element" width="640" height="480"></canvas><!-- // VER: 1 not demo -->
+<!--<canvas id="canvas_element" width="320" height="240"></canvas><!-- Hack to get demo size alternate from static size // VER: demo -->
+<script>
+ var canvas = document.getElementById('canvas_element');
+ var context = canvas.getContext('2d');
+
+ var interval_id;
+ function start() {interval_id = setInterval(timerEvent, 1000/60);}
+ function pause() {clearInterval(interval_id);}
+
+ var variables = {
+ "color_background": 'rgba(0,0,0,255)',
+ }
+
+ function reset() {
+ variables.ball_x = 0
+ variables.ball_y = 0
+ variables.ball_image = new Image();
+ variables.ball_image.src = "images/smile.gif";
+ variables.click_count = 0;
+ variables.timer_ticks = 0;
+ draw();
+ }
+
+ canvas.addEventListener('mousedown', eventMouseDown, true);
+ function eventMouseDown(event) {
+ var pixel = context.getImageData(event.layerX, event.layerY, 1, 1).data;
+ var pixel_color = 'rgba('+pixel[0]+','+pixel[1]+','+pixel[2]+','+pixel[3]+')';
+
+ if (pixel_color!=variables.background_color) {
+ variables.click_count += 1;
+ variables.ball_x = Math.floor(Math.random()*(canvas.width - variables.ball_image.width ));
+ variables.ball_y = Math.floor(Math.random()*(canvas.height - variables.ball_image.height));
+ draw();
+ }
+
+ if (variables.click_count==10) {
+ alert("your speed "+variables.timer_ticks);
+ reset();
+ }
+ }
+
+ function draw() {
+ context.fillStyle = variables.color_background;
+ context.fillRect(0, 0, canvas.width, canvas.height);
+
+ context.drawImage(variables.ball_image, variables.ball_x, variables.ball_y);
+ }
+
+ function timerEvent() {
+ variables.timer_ticks += 1;
+ }
+
+
+ reset();
+ start();
+</script>
1  teachprogramming/templates/projects/_project.mako
View
@@ -153,6 +153,7 @@ def make_web_ver(source):
<%def name='body()' cached="True" cache_key="${project}.${format}">
+ ##
<%
self.files = [file for file in os.listdir(constants.project_path) if file.startswith('%s.' % project)]
%>
21 teachprogramming/templates/projects/whack.mako
View
@@ -1,7 +1,24 @@
<%inherit file="_project.mako"/>
-
+<%
+ vername = {
+ 'full' :'1',
+ }
+%>
<h1>Whack</h1>
+demo
+${parent.web_demo(vername['full'])}
+
+
+
+
-${self.show_diff(None,'1')}
+<%self:code_section
+ prev_version = "${None}"
+ target_version = "${vername['full']}"
+>
+ <%def name="title()">
+ <h2>Base</h2>
+ </%def>
+</%self:code_section>
Please sign in to comment.
Something went wrong with that request. Please try again.