mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
first attempt to implement GameObject
This commit is contained in:
parent
aa30a23ca1
commit
fe0d4a66e2
14 changed files with 328 additions and 129 deletions
31
app/Game/Client/GameObjects/GameObject.js
Normal file
31
app/Game/Client/GameObjects/GameObject.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/GameObject"
|
||||
],
|
||||
|
||||
function(Parent) {
|
||||
|
||||
function GameObject(physicsEngine, view) {
|
||||
this.view = view;
|
||||
Parent.call(this, physicsEngine);
|
||||
this.createMesh();
|
||||
this.render();
|
||||
}
|
||||
|
||||
GameObject.prototype = Object.create(Parent.prototype);
|
||||
|
||||
GameObject.prototype.destroy = function() {
|
||||
// view ...
|
||||
Parent.prototype.destroy.call(this);
|
||||
};
|
||||
|
||||
GameObject.prototype.render = function() {
|
||||
throw new Exception('Abstract method GameObject.render not overwritten');
|
||||
}
|
||||
|
||||
GameObject.prototype.createMesh = function() {
|
||||
throw new Exception('Abstract method GameObject.getMesh not overwritten');
|
||||
};
|
||||
|
||||
return GameObject;
|
||||
|
||||
});
|
||||
48
app/Game/Client/GameObjects/Tile.js
Normal file
48
app/Game/Client/GameObjects/Tile.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Tile",
|
||||
"Game/Config/Settings"
|
||||
],
|
||||
|
||||
function (Parent, Settings) {
|
||||
|
||||
function Tile(physicsEngine, view, options) {
|
||||
Parent.call(this, physicsEngine, view, options);
|
||||
}
|
||||
|
||||
Tile.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Tile.prototype.createMesh = function() {
|
||||
var self = this;
|
||||
|
||||
var material = "Stones";
|
||||
var imgPath = Settings.GRAPHICS_PATH
|
||||
+ Settings.GRAPHICS_SUBPATH_TILES
|
||||
+ material + '/'
|
||||
+ this.options.s + ''
|
||||
+ this.options.r + '.gif';
|
||||
|
||||
var callback = function(mesh) {
|
||||
self.mesh = mesh;
|
||||
self.view.addMesh(mesh);
|
||||
}
|
||||
|
||||
this.view.createMesh(
|
||||
Settings.TILE_SIZE,
|
||||
Settings.TILE_SIZE,
|
||||
0,
|
||||
0,
|
||||
imgPath,
|
||||
callback
|
||||
);
|
||||
};
|
||||
|
||||
Tile.prototype.render = function() {
|
||||
this.view.updateMesh(this.mesh, {
|
||||
x: this.options.x * Settings.TILE_SIZE,
|
||||
y: this.options.y * Settings.TILE_SIZE,
|
||||
})
|
||||
}
|
||||
|
||||
return Tile;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue