I'm trying to make a kind of projectile engine, so i'm using images and moving them depending where the player is facing. Now what id need is check the position of the bullet image, so when it collides with some event the event will jump back. How could I do this? Id preffer to not use plugins I tried Galvs one and didnt work.
MV Check image position
Javascript/Plugin SupportBump
Hello welcome!
Could you show your event controlling images?
X Screen position:
Y Screen position:
As Pictures can be are with fractional numbers, it is necessary to round with this native Javascript command:
developer.mozilla.org
Would be like this:
I believe this will not work on maps larger than the screen unless the player is locked until the projectile collides or terminates the route.
Could you show your event controlling images?
X Screen position:
$gameScreen.picture(ID).x()Y Screen position:
$gameScreen.picture(ID).y()As Pictures can be are with fractional numbers, it is necessary to round with this native Javascript command:
parseInt() - JavaScript | MDN
The parseInt() function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).
Would be like this:
JavaScript:
parseInt($gameScreen.picture(1).x()/48)
I believe this will not work on maps larger than the screen unless the player is locked until the projectile collides or terminates the route.
I tried using that script call as conditional branch but nothing happens.
Was something like:
JavaScript:
if $gameScreen.picture(1).x() == $gameVariables.value(5)
But nothing happened
Please?
The image coordinates are by pixels and not by tiles, that's why I said that I should do the operation:
Good luck
JavaScript:
Control Variables: #001 Screen X of Player
Control Variables: #002 Screen Y of Player
Control Variables: #003 Screen X of Enemy
If: Input.isTriggered("#z")
$gameScreen.showPicture(1, "bullet", 1, $gameVariables.value(1)+40, $gameVariables.value(2) - 40, 100, 100, 255, 0);
$gameScreen.movePicture(1, 1, $gameVariables.value(1)+300, $gameVariables.value(2) - 40, 100, 100, 255, 0, 10);
Control Variables: #005 Picture Bullet X = $gameScreen.picture(1).x()
If: $gameVariables.value(5) >= $gameVariables.value(3) - 20 && $gameVariables.value(5) <= $gameVariables.value(3) + 20
Set movement Route: Enemy
Jump: +1, +0
Wait : 10 frames
Erase Picture: #1
Control Variables: #005 Picture Bullet X = 0
Try this:
Tip:
You can use copy text on event page to paste here or use PrintScreen key instead of rewriting the post, it will save you a lot of time.
Edited:
You will need to do the operation to ensure the collision:
It's no use saying this once, it has to be repeated times, because the image will move:
Do this check on the enemy event and not the common event.
Code:
◆Control Variables: #001 Player Screen X
◆Control Variables: #002 Player Screen Y
◆Control Variables: #003 Enemy X
◆Control Variables: #004 Enemy Y
Tip:
You can use copy text on event page to paste here or use PrintScreen key instead of rewriting the post, it will save you a lot of time.
Edited:
You will need to do the operation to ensure the collision:
JavaScript:
If: ($gameVariables.value(5)/48) >= $gameVariables.value(3) && ($gameVariables.value(6)/48) <= $gameVariables.value(4)
It's no use saying this once, it has to be repeated times, because the image will move:
Code:
◆Control Variables: #005 Picture Bullet X = $gameScreen.picture(1).x()
Do this check on the enemy event and not the common event.
I just tried but I don't think its a problem of diving, picture is working and both are screen coords, the problem is that the bullet doesnt colliding
i think it need to check repeated times the coords as you say, I tried putting
◆Control Variables: #005 Picture Bullet X = $gameScreen.picture(1).x()
in the enemy but still nothing happens, maybe using loops?
Tip, use this method:

The enemy has to be in a Parallel Process, review my post, I had already edited it.
Edited - The method is working:
There's just one problem, maps can't be bigger than the screen screen, being the default 816x624 pixels which equals 17x13 tiles:

The enemy has to be in a Parallel Process, review my post, I had already edited it.
Edited - The method is working:
There's just one problem, maps can't be bigger than the screen screen, being the default 816x624 pixels which equals 17x13 tiles:
- Did you understand the logic of dividing by 48?
- A question, why the projectile has to be by "Picture" and not a map event?
Thanks Dev, it worked! had days without enter here
Original thread: https://forums.rpgmakerweb.com/threads/check-image-position.140375/