-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
67 lines (50 loc) · 2.16 KB
/
index.html
File metadata and controls
67 lines (50 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!Doctype>
<html>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdn.firebase.com/js/client/2.3.1/firebase.js"></script>
<script src="js/player.js"></script>
<script src="js/world.js"></script>
<script src ="js/urlmanager.js"></script>
<script src="js/localplayer.js"></script>
<script src="js/visitingplayer.js"></script>
<script>
$(document).ready(function(){
var playerFunctions = []; //Array to store all of our player functions
var teleport = function(player, world){ //Write a funciton to let you explore other worlds!
var left = player.playerRef.css('left');
var top = player.playerRef.css('top');
if(parseInt(left) < 0) world.ChangeWorld('left');
else if(parseInt(left) > $('body').width()) world.changeWorld('right');
else if(parseInt(top) < 0) world.ChangeWorld('top');
else if(parseInt(top) > $('body').width()) world.changeWorld('bottom');
}
var movePlayer = function(player, key){ //Function to move player
var left = player.css('left');
var top = player.css('top');
if(key == 37)player.css('left', parseInt(left) - 10);
if(key == 39)player.css('left', parseInt(left) + 10);
if(key == 38)player.css('top', parseInt(top) - 10);
if(key == 40)player.css('top', parseInt(top) + 10);
}
playerFunctions[0] = function(player, world){ //Add move function to array of player functions
$('body').keydown(function(e){ //When key gets pressed
movePlayer(player.playerRef, e.which); //move the player
teleport(player, world);
});
}
var neighborWorlds = { //Worlds I want to be my neighbors
'top':'http://google.com',
'bottom':'http://google.com',
'left':'http://google.com',
'right':'http://google.com'};
var myName = 'nick';
var world = new World(neighborWorlds, myName);
world.Init(playerFunctions);
});
</script>
<body>
<!-- img ID must be the same as the name you passed to your world -->
<img src="include/link.png" id="nick" class="cacheMakersPlayer" style="left:100px; top:100px; position:absolute;">
<h1>Cache Makers HTML Game</h1>
</body>
</html>