Player and picture collision

Hyouryuu-Na

Sapphire Sodium
Veteran
Joined
Jun 15, 2017
Messages
960
Reaction score
2,245
First Language
Not English
Primarily Uses
RMMV
Not really a collision.... more like, a way to know that the player is touching a picture through a condition check. (I'm talking about pictures without taking transparent pixels in to account)
Unless I was dreaming, I could've sworn I saw a plugin like this somewhere. I regret not bookmarking the page because now I can't find it no matter what keywords I use to search TT
I'm not requesting a plugin since I can't guarantee I'll even use it and it'll be a waste of someone's time. I just want to test some things (It's okay if I can't. I'll figure some other way out) If anyone knows a way to do this or knows of an existing plugin that does this, please let me know.
 
Last edited:

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,685
First Language
English
Primarily Uses
RMMZ
This feature will require a plugin. So...

Moved to JS Plugin Requests.

 

tale

Volunteer
Veteran
Joined
Dec 16, 2016
Messages
724
Reaction score
1,223
First Language
English
Primarily Uses
N/A
Edit: found Picture Collision (prototype) plugin, if this could be edited to detect player collision and picture.

This plugin uses:
Switch function
Script call function
Code:
$gameSwitches.setValue(switchID,picCollision(Picture1,Picture2))
Download link: https://www.dropbox.com/s/l36dd36vr9vtq0z/Mano_Collsion.js?dl=1

Code:
 //=============================================================================
// Mano_picCollision.js
// ----------------------------------------------------------------------------
// Copyright (c) 2017-2017 Sigureya
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// [Twitter]: https://twitter.com/Sigureya/
// [github]:https://github.com/Sigureya/RPGmakerMV
//=============================================================================

/*:
* @author Sigureya
* @plugindesc Collision check for pictures
*
* @help
* Uses:
* Switch function
* Script call function
* $gameSwitches.setValue(switchID,picCollision(Picture1,Picture2))
* -
*/

(function(global){

const Sprite_Picture_loadBitmap =Sprite_Picture .prototype.loadBitmap;
Sprite_Picture .prototype.loadBitmap =function(){
    Sprite_Picture_loadBitmap.call(this);
    const picture = this.picture();
    picture._spriteMA =this;  
};
function hagaHanase(ax,aw,bx,bw){
    return ax <(bx +bw) &&bx <(ax+aw)  ;//&&bx <(ax+aw);
}


/**
* @param {Game_Picture} picture1
* @param {Game_Picture} picture2
*/
function pictureIntersect(picture1,picture2){  
        if(!picture1._spriteMA.renderable){
            return false;
        }
        if(!picture2._spriteMA.renderable){
            return false;
        }
        if(hagaHanase(picture1.x(),picture1._spriteMA.width,picture2.x(),picture2._spriteMA.width)
        &&hagaHanase(picture1.y(),picture1._spriteMA.height,picture2.y(),picture2._spriteMA.height)){
            return true;
        }
        return false;
    }
    global.pictureIntersect_MA = pictureIntersect;
})(this);




/**
*
* @param {number} a
* @param {number} b
*/
function picCollision(a,b){
    return pictureIntersect_MA(
        $gameScreen.picture(a),
        $gameScreen.picture(b)      
    );

}

_____________________________________

If someone knows how to edit this plugin for use of picture collision in eventing.
Pixel Perfect Collision

Direct link: https://raw.githubusercontent.com/holywyvern/mv-plugins/master/PixelPerfectCollition.js
Currently, it's made for sprite based collisions.

Screenshot preview of condition check for picture. (from vx ace, it can be done for MV) Plugin hasn't been made yet.



Script call if you want to test-
picture_collide_with_char?(1, 0)

Code:
Check collision between a picture and an character(event or player)
pic_id: ID of the picture
char_id: ID of the character
0 represent the player ID

picture_collide_with_char?(pic_id, char_id)

I'll leave collisionhelper script from vx ace in spoiler, in case plugin creator may want to look at existing features to burrow or adapt to request.

Code:
#
# Sprite_Picture
#  Reader to @picture added
#
class Sprite_Picture < Sprite
  attr_reader :picture
end

#
# Sprite_Spriteset_Map
#  Reader to @character_sprites and @picture_sprites added
#
class Spriteset_Map
  attr_reader :character_sprites
  attr_reader :picture_sprites
end

#
# Scene_Map
#   Extented with functions to get event/player and picture spriteset
#
class Scene_Map < Scene_Base
  #
  # Gets Event/Player Spriteset by ID
  # if called with ID 0, returns the player spriteset
  #
  def get_event_spriteset(evt_id)
    if evt_id == 0
      @spriteset.character_sprites.each do |cspr|
        return cspr if cspr.character == $game_player
      end
    else
      @spriteset.character_sprites.each do |cspr|
        return cspr if cspr.character.id == evt_id
      end
    end
    nil
  end
  #
  # Gets the picture sprite that correspond to pic_id
  #
  def get_picture_spriteset(pic_id)
    @spriteset.picture_sprites.each do |pspr|
      next unless pspr
      return pspr if pspr.picture.number == pic_id
    end
    nil
  end
end

#
# Game_Interpreter
#  Added helper functions to check characters and picture pixel collisions
#
class Game_Interpreter
  #
  # Check collion between active event and other event
  #  o_evt_id: ID of the other event, 0 represent the player ID
  #
  def collide_with?(o_evt_id)
    return false if o_evt_id < 0 or !SceneManager.scene.is_a?(Scene_Map)
    return false unless (o_evt_spr = SceneManager.scene.get_event_spriteset(o_evt_id))
    evt_spr = SceneManager.scene.get_event_spriteset(@event_id)
    evt_spr.pixel_collide?(o_evt_spr)
  end
  #
  # Check collion between two events
  #  evt_id1: ID of a event
  #  evt_id2: ID of other event
  #  0 represent the player ID
  #
  def collision_between?(evt_id1, evt_id2)
    return true if evt_id1 == evt_id2
    return false if evt_id1 < 0 or evt_id2 < 0 or !SceneManager.scene.is_a?(Scene_Map)
    evt_spr1 = SceneManager.scene.get_event_spriteset(evt_id1)
    evt_spr2 = SceneManager.scene.get_event_spriteset(evt_id2)
    return false unless evt_id1 and evt_id2
    evt_spr1.pixel_collide?(evt_spr2)
  end
  #
  # Check collion between two pictures
  #  pic1_id: ID of a picture
  #  pic2_id: ID of other picture
  #
  def picture_collision?(pic1_id, pic2_id)
    return true if pic1_id == pic2_id
    return false if pic1_id <= 0 or pic2_id <= 0 or !SceneManager.scene.is_a?(Scene_Map)
    pic1_spr = SceneManager.scene.get_picture_spriteset(pic1_id)
    pic2_spr = SceneManager.scene.get_picture_spriteset(pic2_id)
    return false unless pic1_spr and pic2_spr
    pic1_spr.pixel_collide?(pic2_spr)
  end
  #
  # Check collion between a picture and an character(event or player)
  #  pic_id: ID of the picture
  #  char_id: ID of the character
  #  0 represent the player ID
  #
  def picture_collide_with_char?(pic_id, char_id)
    return false if pic_id <= 0 or char_id < 0 or !SceneManager.scene.is_a?(Scene_Map)
    pic_spr  = SceneManager.scene.get_picture_spriteset(pic_id)
    char_spr = SceneManager.scene.get_event_spriteset(char_id)
    return false unless pic_spr and char_spr
    pic_spr.pixel_collide?(char_spr)
  end
end
Source- https://forums.rpgmakerweb.com/inde...rs-perfect-pixel-collision.34975/#post-345096
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,450
Members
137,820
Latest member
georg09byron
Top