Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-white committed Sep 29, 2013
1 parent 6f4ef88 commit 38c9823
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
18 changes: 18 additions & 0 deletions JuggleBalls/Week2/BallObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function BallObject(ball) {
var ballDiv = ball;
var curXpos = 0;
var curYpos = 0;

this.moveHorizontal = moveHorizontal;
this.moveVertical = moveVertical;

function moveHorizontal( pixels ) {
curXpos = curXpos + pixels;
ballDiv.css("left", curXpos+"px");
}

function moveVertical(pixels) {
curYpos = curYpos + pixels;
ballDiv.css("top",curYpos+"px");
}
}
Binary file added JuggleBalls/Week2/CoderDojo-ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions JuggleBalls/Week2/TurtleBall.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<title>TurtleBall</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="TurtleBall.js"></script>
<script type="text/javascript" src="BallObject.js"></script>
</head>
<body>
<button id="btnUp">Up</button>
<button id="btnDown">Down</button>
<button id="btnLeft">Left</button>
<button id="btnRight">Right</button>
<div id="ballDiv"><img src="CoderDojo-ball.png" width='50px' height='50px'/></div>
</body>
</html>
19 changes: 19 additions & 0 deletions JuggleBalls/Week2/TurtleBall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var ball;
$(document).ready(function() {
ball = new BallObject($("#ballDiv"));

$("#btnUp").click(function() {
ball.moveVertical(-10);
});
$("#btnDown").click(function() {
ball.moveVertical(10);
});

$("#btnLeft").click(function() {
ball.moveHorizontal(-10);
});

$("#btnRight").click(function() {
ball.moveHorizontal(10);
});
});
6 changes: 6 additions & 0 deletions JuggleBalls/Week2/jquery-1.10.2.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions JuggleBalls/Week2/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ballDiv {
position: absolute;
}

0 comments on commit 38c9823

Please sign in to comment.