Game Development Reference
In-Depth Information
game from a browser's JavaScript console. Had the game variables all been stored
in the global scope, anyone with access to that would be able to manipulate the
game state. Also, since this function is merely a setup function, this would be the
perfect place to put any conditional logic to load alternate resources based on the
user agent executing the script.
index.html
The host page for this game could not be any briefer. All that we do in this file is
load all of our resources. Since different components sometimes depend on other
components or other modules defined in our game (and since JavaScript provides
no mechanism to load individual components into a script), the order in which our
JavaScript resources are loaded is important.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>2D Space Shooter</title>
<link rel="stylesheet" href="./css/
style.css" />
</head>
<body class="animBody">
<script src="./js/Vec2.js"></script>
<script src="./js/components/
Sprite.js"></script>
<script src="./js/components/
Move.js"></script>
<script src="./js/entities/
Entity.js"></script>
<script src="./js/Canvas.js"></script>
<script src="./js/GameLoop.js"></script>
<script src="./js/components/
TouchDrag.js"></script>
<script src="./js/components/
Physics.js"></script>
<script src="./js/components/
Search WWH ::




Custom Search