Game (30 marks) You will be creating your own version of the classic Atari ‘Missile Command’ game (https://youtu.be/nokIGklnBGY). This is provided as inspiration, but the possibilities are vast (eg....

2 answer below »
Hi,

I need help with my programming assignment, which I need to use P5.Js library to write this code.




Game (30 marks) You will be creating your own version of the classic Atari ‘Missile Command’ game (https://youtu.be/nokIGklnBGY). This is provided as inspiration, but the possibilities are vast (eg. https://youtu.be/qVK_CMCU5AE) The game involves defending some cities from incoming missiles using an anti-missile platform. The game ends when all of your cities are destroyed. The player typically starts with a limited supply of missiles or a limited fire rate (you may choose to add ‘upgrades’). You should look up some different versions/implementations of the game for ideas. Requirements 1. Multiple Scenes The game must involve at least 4 scenes, there must be a: Loading / splash scene Main menu scene Main game scene Leaderboard scene You should be able to navigate between the scenes Note: each scene needs to only be navigable by at least one other scene (with the exception of the loading scene, it can be a time-oriented screen) 2. Loops The game must use at least 3 loops which are fundamental to the operation of the program. 3. Arrays The game must incorporate at least 3 arrays, with at least 1 of the arrays being used to manage a list of objects on the screen (such as incoming missiles). 4. Interactivity There must exist player interaction using a keyboard. The game needs to handle at least 3 keyboard keys. Using mouse input is optional. 5. Images There must be at least 1 image present in the final product (separate to sprites) that is drawn at an appropriate size. Note: it is up to you, which scene you incorporate the image in. 6. Sprites The p5.play library must be incorporated with a minimum of 3 sprites used. The sprites must have collision detection (between sprites) and must move independently. Sprites must be animated (i.e. a moving object, changing size or colour) 7. Video & Sound The game should use at least 3 sounds and 1 video. Hint: you can use sounds for shooting and video to introduce the game in the main screen. 8. GUI Input At least one type of GUI input is required (e.g. text input, slider, button). The input should affect what is drawn. (Hint: Text input could be useful for high score entry) 9. Data The program needs to read in data from a JSON file where each object must have at least 3 properties. This data must be presented in one of the scenes. Hint: if your themes / ideas of the main game scene conflict/don’t work well with using external data, use the data in the leaderboard scene! 10. Stability The game must feel stable to play. Your game should not feel ‘buggy’. 11. Creativity You must produce creative work that adds complexity to your game. Examples of creative work that add complexity to your game include: Having multiple types of enemies · In addition to incoming missiles, you may have other enemy types that enter to make the game harder Having a dynamic background · Having a scene with a day/night cycle? Or some other animated background. Having multiple weapon types · You could add super weapons, or other beneficial additions to the defenders (shields? Power-ups?) UI & Fonts · You may download and use custom fonts that better fit your theme. Ability to change the difficulty of game · Could be as simple as having two difficulty options that change the number of lives/cities available, or having increased speed of incoming fire / increased toughness of enemy missiles as the game progresses You are encouraged to create your own assets (i.e. missiles, explosions) on top of using public assets from the internet. Note: the ability to creatively expand your game is highly dependent on having basic functionality, such as interactivity. 12. Code You must produce clean, well-written code. This encompasses indentation, meaningful naming of functions & variables, use & overuse of absolute values
Answered 9 days AfterOct 01, 2021

Answer To: Game (30 marks) You will be creating your own version of the classic Atari ‘Missile Command’ game...

Amar Kumar answered on Oct 10 2021
142 Votes
Missile Command_P5.Js/New folder/MissileCommand_FINAL.xhtml





Title and author:

Missile Command





Francisco Esquembre; Aaron Titus

© 2015, Aaron Titus and Francisco Esquembre.
Released under a license.


Missile Command_P5.Js/New folder/_metadata.txt
generated-with: Easy Java/Javascript Simulations, version 5.2, build 151115. Visit http://www.um.es/fem/Ejs
title: Missile Command
logo-image: pvg_missile_command/MissileCommand.png
author: Francisco Esquembre; Aaron Titus
copyright: Aaron Titus and Francisco Esquembre
preferred-width: 600
preferred-height: 800
author-image: common_files/PacoEsquembre2011.png;./common_files/AaronTitus2015.png
source: pvg_MissileCommand.ejss
main-script:
main-simulation: pvg_MissileCommand_Simulation.xhtml
available-languages:
html-contents: pvg_MissileCommand_Contents.xhtml
html-main: pvg_MissileCommand.xhtml
page-title: Game instructions
page-index: pvg_missile_command/pvg_missile_command.xhtml
page-title: Credits
page-index: pvg_missile_command/pvg_missile_command_credits.xhtml
page-title: Missile Command
page-index: pvg_MissileCommand_Simulation.xhtml
resource: pvg_missile_command/bomb.mp3
resource: pvg_missile_command/pvg_missile_command_credits.xhtml
resource: pvg_missile_command/MissileCommand.png
resource: pvg_missile_command/pvg_missile_command.xhtml
resource: common_files/AaronTitus2015.png
resource: common_files/PacoEsquembre2011.png
resource: pvg_missile_command/city0.png
resource: pvg_missile_command/city1.png
resource: pvg_missile_command/city1_black.png
resource: pvg_missile_command/city2.png
resource: pvg_missile_command/city3.png
resource: pvg_missile_command/city4.png
resource: pvg_missile_command/city5.png
resource: pvg_missile_command/explosion.png
resource: pvg_missile_command/TurretGun.png
Missile Command_P5.Js/New folder/_ejs_README.txt

All the files and subdirectories in this directory were extracted from a compressed ZIP file, and contain a Javascript simulation and its auxiliary files, created with Easy Java(script) Simulations .
A simulation directory has several HTML or XHTML files in it:
- A main XHTML file named as the simulation.
- A table of contents XHTML file, named as the simulation plus a “_Contents” suffix.
- A simulation XHTML file, named as the simulation plus a “_Simulation” suffix.
- Possibly, other HTML or XHTML description pages, as included by the author.
To access the complete model with its description pages and simulation in a frame, open the main XHTML file with your favorite browser.
To just run the simulation, open the XHTML file that ends with the "_Simulation" prefix.
A simulation directory also contains a _metadata.txt file that you can inspect to get machine-generated information about the simulation and the different files contained in it.
The simulation ZIP file can also be run on tablets using the EjsS Reader App available in Apple iTunes and in the Google Play store.
Missile Command_P5.Js/New folder/pvg_MissileCommand.xhtml
                
Gee! Your browser is really old and doesn't support frames. You better update!!!

Missile Command_P5.Js/New folder/pvg_missile_command/city0.png
Missile Command_P5.Js/New folder/pvg_missile_command/city1.png
Missile Command_P5.Js/New folder/pvg_missile_command/city4.png
Missile Command_P5.Js/New folder/pvg_missile_command/city1_black.png
Missile Command_P5.Js/New folder/pvg_missile_command/explosion.png
Missile Command_P5.Js/New folder/pvg_missile_command/city3.png
Missile Command_P5.Js/New folder/pvg_missile_command/bomb.mp3
null
1880.8159
Missile Command_P5.Js/New folder/pvg_missile_command/city2.png
Missile Command_P5.Js/New folder/pvg_missile_command/TurretGun.png
Missile Command_P5.Js/New folder/pvg_missile_command/pvg_missile_command_credits.xhtml
Missile Command Credits
Our game is inspired in the original Missile Command game designed
by Atari, Inc.

Resources used in our game:
         Skyline image: Adapted from a public domain image at Pixabay.
         Cannon image : Adapted from a Creative Commons Attribution-Share Alike 2.0 Generic license image in Wikimedia Commons: Kanonrör_(8769896226).
         Explosion image : Adapted from a public domain image released by the United States Navy with the ID 020712-N-5471P-010.
         Explosion sound : Downloaded from http://www.freesfx.co.uk.

Missile Command_P5.Js/New folder/pvg_missile_command/MissileCommand.png
Missile Command_P5.Js/New folder/pvg_missile_command/city5.png
Missile Command_P5.Js/New folder/pvg_missile_command/pvg_missile_command.xhtml
Missile Command
In this game, you will protect cities and yourself by shooting down missiles with bombs. All bombs and missiles in this game move with a constant velocity. The bombs have the same velocity but missiles move at various speeds; some missiles are slower and some missiles are faster.

        To shoot down a missile, click or tap at the location where you want your bomb to explode.
        If a missile is located within the explosion radius of the bomb when it explodes, then the bomb will detonate the missile.
        You win if you can protect at least one of your cities from 50 missiles
        You have one launcher with a limited repository of bombs. If you use up all bombs from the launcher, you are doomed!
        You must take into account the distance the bomb has to travel when anticipating the location of a missile.

Missile Command_P5.Js/New folder/pvg_MissileCommand.ejss


Missile Command
Aaron Titus and Francisco Esquembre
Video Game, Uniform motion, Missile command

Introductory
English

- Sound file by http://www.freesfx.co.uk

false
false
false
false
false
false
false
true
false




./pvg_missile_command/MissileCommand.png
Francisco Esquembre; Aaron Titus
./common_files/PacoEsquembre2011.png;./common_files/AaronTitus2015.png
Permissions: sandbox
Codebase: *
Caller-Allowable-Codebase: *
./common_files/AaronTitus2015.png;./common_files/PacoEsquembre2011.png;./pvg_missile_command/MissileCommand.png;./pvg_missile_command/bomb.mp3;./pvg_missile_command/pvg_missile_command.xhtml;./pvg_missile_command/pvg_missile_command_credits.xhtml;
./pvg_missile_command/;


DESCRIPTION_EDITOR
Game instructions
true
false


_default_
Game instructions
true

./pvg_missile_command/pvg_missile_command.xhtml

DESCRIPTION_EDITOR
Credits
true
false


_default_
Credits
true

./pvg_missile_command/pvg_missile_command_credits.xhtml

24
1

true


VARIABLE_EDITOR
World
true
false



displayScale
3.0/4.0
double





double



xMin
-100
double



xMax
100
double



xRange
xMax-xMin
double



xMiddle
(xMin+xMax)/2
double





double



yMin
0
double



yMax
yMin + xRange/displayScale
double



yRange
yMax-yMin
double



yMiddle
(yMin+yMax)/2
double



rowHeight
yRange/50
double





double



time
0
double



deltaTime
1.0/25
double



maxTime
Number.POSITIVE_INFINITY
double



running
false
boolean



gameOver
false
boolean



replay
false
boolean





boolean



randomGenerator
RNG()
Object



VARIABLE_EDITOR
Display
true
false



SHOW_SCORES
true
boolean



SHOW_AUTOPLAY
true
boolean



SHOW_FULLAUTOPLAY
true
boolean





double



yTopLimit
yMin + yRange*0.83
double



xExtraWidth
xRange/30
double



groundHeight
rowHeight
double



batteryWidth
xRange/10
double



groundData
0
double
[8][2]


destroyedImage
"./pvg_missile_command/explosion.png"
String



VARIABLE_EDITOR
Installations
true
false



nCities
6
int



cityImage
"./pvg_missile_command/city0.png"
String
[nCities]


cityNotDestroyed
true
boolean
[nCities]


cityPos
0
double
[nCities][2]


citySize
0
double
[nCities][2]


turretImage
"./pvg_missile_command/TurretGun.png"
String



turretAngle
0
double



turretNotDestroyed
true
boolean



turretCount
0
int



turretPos
[xMiddle,2*groundHeight]
double
[2]


turretSize
[4*groundHeight,3*groundHeight]
double
[2]


VARIABLE_EDITOR
Missiles
true
false



maxMissiles
50
int



freeMissiles
maxMissiles
int



nMissiles
20
int



missileVis
false
boolean
[nMissiles]


missileTarget
0
int
[nMissiles]


missilePos
0
double
[nMissiles][2]


missileVel
0
double
[nMissiles][2]


missileSize
xRange/100
double



maxNumMisPerStep
3
int



missileMinSpeed
yRange/150/deltaTime
double



missileMaxSpeed
2*missileMinSpeed
double



maxCounter
70
double



roundCounter
maxCounter/2
int





int



VARIABLE_EDITOR
Instructions
true
false



actionsY
yMax-rowHeight
double



scoreY
actionsY-2.5*rowHeight
double



resetX
xMin+xRange/8
double



replayX
xMax-xRange/8
double



autoplayX
xMiddle
double





double



startX
xMiddle
double



startY
yMiddle
double



startWidth
xRange
double



startHeight
rowHeight*4
double



startMessage
"Click or Tap to Start"
String

message to start the game

playAgainMessage
"Click or Tap to Play Again"
String



gameWonMessage
"Congratulations. You Win!"
String

message when aliens are shot

gameSurvivedMessage
"You survived, but the cities were destroyed!"
String



gameLostMessage
"You Lost: all cities were destroyed!"
String



gameOverMessage
"GAME OVER"
String



gameResultMessage
gameLostMessage
String



message
startMessage
String

variable for the message to display

YOU_SURVIVED
1
String



YOU_WIN
2
String



YOU_LOOSE
3
String





String



score
0
int



record
0
int



gameLevel
1
int





String



VARIABLE_EDITOR
Bombs
true
false



maxBombs
100
int



nextBomb
0
int



bombSizeUnit
xRange/150
double



bombExplosionRadius
bombSizeUnit*5
double



bombSpeed
missileMaxSpeed
double



bombPos
0
double
[maxBombs][2]


bombVel
0
double
[maxBombs][2]


bombDiameter
bombSizeUnit
double
[maxBombs]


bombColor
"Blue"
String
[maxBombs]


bombAvailable
true
boolean
[maxBombs]


bombTimeToExplode
-1
double
[maxBombs]




double



VARIABLE_EDITOR
Autoplay
true
false



AUTOPLAY_NONE
0
int



AUTOPLAY_SIMPLE
1
int



AUTOPLAY_AUTO
2
int



AUTOPLAY_USER
3
int



autoplayOption
AUTOPLAY_NONE
int



autoplayText
"None"
String



userAutoplayShowDialog
false
boolean



userAutoplayFunction
undefined
Object





Object



airSpaceHeight
yMin + yRange*0.3
double



autoDefensesFiredForMisile
false
boolean
[nMissiles]




double




CODE_EDITOR
First tasks
true
false



if (replay) randomGenerator.reset(); // See "Random" custom page
else randomGenerator.setResetState();
var userPlay =
"/**\n"+
" * User autoplay function\n"+
" * @param point an array[2] with the coordinates of the point you clicked or tapped (meters).\n"+
" * Must return the angle (in radians) and the time to explosion of the bombs.\n"+
" * For instance: return [Math.PI/2,10]; means a vertical bomb that will\n"+
" * explode in 10 seconds.\n"+
" * Return null if no bomb should be fired.\n"+
" * Predefined functions that you can use in the calculation:\n"+
" * - getTurretPosition(); Returns double[2] array with the X and Y coordinates of the position.\n"+
" * - getNumberOfMissiles(); Returns the number of missiles in the game. \n"+
" * - getMissilePosition(missile); Returns double[2] array with the position of the missile with\n"+
" * the given index. Returns null if the missile is not falling or the index has an invalid value.\n"+
" * - getMissileVelocity(missile); Returns double[2] array with the velocity of the missile with\n"+
" * the given index. Returns null if the missile is not falling or the index has an invalid value.\n"+
" */\n"+
" userAutoplayFunction = function(point) {\n"+
" return null;\n"+
"}";

_view.autoplayTextArea.setValue(userPlay);

CODE_EDITOR
Ground
true
false



groundData = [
[xMin,yMin + groundHeight],
[xMiddle - batteryWidth/2, yMin + groundHeight],
[xMiddle - 1.5*groundHeight, yMin+ 2*groundHeight],
[xMiddle + 1.5*groundHeight, yMin + 2*groundHeight],
[xMiddle + batteryWidth/2, yMin + groundHeight],
[xMax,yMin + groundHeight],
[xMax,yMin - groundHeight],
[xMin,yMin - groundHeight]
];

CODE_EDITOR
Installations
true
false



var min = xMin + batteryWidth/2;
var max = xMiddle - batteryWidth/2;
var dx = (max-min)/nCities;
var x = min + dx;
for (var i=0; i cityPos[i] = [x, yMin+groundHeight];
cityNotDestroyed[i] = true;
switch (i%6) { // Weird way fo doing it, yes. But it will work for Strict ePub
case 0 : cityImage[i] = "./pvg_missile_command/city0.png"; break;
case 1 : cityImage[i] = "./pvg_missile_command/city1.png"; break;
case 2 : cityImage[i] = "./pvg_missile_command/city2.png"; break;
case 3 : cityImage[i] = "./pvg_missile_command/city3.png"; break;
case 4 : cityImage[i] = "./pvg_missile_command/city4.png"; break;
case 5 : cityImage[i] = "./pvg_missile_command/city5.png"; break;
}
citySize[i] = [batteryWidth/1.5,batteryWidth/3];
x += 2*dx;
if (i==(nCities/2-1)) x = xMiddle + batteryWidth/2 + dx;
}
turretImage = "./pvg_missile_command/TurretGun.png";
turretNotDestroyed = true;
turretCount = 0;

CODE_EDITOR
Munno
true
false



resetBombs();
maxCounter = 70;
roundCounter = maxCounter/2;
maxNumMisPerStep = gameLevel;
freeMissiles = maxMissiles;
for (var i = 0; i missileVis[i] = false;
}

CODE_EDITOR
Time
true
false



time = 0;
gameOver = false;
replay = false;
score = 0;
_setFPS(Math.round(1.0/deltaTime));


EVOLUTION_EDITOR
Time
true
false



turretCount--;
if (turretCount<=0) {
turretAngle = 0;
}
if (!running) return;
time += deltaTime;

EVOLUTION_EDITOR
Missiles falling
true
false



if (!running) return;
if (isNaN(chooseAvailableTarget())) return endOfGame(YOU_LOOSE);
for (var i = 0; i if (!missileVis[i]) continue;
missilePos[i][0] += missileVel[i][0]*deltaTime; // Move missile
missilePos[i][1] += missileVel[i][1]*deltaTime;
var x = missilePos[i][0];
var y = missilePos[i][1];
autoplayAction(i);
// Check if the missile hit its target
var target = missileTarget[i];
if (target<0) {
// target = turret
if (y<=turretPos[1]) {
// Hit
turretImage = destroyedImage;
if (turretNotDestroyed) _view.audio.play();
turretNotDestroyed = false;
missileVis[i] = false; // Free missile
}
}
else {
// target = a city
if (y<=cityPos[target][1]) {
// Hit
cityImage[target] = destroyedImage;
if (cityNotDestroyed[target]) _view.audio.play();
cityNotDestroyed[target] = false;
missileVis[i] = false; // // Free missile
}
}
}

EVOLUTION_EDITOR
New Missiles
true
false



if (!running) return;
if (roundCounter===0) {
if (freeMissiles<=0) {
if (missilesStillFalling() || bombsStillExploding()) return;
if (citiesAlive()>0) return endOfGame(YOU_WIN);
return endOfGame(YOU_SURVIVED);
}
createNewMissiles();
}
roundCounter++;
if (roundCounter>maxCounter) roundCounter = 0;

EVOLUTION_EDITOR
Bombs fired
true
false



var i;
for (i = 0; i if (bombTimeToExplode[i]<0) continue; // Not fired
bombPos[i][0] += bombVel[i][0]*deltaTime; // Move the bomb
bombPos[i][1] += bombVel[i][1]*deltaTime;
bombTimeToExplode[i] -= deltaTime; // countdown to explode
var mustExplode = false;
for (var m = 0; m if (!missileVis[m]) continue;
if ((missilePos[m][0]*bombPos[i][1]-missilePos[m][1]*bombPos[i][0])<0.001) {
// bomb trajectory is parallel to that of the missile
if (distance(missilePos[m],bombPos[i]) mustExplode = true;
break;
}
}
}
if (mustExplode || bombTimeToExplode[i]<=0.00001) explodeBomb(i);
}
// For exploded bombs, decrease explosion radius
for (i = 0; i if (bombDiameter[i]<=bombSizeUnit) continue;
bombDiameter[i] -= bombSizeUnit;
if (bombDiameter[i]<=bombSizeUnit) bombAvailable[i] = false;
if (!running && i==maxBombs-1) resetBombs();
}



LIBRARY_EDITOR
Gameplay
true
false



function changeLevel(delta) {
gameLevel += delta;
if (gameLevel<1) gameLevel = 1;
maxNumMisPerStep = gameLevel;
var launched = maxMissiles-freeMissiles;
if (gameLevel>5) maxMissiles = 100;
else maxMissiles = 50;
freeMissiles = maxMissiles-launched;
}
/**
* What to do when the user clicks in a panel
* @param point double[2] the point of the click
*/
function clickAtPoint (point) {
if (Math.abs(point[1]-actionsY) if (Math.abs(point[0]-resetX) < xRange/8) _reset();
else if (Math.abs(point[0]-replayX) < xRange/8) replayGame();
else if (Math.abs(point[0]-autoplayX) < xRange/4) changeAutoplay();
return;
}
if (point[1]>yTopLimit) return; // Ignore clicks in the top display banner
if (running) { // Implement here what happens if you click at a point when the game is running
if (point[1] }
else { // Game is stopped
if (gameOver) {
_initialize();
running = true;
}
else { // Implement here what happens if you click at a point when the game is not running
// console.log ("The game is stopped and you clicked at x = "+point[0]+ ", y = "+point[1]);
running = true;
}
}
}
// What is needed to replay the game (with the same random values)
function replayGame() {
replay = true;
running = false;
_initialize();
}
// What happens when you click at the main message
function clickAtMessage () {
if (!running) { // Game is stopped
if (gameOver) _reset();
else running = true;
}
}
/**
* The game ended
* @param status one of:
* YOU_SURVIVED : you survived but not the cities
* YOU_LOOSE : you died
* YOU_WIN : you won
*/
function endOfGame (status) {
switch(status) {
case YOU_LOOSE : gameResultMessage = gameLostMessage; break;
case YOU_WIN : gameResultMessage = gameWonMessage; break;
case YOU_SURVIVED : gameResultMessage = gameSurvivedMessage; break;
}
message = playAgainMessage;
running = false;
gameOver = true;
if (score>record) record = score;
}

LIBRARY_EDITOR
Tools
true
false



/**
* Returns the turret position
* @return a double[2] array with the X and Y coordinates
*/
function getTurretPosition() {
return [turretPos[0],turretPos[1]];
}
/**
* Returns the number of possible missiles
* @return an integer
*/
function getNumberOfMissiles() {
return nMissiles;
}
/**
* Returns a missile position
* @return a double[2] array with the X and Y coordinates
*/
function getMissilePosition(missile) {
if (!missileVis[missile]) return null;
if (missile<0 || missile>nMissiles) return null;
var pos = missilePos[missile];
return [pos[0],pos[1]];
}
/**
* Returns missile velocity
* @return a double[2] array with the X and Y coordinates of the velocity
*/
function getMissileVelocity(missile) {
if (!missileVis[missile]) return null;
if (missile<0 || missile>nMissiles) return null;
var vel = missileVel[missile];
return [vel[0],vel[1]];
}
/*
* Computes the velocity vector to go from pos to targetPos
* Returns [vx,vy,time to target]
*/
function velocity (speed,pos,targetPos) {
var dx = (targetPos[0]-pos[0]);
var dy = (targetPos[1]-pos[1]);
var distance = Math.sqrt(dx*dx+dy*dy);
return [speed*dx/distance, speed*dy/distance, distance/speed]; // vx,vy, time to target
}
/**
* Distance between two points
*/
function distance (point1,point2) {
var dx = (point2[0]-point1[0]);
var dy = (point2[1]-point1[1]);
return Math.sqrt(dx*dx+dy*dy);
}
/**
* Finds the closest missile to the given position
* @param position array with the X and Y coordinates
* @return the missile index, -1 if no missile is falling
*/
function findClosestMissile(position) {
var closestMissile = -1;
var minDistance = Number.POSITIVE_INFINITY;
var maxIndex = getNumberOfMissiles()-1;
for (var missile = 0; missile<=maxIndex; missile++) {
var missilePosition = getMissilePosition(missile);
if (missilePosition===null) continue; // Not falling
var distanceToMissile = distance (position,missilePosition);
if (distanceToMissile closestMissile = missile;
minDistance = distanceToMissile;
}
}
return closestMissile;
}

LIBRARY_EDITOR
Missiles
true
false

sq

function getFreeMissile () {
for (var i=0; i if (!missileVis[i]) return i;
return -1;
}
function missilesStillFalling() {
for (var i = 0; i if (missileVis[i]) return true;
}
return false;
}

function createNewMissiles () {
var newMs = getRandomInteger (1,maxNumMisPerStep);
for (var i=0; i var free = getFreeMissile();
if (free<0) return; // No missiles left!
missilePos[free] = [getRandomDouble(xMin,xMax), yTopLimit];
var trail = _view.missile_trailSet.getElement(free);
trail.clear();
trail.moveToPoint(missilePos[free]);
var target = chooseAvailableTarget();
if (isNaN(target)) return; // All targets destroyed
var speed = getRandomDouble(missileMinSpeed ,missileMaxSpeed);
missileVel[free] = velocity (speed,missilePos[free], (target<0) ? turretPos : cityPos[target]);
missileTarget[free] = target;
missileVis[free] = true;
autoDefensesFiredForMisile[free] = false;
freeMissiles--;
if (freeMissiles<=0) return;
}
}

LIBRARY_EDITOR
Target
true
false



function targetPosition (target) {
if (target<0) return turretPos;
return cityPos[target];
}
function citiesAlive() {
var nCitiesAlive = 0;
for (var i=0; i if (cityNotDestroyed[i]) nCitiesAlive++;
}
return nCitiesAlive;
}

function chooseAvailableTarget() {
var available = [];
if (turretNotDestroyed) available.push(-1);
for (var i=0; i if (cityNotDestroyed[i]) available.push(i);
}
if (available.length<=0) return Number.NaN;
var targetIndex = getRandomInteger (0, available.length-1);
return available[targetIndex];
}

LIBRARY_EDITOR
Bombs
true
false



function resetBombs() {
var dx = xRange/maxBombs/3;
var min = xMiddle - dx*maxBombs/2;
var max = xMiddle + dx*maxBombs/2;
var x = min + dx;
var y = yMin + 2*groundHeight/3;
for (var i=0; i bombAvailable[i] = true;
bombDiameter[i] = bombSizeUnit;
bombColor[i] = "Blue";
bombPos[i] = [x,y];
bombTimeToExplode[i] = -1;
x += 2*dx;
if (x>=max) {
x = min+dx;
y -= groundHeight/3;
}
}
nextBomb = 0;
}
function addBomb (vx,vy,timeToExplode) {
if (!turretNotDestroyed) return;
console.log ("Bomb added : "+vx+","+vy+","+timeToExplode);
bombPos[nextBomb] = [turretPos[0],turretPos[1]];
bombVel[nextBomb] = [vx,vy];
bombTimeToExplode[nextBomb] = timeToExplode;
nextBomb++;
turretAngle = Math.atan2(vy,vx)-Math.PI/2;
turretCount = 10;
}
function explodeBomb (index) {
bombTimeToExplode[index] = -1;
bombDiameter[index] = 2*bombExplosionRadius;
bombColor[index] = "Red";
for (var m = 0; m if (!missileVis[m]) continue;
if (distance(missilePos[m],bombPos[index]) missileVis[m] = false;
score++;
}
}
}
function bombsStillExploding() {
for (var i = 0; i if (bombAvailable[i] && bombDiameter[i]>bombSizeUnit) return true;
}
return false;
}
function fireBomb(targetPoint) {
if (!turretNotDestroyed) return;
if (nextBomb>=maxBombs) return;
var aimTo;
if (autoplayOption==AUTOPLAY_SIMPLE) {
aimTo = assistedGuidance(targetPoint);
if (aimTo!==null) addBomb(bombSpeed*Math.cos(aimTo[0]),bombSpeed*Math.sin(aimTo[0]),aimTo[1]);
}
else if (autoplayOption==AUTOPLAY_USER) {
aimTo = userAutoplayFunction(targetPoint);
if (aimTo!==null) addBomb(bombSpeed*Math.cos(aimTo[0]),bombSpeed*Math.sin(aimTo[0]),aimTo[1]); }
else {
var bombSetup = velocity(bombSpeed,turretPos,targetPoint);
addBomb (bombSetup[0],bombSetup[1],bombSetup[2]);
}
}

LIBRARY_EDITOR
Autoplay
true
false



// EDIT this function to implement an autoplay strategy
function changeAutoplay() {
if (userAutoplayShowDialog) return userAutoplayEval();
userAutoplayShowDialog = false;
_play();
autoplayOption = (autoplayOption+1) % 4;
if (!SHOW_FULLAUTOPLAY && autoplayOption==AUTOPLAY_AUTO)autoplayOption = AUTOPLAY_USER;
switch (autoplayOption) {
case AUTOPLAY_NONE : autoplayText = "None"; break;
case AUTOPLAY_SIMPLE : autoplayText = "Guided"; break;
case AUTOPLAY_AUTO : autoplayText = "Auto"; break;
case AUTOPLAY_USER :
autoplayText = "User";
userAutoplayShowDialog = true;
_pause();
break;
}
}
/**
* Returns the best launch parameters for the
* missile closest to the given position
* @param point an array[2] with the coordinates
* of the point you clicked or tapped (meters)
* @return an array[2] with [angle, timeToExplode]
*/
function assistedGuidance(position) {
var missile = findClosestMissile(position);
if (missile<0) return null; // no missile around!
return aimToMissile(missile);
}
/**
* Computes the best angle and explosion time to
* destroy a falling missile
* @param missile the integer index for the missile
* @return an array with [angle, timeToExplode]
*/
function aimToMissile(missile) {
var position = getMissilePosition(missile);
var velocity = getMissileVelocity(missile);
var turret = getTurretPosition();
// Compute time
var dx = position[0]-turret[0];
var dy = position[1]-turret[1];
var vx = velocity[0], vy = velocity[1];
var a = bombSpeed*bombSpeed - vx*vx - vy*vy;
var b = - 2 * (dx*vx + dy*vy);
var c = - (dx*dx + dy*dy);
// Get the solution with positive value of the square root
var timeToExplode = ( -b + Math.sqrt(b*b-4*a*c))/(2*a);
// Compute angle
var cosine = (dx+vx*timeToExplode)/(bombSpeed*timeToExplode);
var angle = Math.acos(cosine);
return [angle,timeToExplode];
}
/**
* Action to autommatically destroy a missile
*/
function autoplayAction(missile) {
if (autoplayOption!=AUTOPLAY_AUTO) return;
if (!turretNotDestroyed) return;
if (!autoDefensesFiredForMisile[missile]) { // Fire only once
var position = missilePos[missile];
if (position[1]>airSpaceHeight) return;
var aimTo = aimToMissile(missile);
if (aimTo!==null) {
addBomb (bombSpeed*Math.cos(aimTo[0]),bombSpeed*Math.sin(aimTo[0]),aimTo[1]);
autoDefensesFiredForMisile[missile] = true;
}
}
}
// *** No need to edit this page beyond this point
function userAutoplayEval() {
userAutoplayFunction = undefined;
try {
var userPlay = _view.autoplayTextArea.getValue();
eval(userPlay);
} catch (error) {
userAutoplayFunction = undefined;
}
if (!userAutoplayFunction) {
alert("No valid userAutoplay function provided!\nPlease, edit the userAutoplay function");
autoplayOption = 0;
}
userAutoplayShowDialog = false;
_play();
}

LIBRARY_EDITOR
Random
true
false



// *** No need to edit this page
// Returns a random integer between the given ones, both included
function getRandomInteger(min,max) {
return randomGenerator.nextRange(min,max+1);
}
// Returns a random double between the given ones, both included
function getRandomDouble(min,max) {
return min + randomGenerator.nextDouble()*(max-min);
}
// Random number generator
// Adapted from http://stackoverflow.com/questions/424292/seedable-javascript-random-number-generator
function RNG(seed) {
var self = {};
// LCG using GCC's constants
self.m = 0x80000000; // 2**31;
self.a = 1103515245;
self.c = 12345;
self.firstState = (seed) ? seed : Math.floor(Math.random() * (self.m-1));
self.state = self.firstState;

self.nextInt = function() {
self.state = (self.a * self.state + self.c) % self.m;
return self.state;
};

self.nextDouble = function() { // returns in range [0,1]
return self.nextInt() / (self.m - 1);
};
self.nextRange = function(start, end) {
// returns in range [start, end): including start, excluding end
// can't modulu nextInt because of weak randomness in lower bits
var rangeSize = end - start;
var randomUnder1 = self.nextInt() / self.m;
return start + Math.floor(randomUnder1 * rangeSize);
};
self.setResetState = function() {
self.firstState = self.state;
};

self.reset = function() {
self.state = self.firstState;
};

return self;
}





HTML_VIEW_EDITOR
HtmlView Page
true
false

0
0
23
600
800
true


true
Elements.Panel
topPanel
{
"position" : "absolute",
"top" : "0px",
"margin-left":"0px",
"left":"0%"
}
"100%"
"100%"

true
Elements.DrawingPanel
drawingPanel
topPanel
xMin
yMin
"white"
true
"none"
"100%"
%clickAtPoint%
true
"100%"
yMax
xMax
_view._touch();

false
Elements.Group2D
fieldGroup
drawingPanel

Elements.Shape2D
skyShape
fieldGroup
"rgb(239,239,255)"
xRange
"SOUTH_WEST"
"RECTANGLE"
xMin
yMin
yRange
false

Elements.Shape2D
autoDefenseShape
fieldGroup
"rgba(192,255,255,255)"
xRange
"SOUTH_WEST"
"RECTANGLE"
xMin
yMin
autoplayOption==AUTOPLAY_AUTO
airSpaceHeight
false

Elements.Polygon2D
groundPolygon
fieldGroup
groundData
"Orange"
false

Elements.Image2D
turretImage
drawingPanel
turretAngle
turretPos
"SOUTH"
turretSize
%turretImage%

Elements.ImageSet2D
cities_imageSet
drawingPanel
nCities
cityPos
"SOUTH"
citySize
%cityImage%

Elements.TrailSet2D
missile_trailSet
drawingPanel
nMissiles
missilePos
"Red"
missileVis
true
2

Elements.ShapeSet2D
missiles_shapeSet
drawingPanel
nMissiles
"Blue"
missileSize
missilePos
"ELLIPSE"
missileVis
missileSize

false
Elements.Group2D
messageGroup
drawingPanel
startX
startY
!running

Elements.Text2D
messageText
messageGroup
"Black"
%message%
"normal bold 22px "

Elements.Text2D
gameOverText
messageGroup
rowHeight*6
%gameOverMessage%
gameOver
"normal bold 26px "

Elements.Text2D
gameResultText
messageGroup
rowHeight*3
%gameResultMessage%
gameOver
"normal bold 22px "

Elements.ShapeSet2D
bombs_shapeSet
drawingPanel
maxBombs
%bombColor%
bombDiameter
bombPos
bombAvailable
bombDiameter

Elements.Shape2D
topShape
drawingPanel
"Green"
xRange
"SOUTH"
"RECTANGLE"
xMiddle
yTopLimit
yMax-yTopLimit

false
Elements.Group2D
topGroup
drawingPanel
xMiddle
actionsY

Elements.Text2D
newGameText
topGroup
"Black"
"CENTERED"
resetX
"RESTART"
"normal bold 20px \"Courier New\", Courier, monospace"

Elements.Text2D
autoplayText
topGroup
"Blue"
"CENTERED"
autoplayX
"AUTOPLAY:"+autoplayText
SHOW_AUTOPLAY
"normal bold 20px \"Courier New\", Courier, monospace"

Elements.Text2D
replayText
topGroup
"Black"
"CENTERED"
replayX
"REPLAY"
"normal bold 20px \"Courier New\", Courier, monospace"

true
Elements.Group2D
displayGroup
drawingPanel
xMiddle
scoreY

false
Elements.Group2D
scoreGroup
displayGroup
xMin+0.22*xRange
SHOW_SCORES

Elements.Text2D
scoreTitleText
scoreGroup
"Orange"
"EAST"
"SCORE:"
"normal bold 20px \"Courier New\", Courier, monospace"

Elements.Text2D
scoreText
scoreGroup
"Yellow"
"WEST"
""+score
"normal normal 20px \"Courier New\", Courier, monospace"

Elements.Text2D
recordTitleText
scoreGroup
"Orange"
0.1
"EAST"
0
-2*rowHeight
"RECORD:"
"normal bold 20px \"Courier New\", Courier, monospace"

Elements.Text2D
recordText
scoreGroup
"Yellow"
"WEST"
0
-2*rowHeight
""+record
"normal normal 20px \"Courier New\", Courier, monospace"

true
Elements.Group2D
munnoGroup
displayGroup
autoplayX+xRange/16

Elements.Text2D
missileTitleText
munnoGroup
"Orange"
"EAST"
"MISSILES:"
"normal bold 20px \"Courier New\", Courier, monospace"

Elements.Text2D
missileText
munnoGroup
"Yellow"
"WEST"
""+(maxMissiles-freeMissiles)+"/"+maxMissiles
"normal normal 20px \"Courier New\", Courier, monospace"

Elements.Text2D
bombsTitleText
munnoGroup
"Orange"
0.1
"EAST"
0
-2*rowHeight
"GROUND2AIR:"
"normal bold 20px \"Courier New\", Courier, monospace"

Elements.Text2D
bombsText
munnoGroup
"Yellow"
"WEST"
0
-2*rowHeight
""+(maxBombs-nextBomb)+"/"+maxBombs
"normal normal 20px \"Courier New\", Courier, monospace"

false
Elements.Group2D
levelGroup
displayGroup
replayX+xRange/16

Elements.Text2D
levelTitleText
levelGroup
"Orange"
"EAST"
"LEVEL:"
"normal bold 20px \"Courier New\", Courier, monospace"

Elements.Text2D
levelText
levelGroup
"Yellow"
"WEST"
""+maxNumMisPerStep
"normal normal 20px \"Courier New\", Courier, monospace"

Elements.Text2D
levelDownText
levelGroup
changeLevel(-1);
"Blue"
20
0.1
"CENTERED"
-xRange/12
-2*rowHeight
"DOWN"
"normal bold 20px \"Courier New\", Courier, monospace"
"ENABLED_FIXED"

Elements.Text2D
levelUpText
levelGroup
changeLevel(+1);
"Blue"
20
"CENTERED"
xRange/50
-2*rowHeight
"UP"
"normal bold 20px \"Courier New\", Courier, monospace"
"ENABLED_FIXED"

Elements.Audio
audio
topPanel
"./pvg_missile_command/bomb.mp3"
"none"

true
Elements.Panel
autoplayPanel
{ "position":"fixed",
"top":"50px", "left":"50%",
"zIndex":"99999",
"marginLeft":"-250px",
"overflow":"hidden",
"wordWrap":"break-word"
}
"Gray"
"solid"
"Blue"
userAutoplayShowDialog
400
2
500

Elements.TextArea
autoplayTextArea
autoplayPanel
false
true
"100%"
"100%"
Missile Command_P5.Js/New folder/_ejs_library/html/EjsLauncher.html

Open Source Physics

Easy Java Simulation Models

© Wolfgang Christian
Davidson College, Davidson NC
http://www.opensourcephysics.org
Easy Java Simulations is a modeling and authoring tool created by
Francisco Esquembre
http://www.um.es/fem/Ejs
Missile Command_P5.Js/New folder/_ejs_library/images/CC_icon.png
Missile Command_P5.Js/New folder/_ejs_library/images/Gyroscope.gif
Missile Command_P5.Js/New folder/_ejs_library/images/EjsIcon.gif
Missile Command_P5.Js/New folder/_ejs_library/images/EjsMainIcon.gif
Missile Command_P5.Js/New folder/_ejs_library/images/EjsLogo.gif
Missile Command_P5.Js/New folder/_ejs_library/css/ejsSimulation_default.css
/* This defines styles and classes used in this book */
body { margin-left: 3%; margin-right: 3%; margin-top: 2%; margin-bottom: 5%; text-align: justify; font-size: medium; }
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid !important;
page-break-inside: avoid !important;
text-indent: 0px;
text-align: left;
font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif;}
h1 { text-align: left; color: #C80000; margin: 0; padding: 0.25em; border-top: solid #000000 medium;
border-bottom: solid #000000 thin; font-size: 130% !important;}
h2 { text-align: left; color: #900000; font-size: 115% !important;}
h3 { text-align: left; }
h4 { text-align: left; }
h5 { text-align: left; }
h6 { text-align: left; }
h1.title {text-align: center; color: #0000CC; margin: 0; padding: 0.25em; border-top: solid #000000 medium;
border-bottom: solid #000000 thin; font-size: 130% !important;}
h2.author {text-align: center; color: #000099; font-size: 115% !important;}
h3.date {text-align: center;}
p { font-family: "Times New Roman", "Palatino", Caecilia, serif;
line-height: 1.5em;
margin: 0;
margin-bottom:1.5em;
text-align: justify;
orphans: 2;
widows: 2; }
button { font-family: Georgia, "Times New Roman", Times, serif; font-size: medium; }
code {font-family: monospace; font-size:100% !important; font-weight: bold;}
input[readonly]{
background:#F0F0F0;
color:black;
}
figcaption{
margin: 0 !important;
text-align: center;
font-size: 68%;
margin-top: 1.0em !important;
margin-bottom: 1.0em !important;}
figure img {width: 65% !important; max-width: 2.5in !important;}
p.img {text-align: center; margin-bottom: 0.5em !important;}
p img.respect {width: 35% !important; max-width: 1.5in !important;}
p.anchor {text-align: center !important; margin-bottom: 0.5em !important;}
p a{font-size: 68% !important;}
section.footnotes{margin-top: -1em; margin-bottom: 0em; font-size:smaller;}
ol{list-style-type: lower-alpha;}
section.footnotes li{list-style-type: decimal !important;}
li{margin-top: -1em; margin-bottom: 0em !important;}
ol.toc{ padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none !important; margin: 0; padding: 0;}
/* For source-code highlighting */
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
.centered{ display:block; margin-left:auto; margin-right:auto;}
mspace {white-space: pre !important; content:normal;}
math, math[mode="inline"] {
display: inline;
line-height: 1.0em;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
math[mode="display"] {
display: block;
line-height: 1.0em;
text-align: center;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
msub>*:first-child[mathsize="big"],
msup>*:first-child[mathsize="big"],
msubsup>*:first-child[mathsize="big"],
munder>*:first-child[mathsize="big"],
mover>*:first-child[mathsize="big"],
munderover>*:first-child[mathsize="big"],
mmultiscripts>*:first-child[mathsize="big"],
mroot>*:first-child[mathsize="big"] {
font-size: 125%
}
msub>*:first-child[mathsize="small"],
msup>*:first-child[mathsize="small"],
msubsup>*:first-child[mathsize="small"],
munder>*:first-child[mathsize="small"],
mover>*:first-child[mathsize="small"],
munderover>*:first-child[mathsize="small"],
mmultiscripts>*:first-child[mathsize="small"],
mroot>*:first-child[mathsize="small"] {
font-size: 80%
}
msub>*:first-child,
msup>*:first-child,
msubsup>*:first-child,
munder>*:first-child,
mover>*:first-child,
munderover>*:first-child,
mmultiscripts>*:first-child,
mroot>*:first-child {
font-size: 100%
}
/*Set size values for the other children of script and limit schema (the
script and limit children) - include scriptlevel increment attribute?
*/
msub>*[mathsize="big"],
msup>*[mathsize="big"],
msubsup>*[mathsize="big"],
munder>*[mathsize="big"],
mover>*[mathsize="big"],
munderover>*[mathsize="big"],
mmultiscripts>*[mathsize="big"],
math[display="inline"] mfrac>*[mathsize="big"],
math *[scriptlevel="+1"][mathsize="big"] {
font-size: 89% /* (.71 times 1.25) */
}
msub>* [mathsize="small"],
msup>*[mathsize="small"],
msubsup>*[mathsize="small"],
munder>*[mathsize="small"],
mover>*[mathsize="small"],
munderover>*[mathsize="small"],
mmultiscripts>*[mathsize="small"],
math[display="inline"] mfrac>*[mathsize="small"],
math *[scriptlevel="+1"][mathsize="small"] {
font-size: 57% /* (.71 times .80) */
}
msub>*,
msup>*,
msubsup>*,
munder>*,
mover>*,
munderover>*,
mmultiscripts>*,
math[display="inline"] mfrac>*,
math *[scriptlevel="+1"] {
font-size: 71%
}
mroot>*[mathsize="big"] {
font-size: 62% /* (.50 times 1.25) */
}
mroot>*[mathsize="small"] {
font-size: 40% /* (.50 times .80) */
}
mroot>* {
font-size: 50%
}
/* Set size values for other scriptlevel increment attributes */
math *[scriptlevel="+2"][mathsize="big"] {
font-size: 63% /* (.71 times .71 times 1.25) */
}
math *[scriptlevel="+2"][mathsize="small"] {
font-size: 36% /* (.71 times .71 times .71) */
}
math *[scriptlevel="+2"] {
font-size: 50% /* .71 times .71 */
}
Missile Command_P5.Js/New folder/_ejs_library/css/ejsContentsTop.css
body {
font-family: Georgia, "Times New Roman", Times, serif;
color: purple;
background-color: #C8DFD0;
margin-right: 0px;
}
a { text-decoration: none }
a:link { color: blue }
a:visited { color: purple }
a:hover { text-decoration: underline; }
h1 {
text-align: center;
font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif;
border: 2px solid #000000;
margin-bottom: 0;
}
h2 {
display: inline;
text-align: left;
margin-bottom: 0;
}
div.contents {
display: inline;
margin-bottom: 0;
}
div.intro, div.simulation {
display: inline;
margin: 2px;
padding: 0.3em;
margin-bottom: 0;
}
div.signature {
background: url(../images/EjsLogo.gif) no-repeat 0px 5px;
margin-top: 0;
padding: 15px 65px 54px;
}
Missile Command_P5.Js/New folder/_ejs_library/css/ejsSimulation_AEM.css
/* This defines styles and classes used in this book */
body { margin-left: 3%; margin-right: 3%; margin-top: 2%; margin-bottom: 5%; text-align: justify; font-size: medium; }
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid !important;
page-break-inside: avoid !important;
text-indent: 0px;
text-align: left;
font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif;}
h1 { text-align: left; color:#C80000; margin: 0; padding: 0.0em; font-size: 130% !important; page-break-after: avoid !important;}
h2 { text-align: left; color: #900000; font-size: 120% !important; page-break-after: avoid !important;}
h3 { text-align: left; color:#900000; font-size: 110% !important; page-break-after: avoid !important;}
h4 { text-align: left; }
h5 { text-align: left; }
h6 { text-align: left; }
h1.title {text-align: center; color: #0000CC; margin: 0; padding: 0.25em; border-top: solid #000000 medium;
border-bottom: solid #000000 thin; font-size: 130% !important;}
h2.author {text-align: center; color: #000099; font-size: 115% !important;}
h3.date {text-align: center;}
p { font-family: Georgia, "Times New Roman", Times, serif;
line-height: 1.5em;
margin: 0;
margin-bottom:1.5em;
text-align: justify;
orphans: 2;
widows: 2; }
button { font-family: Georgia, "Times New Roman", Times, serif; font-size: medium; }
code {font-family: monospace; font-size:100% !important; font-weight: bold;}
input[readonly]{
background:#F0F0F0;
color:black;
}
figcaption{
margin: 0 !important;
text-align: center;
font-size: 68%;
margin-top: 1.0em !important;
margin-bottom: 1.0em !important;}
figure img {width: 65% !important; max-width: 2.5in !important;}
p.img {text-align: center; margin-bottom: 0.5em !important;}
p img.respect {width: 35% !important; max-width: 1.5in !important;}
p.anchor {text-align: center !important; margin-bottom: 0.5em !important;}
p a{font-size: 100% !important;}
section.footnotes{margin-top: -1em; margin-bottom: 0em; font-size:smaller;}
ol{list-style-type: lower-alpha;}
section.footnotes li{list-style-type: decimal !important;}
li{margin-top: -1em; margin-bottom: 0em !important;}
ol.toc{ padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none !important; margin: 0; padding: 0;}
/* For source-code highlighting */
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
.centered{ display:block; margin-left:auto; margin-right:auto;}
mspace {white-space: pre !important; content:normal;}
math, math[mode="inline"] {
display: inline;
line-height: 1.0em;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
math[mode="display"] {
display: block;
line-height: 1.0em;
text-align: center;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
msub>*:first-child[mathsize="big"],
msup>*:first-child[mathsize="big"],
msubsup>*:first-child[mathsize="big"],
munder>*:first-child[mathsize="big"],
mover>*:first-child[mathsize="big"],
munderover>*:first-child[mathsize="big"],
mmultiscripts>*:first-child[mathsize="big"],
mroot>*:first-child[mathsize="big"] {
font-size: 125%
}
msub>*:first-child[mathsize="small"],
msup>*:first-child[mathsize="small"],
msubsup>*:first-child[mathsize="small"],
munder>*:first-child[mathsize="small"],
mover>*:first-child[mathsize="small"],
munderover>*:first-child[mathsize="small"],
mmultiscripts>*:first-child[mathsize="small"],
mroot>*:first-child[mathsize="small"] {
font-size: 80%
}
msub>*:first-child,
msup>*:first-child,
msubsup>*:first-child,
munder>*:first-child,
mover>*:first-child,
munderover>*:first-child,
mmultiscripts>*:first-child,
mroot>*:first-child {
font-size: 100%
}
/*Set size values for the other children of script and limit schema (the
script and limit children) - include scriptlevel increment attribute?
*/
msub>*[mathsize="big"],
msup>*[mathsize="big"],
msubsup>*[mathsize="big"],
munder>*[mathsize="big"],
mover>*[mathsize="big"],
munderover>*[mathsize="big"],
mmultiscripts>*[mathsize="big"],
math[display="inline"] mfrac>*[mathsize="big"],
math *[scriptlevel="+1"][mathsize="big"] {
font-size: 89% /* (.71 times 1.25) */
}
msub>* [mathsize="small"],
msup>*[mathsize="small"],
msubsup>*[mathsize="small"],
munder>*[mathsize="small"],
mover>*[mathsize="small"],
munderover>*[mathsize="small"],
mmultiscripts>*[mathsize="small"],
math[display="inline"] mfrac>*[mathsize="small"],
math *[scriptlevel="+1"][mathsize="small"] {
font-size: 57% /* (.71 times .80) */
}
msub>*,
msup>*,
msubsup>*,
munder>*,
mover>*,
munderover>*,
mmultiscripts>*,
math[display="inline"] mfrac>*,
math *[scriptlevel="+1"] {
font-size: 71%
}
mroot>*[mathsize="big"] {
font-size: 62% /* (.50 times 1.25) */
}
mroot>*[mathsize="small"] {
font-size: 40% /* (.50 times .80) */
}
mroot>* {
font-size: 50%
}
/* Set size values for other scriptlevel increment attributes */
math *[scriptlevel="+2"][mathsize="big"] {
font-size: 63% /* (.71 times .71 times 1.25) */
}
math *[scriptlevel="+2"][mathsize="small"] {
font-size: 36% /* (.71 times .71 times .71) */
}
math *[scriptlevel="+2"] {
font-size: 50% /* .71 times .71 */
}
Missile Command_P5.Js/New folder/_ejs_library/css/ejsGroupPage.css
body {
font-family: Georgia, "Times New Roman", Times, serif;
color: purple;
background-color: #C8DFD0;
margin-right: 0px;
}
a { text-decoration: none }
a:link { color: blue }
a:visited { color: purple }
a:hover { text-decoration: underline; }
h1 {
text-align: center;
font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif;
border: 2px solid black;
}
h2 {
text-align: left;
margin-bottom: 3px;
}
div.contents {
border-top: thin solid;
border-bottom: thin solid;
}
div.simulation {
background: #C8DFFF;
margin: 3px 0;
padding: 0.3em;
border-right: 1em solid black;
}
div.abstract {
margin: 3px 0;
padding: 0.3em;
}
Missile Command_P5.Js/New folder/_ejs_library/css/ejsSimulation.css
/* This defines styles and classes used in this book */
body { margin-left: 3%; margin-right: 3%; margin-top: 2%; margin-bottom: 5%; text-align: justify; font-size: medium; }
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid !important;
page-break-inside: avoid !important;
text-indent: 0px;
text-align: left;
font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif;}
h1 { text-align: left; color:#C80000; margin: 0; padding: 0.0em; font-size: 130% !important; page-break-after: avoid !important;}
h2 { text-align: left; color: #900000; font-size: 120% !important; page-break-after: avoid !important;}
h3 { text-align: left; color:#900000; font-size: 110% !important; page-break-after: avoid !important;}
h4 { text-align: left; }
h5 { text-align: left; }
h6 { text-align: left; }
h1.title {text-align: center; color: #0000CC; margin: 0; padding: 0.25em; border-top: solid #000000 medium;
border-bottom: solid #000000 thin; font-size: 130% !important;}
h2.author {text-align: center; color: #000099; font-size: 115% !important;}
h3.date {text-align: center;}
p { font-family: Georgia, "Times New Roman", Times, serif;
line-height: 1.5em;
margin: 0;
margin-bottom:1.5em;
text-align: justify;
orphans: 2;
widows: 2; }
button { font-family: Georgia, "Times New Roman", Times, serif; font-size: medium; }
code {font-family: monospace; font-size:100% !important; font-weight: bold;}
input[readonly]{
background:#F0F0F0;
color:black;
}
figcaption{
margin: 0 !important;
text-align: center;
font-size: 68%;
margin-top: 1.0em !important;
margin-bottom: 1.0em !important;}
figure img {width: 65% !important; max-width: 2.5in !important;}
p.img {text-align: center; margin-bottom: 0.5em !important;}
p img.respect {width: 35% !important; max-width: 1.5in !important;}
p.anchor {text-align: center !important; margin-bottom: 0.5em !important;}
p a{font-size: 100% !important;}
section.footnotes{margin-top: -1em; margin-bottom: 0em; font-size:smaller;}
ol{list-style-type: lower-alpha;}
section.footnotes li{list-style-type: decimal !important;}
li{margin-top: -1em; margin-bottom: 0em !important;}
ol.toc{ padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none !important; margin: 0; padding: 0;}
/* For source-code highlighting */
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
.centered{ display:block; margin-left:auto; margin-right:auto;}
mspace {white-space: pre !important; content:normal;}
math, math[mode="inline"] {
display: inline;
line-height: 1.0em;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
math[mode="display"] {
display: block;
line-height: 1.0em;
text-align: center;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
msub>*:first-child[mathsize="big"],
msup>*:first-child[mathsize="big"],
msubsup>*:first-child[mathsize="big"],
munder>*:first-child[mathsize="big"],
mover>*:first-child[mathsize="big"],
munderover>*:first-child[mathsize="big"],
mmultiscripts>*:first-child[mathsize="big"],
mroot>*:first-child[mathsize="big"] {
font-size: 125%
}
msub>*:first-child[mathsize="small"],
msup>*:first-child[mathsize="small"],
msubsup>*:first-child[mathsize="small"],
munder>*:first-child[mathsize="small"],
mover>*:first-child[mathsize="small"],
munderover>*:first-child[mathsize="small"],
mmultiscripts>*:first-child[mathsize="small"],
mroot>*:first-child[mathsize="small"] {
font-size: 80%
}
msub>*:first-child,
msup>*:first-child,
msubsup>*:first-child,
munder>*:first-child,
mover>*:first-child,
munderover>*:first-child,
mmultiscripts>*:first-child,
mroot>*:first-child {
font-size: 100%
}
/*Set size values for the other children of script and limit schema (the
script and limit children) - include scriptlevel increment attribute?
*/
msub>*[mathsize="big"],
msup>*[mathsize="big"],
msubsup>*[mathsize="big"],
munder>*[mathsize="big"],
mover>*[mathsize="big"],
munderover>*[mathsize="big"],
mmultiscripts>*[mathsize="big"],
math[display="inline"] mfrac>*[mathsize="big"],
math *[scriptlevel="+1"][mathsize="big"] {
font-size: 89% /* (.71 times 1.25) */
}
msub>* [mathsize="small"],
msup>*[mathsize="small"],
msubsup>*[mathsize="small"],
munder>*[mathsize="small"],
mover>*[mathsize="small"],
munderover>*[mathsize="small"],
mmultiscripts>*[mathsize="small"],
math[display="inline"] mfrac>*[mathsize="small"],
math *[scriptlevel="+1"][mathsize="small"] {
font-size: 57% /* (.71 times .80) */
}
msub>*,
msup>*,
msubsup>*,
munder>*,
mover>*,
munderover>*,
mmultiscripts>*,
math[display="inline"] mfrac>*,
math *[scriptlevel="+1"] {
font-size: 71%
}
mroot>*[mathsize="big"] {
font-size: 62% /* (.50 times 1.25) */
}
mroot>*[mathsize="small"] {
font-size: 40% /* (.50 times .80) */
}
mroot>* {
font-size: 50%
}
/* Set size values for other scriptlevel increment attributes */
math *[scriptlevel="+2"][mathsize="big"] {
font-size: 63% /* (.71 times .71 times 1.25) */
}
math *[scriptlevel="+2"][mathsize="small"] {
font-size: 36% /* (.71 times .71 times .71) */
}
math *[scriptlevel="+2"] {
font-size: 50% /* .71 times .71 */
}
Missile Command_P5.Js/New folder/_ejs_library/css/ejsPage.css
/* This defines styles and classes used for OSP-EjsS Description pages*/
body { margin-left: 3%; margin-right: 3%; margin-top: 2%; margin-bottom: 5%; text-align: justify; font-size: medium; }
h1, h2, h3, h4, h5, h6 {
hyphens: none !important;
-moz-hyphens: none !important;
-webkit-hyphens: none !important;
adobe-hyphenate: none !important;
page-break-after: avoid !important;
page-break-inside: avoid !important;
text-indent: 0px;
text-align: left;
font-family: Helvetica, Arial, sans-serif; }
h1 { text-align: left; color: #0000C8; margin: 0; padding: 0.2em; border-top: solid #000000 medium;
border-bottom: solid #000000 thin; font-size: 135% !important;}
h2 { text-align: left; color: #000777; font-size: 120% !important; page-break-after: avoid !important;}
h3 { text-align: left; color:navy; font-size: 110% !important; page-break-after: avoid !important;}
h4 { text-align: left; }
h5 { text-align: left; }
h6 { text-align: left; }
p { font-family: "Times New Roman", "Palatino", Caecilia, serif;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
hyphenate-after: 3;
hyphenate-before: 3;
hyphenate-lines: 2;
-webkit-hyphenate-after: 3;
-webkit-hyphenate-before: 3;
-webkit-hyphenate-lines: 2;
line-height: 1.5em;
margin: 0;
margin-bottom:10pt;
text-align: justify;
orphans: 2;
widows: 2; }
code {font-family: monospace; font-size:100% !important; font-weight: bold;}
h1.title {text-align: center !important; color: ##0000C8!important; margin: 0; padding: 0.25em; border-top: solid #000000 medium !important;
border-bottom: solid #000000 thin !important; font-size: 130% !important;}
h2.author {text-align: center !important; color: #000090 !important; font-size: 115% !important;}
h3.date {text-align: center;}
div.coverImage {text-align: center !important; width: 60% !important;}
img {padding:1px !important;
border:1px solid #021a40 !important;
-moz-box-shadow: 6px 6px 4px #888888;
-webkit-box-shadow: 6px 6px 4px #888888;
box-shadow: 6px 6px 4px #888888;}

p.example{background-color: #F5A9A9 !important;}
p.solution{background-color: #D8D8D8 !important;}
div.example{background-color: #D8D8D8 !important;}
div.figure {text-align: center !important; page-break-inside: avoid !important; page-break-after: avoid !important;}
div img {max-width: 60% !important; max-height: 35% !important; margin-bottom: 0.15em !important;}
p.caption { margin: 0 !important; text-align: center !important; font-size: 75% !important; margin-top: 0.25em !important; margin-bottom: 0.25em !important;}
p.img {text-align: center !important; margin-bottom: -0.35em !important;}
p img {max-width: 35% !important;}
p.a {margin: 0 !important; text-align: center !important; font-size: 75% !important; margin-top: 0.5em !important; margin-bottom: 0.3em !important;}
p.math{text-align: center !important}
p.center {text-align: center !important;}
div.center {text-align: center !important;}
section.footnotes{margin-top: -1em; margin-bottom: 0em; font-size:smaller;}
ol{list-style-type: lower-alpha;}
section.footnotes li{list-style-type: decimal !important;}
li{margin-top: 1em; margin-bottom: 1em !important;}
ol.toc { padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none !important; margin: 0; padding: 0;}
/* For source-code highlighting */
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
mspace {white-space: pre !important; content:normal;}
Missile Command_P5.Js/New folder/_ejs_library/css/ejsSimulation_WC.css
/* This defines styles and classes used in OSP-EjsS simulations*/
body { margin-left: 3%; margin-right: 3%; margin-top: 2%; margin-bottom: 5%; text-align: justify; font-size: medium; }
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid !important;
page-break-inside: avoid !important;
text-indent: 0px;
text-align: left;
font-family: Helvetica, Arial, sans-serif; }
h1 { text-align: left; color: #0000C8; margin: 0; padding: 0.2em; border-top: solid #000000 medium; border-bottom: solid #000000 thin; font-size: 135% !important;}
h2 { text-align: left; color: #000777; font-size: 120% !important; page-break-after: avoid !important;}
h3 { text-align: left; color:navy; font-size: 110% !important; page-break-after: avoid !important;}
h4 { text-align: left; }
h5 { text-align: left; }
h6 { text-align: left; }
p { font-family: "Times New Roman", "Palatino", Caecilia, serif;
line-height: 1.5em;
margin: 0;
margin-bottom:1.0em;
text-align: justify;
orphans: 2;
widows: 2; }
code {font-family: monospace; font-size:100% !important; font-weight: bold;}
h1.title {text-align: center !important; color: #0000C8!important; margin: 0; padding: 0.25em; border-top: solid #000000 medium !important;
border-bottom: solid #000000 thin !important; font-size: 130% !important;}
h2.author {text-align: center !important; color: #000090 !important; font-size: 115% !important;}
h3.date {text-align: center;}
div.coverImage {text-align: center !important; width: 60% !important;}

p.example{background-color: #f5a9A9 !important;}
p.solution{background-color: #d8d8d8 !important;}
div.example{background-color: #d8d8d8 !important;}
div.figure {text-align: center !important; page-break-inside: avoid !important; page-break-after: avoid !important;}
p.caption { margin: 0 !important; text-align: center !important; font-size: 75% !important; margin-top: 0.25em !important; margin-bottom: 0.25em !important;}
p.a {margin: 0 !important; text-align: center !important; font-size: 75% !important; margin-top: 0.5em !important; margin-bottom: 0.3em !important;}
p.math{text-align: center !important}
p.center {text-align: center !important;}
.centered{ display:block; margin-left:auto; margin-right:auto;}
div.center {text-align: center !important;}
section.footnotes{margin-top: -1em; margin-bottom: 0em; font-size:smaller;}
ol{list-style-type: lower-alpha;}
section.footnotes li{list-style-type: decimal !important;}
li{text-align: left; margin-top: 1em; margin-bottom: 1em !important;}
ol.toc { padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none !important; margin: 0; padding: 0;}
/* For source-code highlighting */
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
mspace {white-space: pre !important; content:normal;}
Missile Command_P5.Js/New folder/_ejs_library/css/ejsContentsLeft.css
body {
font-family: Georgia, "Times New Roman", Times, serif;
color: purple;
background-color: #C8DFD0;
margin-right: 0px;
}
a { text-decoration: none }
a:link { color: blue }
a:visited { color: purple }
a:hover { text-decoration: underline; }
h1 {
text-align: center;
font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif;
border: 2px solid black;
}
h2 {
text-align: left;
margin-bottom: 3px;
}
div.contents {
border-top: thin solid;
border-bottom: thin solid;
}
div.intro, div.simulation {
background: #C8DFFF;
margin: 3px 0;
padding: 0.3em;
border-right: 1em solid black;
}
div.simulation {
background: #00DFFF;
}
div.signature {
background: url(../images/EjsLogo.gif) no-repeat 0px 5px;
margin-top: 0;
padding: 15px 65px 54px;
}
Missile Command_P5.Js/New folder/_ejs_library/javascript/OEBPS/stylesheet.css
/* This defines styles and classes used in this book */
body { margin-left: 3%; margin-right: 3%; margin-top: 5%; margin-bottom: 5%; text-align: justify; font-size: medium; }
h1, h2, h3, h4, h5, h6 {
page-break-after: avoid !important;
page-break-inside: avoid !important;
text-indent: 0px;
text-align: left;
font-family: Helvetica, Arial, sans-serif; }
h1 { text-align: left; color: #C80000; margin: 0; padding: 0.25em; border-top: solid #000000 medium;
border-bottom: solid #000000 thin; font-size: 130% !important;}
h2 { text-align: left; color: #900000; font-size: 115% !important;}
h3 { text-align: left; }
h4 { text-align: left; }
h5 { text-align: left; }
h6 { text-align: left; }
h1.title {text-align: center; color: #0000CC; margin: 0; padding: 0.25em; border-top: solid #000000 medium;
border-bottom: solid #000000 thin; font-size: 130% !important;}
h2.author {text-align: center; color: #000099; font-size: 115% !important;}
h3.date {text-align: center;}
p { font-family: "Times New Roman", "Palatino", Caecilia, serif;
line-height: 1.5em;
margin: 0;
margin-bottom:1.5em;
text-align: justify;
orphans: 2;
widows: 2; }

code {font-family: monospace; font-size:100% !important; font-weight: bold;}
figcaption{
margin: 0 !important;
text-align: center;
font-size: 68%;
margin-top: 1.0em !important;
margin-bottom: 1.0em !important;}
img {-moz-box-shadow: 6px 6px 4px #888888;
-webkit-box-shadow: 6px 6px 4px #888888;
box-shadow: 6px 6px 4px #888888;}
figure img {width: 65% !important; max-width: 2.5in !important;}
p.img {text-align: center; margin-bottom: 0.5em !important;}
p img.respect {width: 35% !important; max-width: 1.5in !important;}
p.anchor {text-align: center !important; margin-bottom: 0.5em !important;}
p a{font-size: 68% !important;}
section.footnotes{margin-top: -1em; margin-bottom: 0em; font-size:smaller;}
ol{list-style-type: lower-alpha;}
section.footnotes li{list-style-type: decimal !important;}
li{margin-top: -1em; margin-bottom: 0em !important;}
ol.toc{ padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none !important; margin: 0; padding: 0;}
/* For source-code highlighting */
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
td.sourceCode { padding-left: 5px; }
.centered{ display:block; margin-left:auto; margin-right:auto;}
mspace {white-space: pre !important; content:normal;}
math, math[mode="inline"] {
display: inline;
line-height: 1.0em;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
math[mode="display"] {
display: block;
line-height: 1.0em;
text-align: center;
font-family: STIXGeneral, "Asana Math", "Times New Roman", Times !important;
font-style: normal;
}
msub>*:first-child[mathsize="big"],
msup>*:first-child[mathsize="big"],
msubsup>*:first-child[mathsize="big"],
munder>*:first-child[mathsize="big"],
mover>*:first-child[mathsize="big"],
munderover>*:first-child[mathsize="big"],
mmultiscripts>*:first-child[mathsize="big"],
mroot>*:first-child[mathsize="big"] {
font-size: 125%
}
msub>*:first-child[mathsize="small"],
msup>*:first-child[mathsize="small"],
msubsup>*:first-child[mathsize="small"],
munder>*:first-child[mathsize="small"],
mover>*:first-child[mathsize="small"],
munderover>*:first-child[mathsize="small"],
mmultiscripts>*:first-child[mathsize="small"],
mroot>*:first-child[mathsize="small"] {
font-size: 80%
}
msub>*:first-child,
msup>*:first-child,
msubsup>*:first-child,
munder>*:first-child,
mover>*:first-child,
munderover>*:first-child,
mmultiscripts>*:first-child,
mroot>*:first-child {
font-size: 100%
}
/*Set size values for the other children of script and limit schema (the
script and limit children) - include scriptlevel increment attribute?
*/
msub>*[mathsize="big"],
msup>*[mathsize="big"],
msubsup>*[mathsize="big"],
munder>*[mathsize="big"],
mover>*[mathsize="big"],
munderover>*[mathsize="big"],
mmultiscripts>*[mathsize="big"],
math[display="inline"] mfrac>*[mathsize="big"],
math *[scriptlevel="+1"][mathsize="big"] {
font-size: 89% /* (.71 times 1.25) */
}
msub>* [mathsize="small"],
msup>*[mathsize="small"],
msubsup>*[mathsize="small"],
munder>*[mathsize="small"],
mover>*[mathsize="small"],
munderover>*[mathsize="small"],
mmultiscripts>*[mathsize="small"],
math[display="inline"] mfrac>*[mathsize="small"],
math *[scriptlevel="+1"][mathsize="small"] {
font-size: 57% /* (.71 times .80) */
}
msub>*,
msup>*,
msubsup>*,
munder>*,
mover>*,
munderover>*,
mmultiscripts>*,
math[display="inline"] mfrac>*,
math *[scriptlevel="+1"] {
font-size: 71%
}
mroot>*[mathsize="big"] {
font-size: 62% /* (.50 times 1.25) */
}
mroot>*[mathsize="small"] {
font-size: 40% /* (.50 times .80) */
}
mroot>* {
font-size: 50%
}
/* Set size values for other scriptlevel increment attributes */
math *[scriptlevel="+2"][mathsize="big"] {
font-size: 63% /* (.71 times .71 times 1.25) */
}
math *[scriptlevel="+2"][mathsize="small"] {
font-size: 36% /* (.71 times .71 times .71) */
}
math *[scriptlevel="+2"] {
font-size: 50% /* .71 times .71 */
}
Missile Command_P5.Js/New folder/_ejs_library/javascript/OEBPS/copyright_page.xhtml
Copyright and conditions of use

This ePub was created by its author using the Easy Java/Javascript Simulations modeling and authoring tool, and has been released under a Creative Commons Attribution-NonCommercial-ShareAlike license.


This material is free for non-commercial purposes and lets others remix, tweak, and build upon this work non-commercially, as long as they credit the author and license their new creations under the identical terms. For other uses, permission must be obtained both from the ePub author and from the creators of the EjsS authoring tool and code library.


For more information on Easy Java/Javascript Simulations, please visit the EjsS website.



Missile Command_P5.Js/New folder/_ejs_library/javascript/OEBPS/CC_icon.png
Missile Command_P5.Js/New folder/_ejs_library/javascript/OEBPS/cover-image.png
Missile Command_P5.Js/New folder/_ejs_library/javascript/OEBPS/Gyroscope.gif
Missile Command_P5.Js/New folder/_ejs_library/javascript/OEBPS/title_page.xhtml
Kinematics Physlets
W. Christian and M. Belloni
2014-09-18
Created with EjsS

Missile Command_P5.Js/New folder/_ejs_library/javascript/OEBPS/cover-image.ai
Open Source Physics
Easy JavaScript Simulation Models
created at Davidson College
http://www.opensourcephysics.org
Easy Java/JavaScript Simulations is a modeling and authoring tool created by
Francisco Esquembre
http://www.um.es/fem/Ejs
Missile Command_P5.Js/New folder/_ejs_library/scripts/textresizedetector.js
/**
* @fileoverview TextResizeDetector
*
* Detects changes to font sizes when user changes browser settings
*
Fires a custom event with the following data:
*     iBase : base font size     
*    iDelta : difference in pixels from previous setting
*     iSize : size in pixel of text
*
* * @author Lawrence Carvalho [email protected]
* @version 1.0
*/
/**
* @constructor
*/
TextResizeDetector = function() {
var el = null;
    var iIntervalDelay = 200;
    var iInterval = null;
    var iCurrSize = -1;
    var iBase = -1;
    var aListeners = [];
    var createControlElement = function() {
         el = document.createElement('span');
        el.id='textResizeControl';
        el.innerHTML=' ';
        el.style.position="absolute";
        el.style.left="-9999px";
        var elC = document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID);
        // insert before firstChild
        if (elC)
            elC.insertBefore(el,elC.firstChild);
        iBase = iCurrSize = TextResizeDetector.getSize();
    };
    function _stopDetector() {
        window.clearInterval(iInterval);
        iInterval=null;
    };
    function _startDetector() {
        if (!iInterval) {
            iInterval = window.setInterval('TextResizeDetector.detect()',iIntervalDelay);
        }
    };
    
     function _detect() {
        var iNewSize = TextResizeDetector.getSize();
        
        if(iNewSize!== iCurrSize) {
            for (var     i=0;i                 aListnr = aListeners[i];
                var oArgs = { iBase: iBase,iDelta:((iCurrSize!=-1) ? iNewSize - iCurrSize + 'px' : "0px"),iSize:iCurrSize = iNewSize};
                if (!aListnr.obj) {
                    aListnr.fn('textSizeChanged',[oArgs]);
                }
                else {
                    aListnr.fn.apply(aListnr.obj,['textSizeChanged',[oArgs]]);
                }
            }
        }
        return iCurrSize;
    };
    var onAvailable = function() {
        
        if (!TextResizeDetector.onAvailableCount_i ) {
            TextResizeDetector.onAvailableCount_i =0;
        }
        if (document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID)) {
            TextResizeDetector.init();
            if (TextResizeDetector.USER_INIT_FUNC){
                TextResizeDetector.USER_INIT_FUNC();
            }
            TextResizeDetector.onAvailableCount_i = null;
        }
        else {
            if (TextResizeDetector.onAvailableCount_i<600) {
               TextResizeDetector.onAvailableCount_i++;
                setTimeout(onAvailable,200)
            }
        }
    };
    setTimeout(onAvailable,500);
    return {
             /*
              * Initializes the detector
              *
              * @param {String} sId The id of the element in which to create the control element
              */
             init: function() {
                 
                 createControlElement();        
                _startDetector();
            },
            /**
             * Adds listeners to the ontextsizechange event.
             * Returns the base font size
             *
             */
            addEventListener:function(fn,obj,bScope) {
                aListeners[aListeners.length] = {
                    fn: fn,
                    obj: obj
                }
                return iBase;
            },
            /**
             * performs the detection and fires textSizeChanged event
             * @return the current font size
             * @type {integer}
             */
            detect:function() {
                return _detect();
            },
            /**
             * Returns the height of the control element
             *
             * @return the current height of control element
             * @type {integer}
             */
            getSize:function() {
                     var iSize;
                     return el.offsetHeight;
                 
                 
            },
            /**
             * Stops the detector
             */
            stopDetector:function() {
                return _stopDetector();
            },
            /*
             * Starts the detector
             */
            startDetector:function() {
                return _startDetector();
            }
    }
}();
TextResizeDetector.TARGET_ELEMENT_ID = 'doc';
TextResizeDetector.USER_INIT_FUNC = null;
Missile Command_P5.Js/New folder/_ejs_library/scripts/common_script.js
var _isEPub = false;
var __base64Images =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here