In a place where your fantasy can roam free, there won't be any boundaries to what your imagination can create.
Misha’s Tech Playground
graphics, fun and code play
I'm crazy - but who cares? My ideas are constantly dwelling and this is the place for them to pour out and form into something good. Only active participation will ultimately make this place come to life.
Game Engine Preview
Since the class hierarchy is almost finalized I thought I post a little sneak peek of what is to be expected.
Not everything shown here will make it into the first release, unfortunately. But be assured that development is in progress...
You might notice that this looks a lot like pseudo code, but I just don't want to throw around pieces that aren't finalized yet.
So without further ado, here's some code to stick your nose in...
-
/**
-
* CGE
-
* the Object holding it all together
-
*
-
* also offers all constants and bitmask for configuration
-
*
-
* @var string
-
*/
-
var CGE = {
-
// accessors
-
LEFT: 0,
-
TOP: 1,
-
RIGHT: 2,
-
BOTTOM: 3,
-
-
HEIGHT: 1,
-
WIDTH: 0,
-
-
X: 0,
-
Y: 1,
-
-
// tile constants
-
BARRIER_WALK : 0x1,
-
BARRIER_FLY : 0x2,
-
BARRIER_SHOOT: 0x4,
-
BARRIER_SPELL: 0x8,
-
-
// item constants
-
ITEM_PICKABLE: 0x1,
-
ITEM_USEABLE : 0x2,
-
ITEM_WEARABLE: 0x4,
-
ITEM_QUEST_ITEM: 0x8,
-
-
tileH: 0, // tile height
-
tileW: 0, // tile height
-
};
-
-
-
/**
-
* CharacterAttribute
-
* any character will have on of these, even NPC and villains
-
*
-
* @author Torsten Walter
-
*/
-
-
CGE.CharacterAttribute = new AJS.Class({
-
// attributes range from 0 (non existant) to 99,
-
// different classes might have different limits
-
age: 0, // just a number
-
charisma: 0, // important in one on one talk
-
dexterity: 0, // important for lock picking and distance weapons
-
experience: 0, // experience points
-
gender: 0, // 0 female, 1 male, 2 n/a (monster?)
-
health: 0, // deducted if hit
-
attPoints: 0, // base attack points before modification
-
defPoints: 0, // base defense points before modification
-
// number is substracted from 50 and multiplied by 2,
-
// result is mod percentage for successful attack, defense and magic dice rolls
-
// ex: roll of 10 is required, 11 is rolled, luck is 40, 2 is substracted
-
// from the rolled dice ((40-50)*2 = -20%)
-
luck: 0,
-
mana: 0, // magical power
-
name: "",
-
stamina: 0, // how fast the caracter recovers from injury
-
strength: 0, // how much hit points and carrying weight
-
});
-
-
-
/**
-
* Entity
-
* Base class for all interactive and non interactive game objects
-
*
-
*/
-
CGE.Entity = new AJS.Class({
-
-
elm: null, // because we stack tiles, we need a box for each stack
-
gfx: null, // reference to the associated TileGfx object
-
-
next: null, // used for tile stacking
-
offset: [0,0],
-
size: [0,0],// actual tile size, might be different from grid size
-
-
x: 0,
-
y: 0,
-
z: 0,
-
-
init: function(x, y, z, o) {}
-
});
-
-
-
/**
-
* Tile
-
* Any to a map belonging elements in the game use or extend this class
-
* e.g. floor tiles, walls, doors
-
*
-
*/
-
CGE.Tile = CGE.Entity.extend({
-
east: null, // neighbors
-
north: null,
-
south: null,
-
west: null,
-
init: function (x, y, z, o, tW, tH, img) {},
-
initGfx: function (img) {},
-
getImg: function () {},
-
setImg: function (img) {},
-
getPos: function () {},
-
setPos: function (pos) {}
-
});
-
-
-
/**
-
* TileGfx
-
* wrapper for actual tile Graphic,
-
* is different for SVG and HTML
-
*
-
*/
-
CGE.TileGfx = new AJS.Class({
-
img: null, // the actual graphic
-
init: function (img, offset, z) {},
-
get: function () {},
-
set: function (img) {},
-
pos: function (pos) {},
-
setZ: function(z) {}
-
});
-
-
-
/**
-
* Classes derived from Entity
-
* Characters, Items and Weapons
-
*
-
*/
-
-
CGE.Character = CGE.Entity.extend({});
-
-
CGE.PlayableChar = CGE.Character.extend({});
-
-
CGE.Hero = CGE.PlayableChar.extend({});
-
-
CGE.Item = CGE.Entity.extend({});
-
-
CGE.UsableItem = CGE.Item.extend({});
-
-
CGE.MagicalItem = CGE.UsableItem.extend({});
-
-
CGE.Weapon = CGE.Item.extend({});
-
-
CGE.MagicalWeapon = CGE.MagicalItem.extend({});
-
-
-
/**
-
* Map
-
* handles the raw map data and tile creation, no GUI or Graphics
-
* but has mouse and keyboard methods (move, click)
-
*
-
*/
-
-
CGE.Map = new AJS.Class({});
-
-
-
/**
-
* IsoMap
-
* extends map to work with isometric tiles
-
*
-
*/
-
CGE.IsoMap = CGE.Map.extend({});
-
-
-
/**
-
* MapEditor
-
* offers map editing functions and provides GUI
-
*
-
*/
-
CGE.MapEditor = new AJS.Class({});
-
-
-
/**
-
* MapEditor
-
* extends certain methods to work with iso maps
-
*
-
*/
-
CGE.IsoMapEditor = CGE.MapEditor.extend({});
-
-
// helper functions
-
-
-
/**
-
* Loader
-
* handles file loading operations for ALL game relevant date and
-
* returns appropriate objects
-
*
-
*/
-
CGE.Loader = new AJS.Class({
-
init: function () {},
-
loadJson: function () {},
-
loadXml: function () {},
-
loadYml: function () {}
-
});
-
-
-
/**
-
* Panel
-
* extends screen, single display unit like popover, map slot or power bars
-
*
-
*/
-
CGE.Panel = CGE.ViewPort.extend({
-
contents: null,
-
init: function () {},
-
hide: function () {},
-
show: function () {},
-
});
-
-
-
/**
-
* Progress
-
* handles progress monitoring, showing busy nimation or percentage
-
*
-
*/
-
CGE.Progress = CGE.Panel.extend({
-
busySrc: "",
-
normSrc: "",
-
init: function () {},
-
busy: function () {},
-
tick: function () {}
-
});
-
-
-
/**
-
* ViewPort
-
* Base class of all display related classes,
-
* handles all rendering tasks
-
*
-
*/
-
CGE.ViewPort = new AJS.Class({
-
height: 0,
-
left: 0,
-
top: 0,
-
width: 0,
-
init: function () {},
-
clear: function () {},
-
paint: function () {}
-
});
Tags: code performance, Games, JavaScript Library, pbbg, tile graphics
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Leave a Reply