HTML and CSS Reference
In-Depth Information
<!doctype html>
<html
<html lang= "en" >
<head>
<head>
<meta
<meta charset= "UTF-8" >
<title>
<title> CH5EX14: Simple Gravity </title>
</title>
< script src = "modernizr.js" >< /script>
< script type = "text/javascript" >
window . addEventListener ( 'load' , eventWindowLoaded , false
false );
function
function eventWindowLoaded () {
canvasApp ();
}
function
function canvasSupport () {
return
return Modernizr . canvas ;
}
function
function canvasApp () {
iif ( ! canvasSupport ()) {
return
return ;
}
function
function drawScreen () {
context . fillStyle = '#EEEEEE' ;
context . fillRect ( 0 , 0 , theCanvas . width , theCanvas . height );
//Box
context . strokeStyle = '#000000' ;
context . strokeRect ( 1 , 1 , theCanvas . width - 2 , theCanvas . height - 2 );
iif ( ball . y + ball . radius <= theCanvas . height ) {
ball . velocityy += gravity ;
} else
else {
ball . velocityx = 0 ;
ball . velocityy = 0 ;
ball . y = theCanvas . height - ball . radius ;
}
ball . y += ball . velocityy ;
ball . x += ball . velocityx ;
context . fillStyle = "#000000" ;
context . beginPath ();
context . arc ( ball . x , ball . y , ball . radius , 0 , Math . PI * 2 , true
true );
context . closePath ();
Search WWH ::




Custom Search