8 Directions graphics plugin

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
103
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
785
Reaction score
89
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

Writing out an idea for the No Travel Game Jam. I have a general plot and challenge written out, it's just a matter of filling the rest in and making it interesting.
A definite difficult time right now. How is everyone doing during this pandemic? I already have seen furloughs and layoffs.
Hollow 1977 wrote on Archeia's profile.
Hope you and your family are doing well during this difficult time. :)
My elderly neighbor whom I've been buying groceries for just got carried out of his home on a stretcher by guys with hazmat suits. Considering I've been his only point of contact for the past month it's probably safe to say my boss was right to tell me to stay home once I developed a mild cough after all.
Damn. All these new features to the forums. Takes some getting used to.

Forum statistics

Threads
95,642
Messages
930,674
Members
125,963
Latest member
highchloride
Top