HTML and CSS Reference
In-Depth Information
Table 4-2 shows the complete code for the simplest application, with the ball moving in an arc and no
actual cannon.
Table 4-2.
The First Cannonball Application
Code
Explanation
<html>
Opening
html
tag
<head>
Opening
head
tag
<title>Cannonball</title>
Complete
title
element
<style>
Opening
style
tag
form {
Style for the form
width:330px;
Width
margin:20px;
External
margin
background-color:brown;
Color
padding:20px;
Internal
padding
}
Close this style
</style>
Close
style
element
<script>
Opening
script
tag
var cwidth = 600;
Set value for width of canvas, used for clearing
var cheight = 400;
Set value for
height
of canvas, used for clearing
var ctx;
Variable to hold canvas context
var everything = [];
Array to hold all objects to be drawn. Initialized as an
empty array
var tid;
Variable to hold identifier for the timing event
var horvelocity;
Variable to hold the horizontal velocity (aka
displacement)