HTML and CSS Reference
In-Depth Information
<script src='underscore.js'></script>
<script src='quintus.js'></script>
<script src='quintus_input.js'></script>
<script src='quintus_sprites.js'></script>
<script src='quintus_scenes.js'></script>
<script src='quintus_dom.js'></script>
<script src='rpg.js'></script>
<style>
* { padding:0px; margin:0px; }
#quintus { background-color:black; }
</style>
</head>
<body>
</body>
</html>
As before, this file is almost completely empty except for a few reset styles and the script tags to load the
game.
Setting Up the Game
To start the game, set up a basic structure for the game that sets up the window and loads some art assets.
Rather than reinvent the wheel for a nethack (also known as rogue-like) tileset, some friendly folks on the
Internet have released public domain tilesets that you can use to build the game: http://rltiles.sourceforge.net/ .
The RPG in this chapter uses three of the files from RLTiles to get up and running. These tiles need a little bit
of background removal work to fit nicely into the game, but otherwise they should work well. The images/
directory of this chapter's files have the images set up as needed. Each of the images has a large set of 32-pixel
by 32-pixel images. This game isn't going to put much of the tile set to good use, but rather is just going to pull
random enemy and item images for visual effect.
With these three files in hand, it's time to bootstrap the game. Create the rpg.js file that was mentioned in
the preceding HTML wrapper file and put in the boilerplate code in Listing 13-3 . You also need a level data text
file called level1.txt in a data/ subfolder of your game to run. Right now it doesn't matter what is in the file:
You can copy the one from the chapter assets or just create your own and save an empty file.
Listing 13-3: Bootstrapping the RPG
$(function() {
var Q = window.Q = Quintus()
.include('Input,Sprites,Scenes,DOM')
.domOnly()
.setup('quintus',{ maximize: true });
var tileSize = 32;
var TILE = {
WALL: 10,
FLOOR: 30,
STAIRS: 45
};
var impassableTiles = {
 
 
Search WWH ::




Custom Search