8 Directions graphics plugin

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
I created this for myself and I thought that I might aswell upload it.


To use it you must:


 1 - insert "8dir" in the name of the file (wherever you want)
 2 - put the 4 diagonal graphics right below the normal cross movement graphics, just as they where an another character
 3 - be sure the diagonal movement graphics are facing directions in this order: South-West, NW, SE, NE
 4 - choose either both top(normal) and bottom(diagonal) graphic sheet for the character, the code accounts for it
 5 - if you want a cahracter to face a diagonal direction during, for example, a set-mouve-route, just call "this.setDirection(direction_id)" via script.
     if you want to know which id(number) stands for which direction just look at your numpad and imagine the character instead of the "5" key


You can find this same instructions also in the plugin help.


Here is an example graphic if you want to see how the 8dr graphic should be like


(ps i didnt' create this graphic, i found it on goole, i just rearranged the sprites and resized the image)


| ---


basically is the standard 4 x 2 character sheet, you just put the diag graphics in the bottom slot.


I hope you'll find this usefull :)


Plugin code     (dowload here: View attachment 8dir_graphics.js)

Code:
//=============================================================================
// 8dir_graphics.js
//=============================================================================
/*:
 * @plugindesc you can use 8 directions graphics
 *
 * @author Orcomarcio
 *
 * @help to use 8 direction graphics: 
 1 - insert "8dir" in the name of the file (wherever you want)
 2 - put the 4 diagonal graphics right below the normal cross movement graphics, just as they where an another character
 3 - be sure the diagonal movement graphics are facing directions in this order: South-West, NW, SE, NE
 4 - choose either both top(normal) and bottom(diagonal) graphic sheet for the character, the code accounts for it
 5 - if you want a cahracter to face a diagonal direction during, for example, a set-mouve-route, just call "this.setDirection(direction_id)" via script.
     if you want to know which id(number) stands for which direction just look at your numpad and imagine the character instead of the "5" key
 *
 * Free for commercial and non commercial use.
 */

 ImageManager.is8DirCharacter = function(filename) {
    return filename.contains('8dir');
};


var alias_Game_CharacterBase_initMembers = Game_CharacterBase.prototype.initMembers;
Game_CharacterBase.prototype.initMembers = function() {
    alias_Game_CharacterBase_initMembers.call(this); //calls original method

    // added lines
    this._dir8 = this._direction;
    this._isDir8 = false;
    this._originalCharacterIndex;
};

var alias_CharacterBase_update = Game_CharacterBase.prototype.update
Game_CharacterBase.prototype.update = function() {
    alias_CharacterBase_update.call(this); //calls original method

    // added lines
    this.updateDir8();
};

Game_CharacterBase.prototype.setImage = function(characterName, characterIndex) {
    this._tileId = 0;
    this._characterName = characterName;
    this._characterIndex = characterIndex;
    this._isObjectCharacter = ImageManager.isObjectCharacter(characterName);

    // added lines
    this._isDir8 = ImageManager.is8DirCharacter(characterName);
    this._originalCharacterIndex = (this._isDir8 && this._characterIndex > 3) ? this._characterIndex - 4 : this._characterIndex;
};

Game_CharacterBase.prototype.setDirection = function(d) {
    if (!this.isDirectionFixed() && d) {

        var dir4;
        switch (d) {
            case 1:
                dir4 = 2;
                break;
            case 3:
                dir4 = 6;
                break;
            case 7:
                dir4 = 4;
                break;
            case 9:
                dir4 = 8;
                break;
            default:
                dir4 = d;
        }

        this._direction = dir4;
        this._dir8 = d;
    }

    this.resetStopCount();
};

Game_CharacterBase.prototype.updateDir8 = function() {
    if (this._isDir8) {
        if (this._dir8 % 2 == 0) {
            // direzione a croce
            this._characterIndex = this._originalCharacterIndex;
        }
        else {
            // direzione in diagonale
            this._characterIndex = this._originalCharacterIndex + 4;
        }
    }
};

Game_CharacterBase.prototype.moveDiagonally = function(horz, vert) {
    this.setMovementSuccess(this.canPassDiagonally(this._x, this._y, horz, vert));
    if (this.isMovementSucceeded()) {
        this._x = $gameMap.roundXWithDirection(this._x, horz);
        this._y = $gameMap.roundYWithDirection(this._y, vert);
        this._realX = $gameMap.xWithDirection(this._x, this.reverseDir(horz));
        this._realY = $gameMap.yWithDirection(this._y, this.reverseDir(vert));
        this.increaseSteps();
    }

    if (horz == 4) {
        if (vert == 2)  this.setDirection(1);
        else            this.setDirection(7);
    } else {
        if (vert == 2)  this.setDirection(3);
        else            this.setDirection(9);
    }
};
 
Last edited by a moderator:

NeoPGX

~ King of Cuteness ~
Veteran
Joined
May 15, 2014
Messages
847
Reaction score
175
First Language
English (US)
Primarily Uses
N/A
This definitely looks useful, Of course the challenge would be creating the diagonal sprites.
 

Valancourt

Villager
Member
Joined
Aug 11, 2013
Messages
25
Reaction score
2
First Language
English
Primarily Uses
Can you make a video showing this? this wasn't explained too well..
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top