Skip to content

Contribution to the gamequery #13

@jarodium

Description

@jarodium

Hello selim

I would like to contribute some code to gamequery. Maybe it is not the time but I hope you find it useful for the tilemap editor tool.

Here is the code

var templ_dir = "BASE SITE DIRECTORY";
var templ_imgs = templ_dir+"SPRITE DIRECTORY";
var sprDelta = 32; //default sprite delta ( for use on tilemap, since all animations have the same delta )
var animations = [];

//this sets up a simple sprite into the animations array
function setupSprite(image,offsetx,offsety) {
animations.push(new $.gameQuery.Animation({
imageURL: templ_imgs+image,
type: $.gameQuery.ANIMATION_ONCE,
numberOfFrame: 1,
delta: sprDelta,
rate: 30,
offsetx: offsetx,
offsety: offsety
}));

}

//this allows to setup a building matrix on the animations array
function setupSpriteBuilding(image,startX,startY) {
//this needs some work, because this assumes that the building is composed by 9 tiles, on a 3 rows and 2 colums
//anyway the buildings can be organized in various layouts in the spritesheet.
for(i=0;i<2; i++) {
for(j=0; j<3; j++) {
setupSprite(image,startX+(sprDelta_j),startY+(sprDelta_i));
}
}
}

you call'em like this:

setupSprite('TileA5.png',0,32);
setupSprite('TileA5.png',0,64);

setupSpriteBuilding('edificios.png',192,64);

I'm working on how to make map placement easier, but i'll get there as soon as I can.

Best regards
jarodium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions