-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.js
177 lines (148 loc) · 2.98 KB
/
Game.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
$.Config = {
Tile: { xLen: 32, yLen: 32 }
}
$.Hid = {
var handlerList = {};
function handle(e) {
$.each( )
}
function init() {
$(document).keypress(function(e){
}
$(document).keypress(function(e){
var checkWebkitandIE=(e.which==26 ? 1 : 0);
var checkMoz=(e.which==122 && e.ctrlKey ? 1 : 0);
if (checkWebkitandIE || checkMoz) $("body").append("<p>ctrl+z detected!</p>");
});
}
$.PaneGame = function() {
function init() {
// Create all the chrome
$('#main').append('<div id="game"></div>');
}
init();
return this;
}
$.PaneMenu = function() {
function init() {
// probably need to pull from a certain Pattern here
$('main').append('<div id="menu"></div>');
}
}
$.PaneWorld = function() {
var xLen = 15;
var yLen = 15;
var viewer = null;
var grid = {};
function init() {
$('main').append('<div id="world"></div>');
for( var y=0 ; y<yLen ; ++y ) {
for( var x=0 ; x<xLen ; ++x ) {
var vx = x*$.Config.Tile.xLen;
var vy = y*$.Config.Tile.yLen;
$('world').append('<div class="tile" style="left:'+vx+'px; top:'+vy+'px;"></div>')
}
}
}
function setViewer(entity) {
viewer = entity;
}
return this;
}
$.Model = {
Create: function(modelId,params) {
},
Area: (function() {
return {
};
}),
Terrain: (function() {
return {
typeList: { icon: null, pass: null, seethru: null }
dataList: { x: null, y: null, type: null }
};
}),
Thing: (function() {
return {
fieldList: { icon: null, pass: null, seethru: null, slot: null }
};
})
}
$.Type = {
Create: function(typeId,data) {
// Create the type here.
},
Area: {},
Terrain: {},
Stuff: {}
};
$.Type.Area.Dungeon = {
};
$.Type.Terrain.Floor = {
icon: '.',
pass: { swim: 0 },
seethru: true
};
$.Type.Stuff.Sword = {
icon: '!',
pass: true,
seethru: true,
slot: { hand: 1 }
};
$.Terrain = function(area,xLen,yLen) {
var terrain = [];
function get(id) {
return terrain[['a',id.area || area,'x',id.x,'y',id.y].join('')];
}
function set(id,value) {
terrain[['a',id.area || area,'x',id.x,'y',id.y].join('')] = value;
}
function init() {
for( var x=0 ; x<xLen ; ++x ) {
for( var y=0 ; y<yLen ; ++y ) {
set({x:x,y:y},$.Model.Create($.Type.Terrain.Floor));
}
}
}
this.get = get;
this.set = set;
init();
return this;
}
$.Area = function(xLen,yLen,name) {
}
$.Stuff = function(area) {
function init() {
}
init();
return this;
}
$.World = function() {
var area = new $.Area({xLen})
var xLen = 30;
var yLen = 30;
var area = 'level1';
var terrain = new $.Terrain(area,xLen,yLen);
var stuff = new $.Stuff(area);
// Support only one level at a time.
function init() {
stuff.set(0,$.Model.Create('Stuff',{x: 10, y:10, }))
stuff = $.Model.Create('stuff', {x: 10, y:10, ${
x: 10,
y:
}
}
}
$.Game = (function() {
var state = 'nogame';
function start() {
new $.PaneWorld();
new $.PaneMap();
new $.PaneInventory();
new $.PaneProfile();
}
function init() {
this.paneGame = new $.PaneGame();
this.paneMenu = new $.PaneMenu();
}
}());