SpaceTraveller97

Villager
Member
Joined
Feb 5, 2021
Messages
21
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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.
 
Last edited:

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
Hello welcome!
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:

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.
 
Last edited:

SpaceTraveller97

Villager
Member
Joined
Feb 5, 2021
Messages
21
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
Hello welcome!
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:

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)
Adjust move route: Event jump (Variable 5 is screen X of the event)

But nothing happened
 
Last edited:

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3

SpaceTraveller97

Villager
Member
Joined
Feb 5, 2021
Messages
21
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
Try this:
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.
 
Last edited:

SpaceTraveller97

Villager
Member
Joined
Feb 5, 2021
Messages
21
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
Forget the part about dividing by 48, as I understand you didn't even try...

Try this:
Code:
◆Control Variables: #001 Player Screen X
◆Control Variables: #002 Player Screen Y
◆Control Variables: #003 Enemy Screen X

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.
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
◆Control Variables: #002 Player Screen Y
◆Control Variables: #003 Enemy X
◆Control Variables: #004 Enemy Y[/CODE]

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 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?
 
Last edited:

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
965
Reaction score
470
First Language
PT-BR
Primarily Uses
RM2k3
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:

  1. Did you understand the logic of dividing by 48?
  2. A question, why the projectile has to be by "Picture" and not a map event?
 
Last edited:

SpaceTraveller97

Villager
Member
Joined
Feb 5, 2021
Messages
21
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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:

  1. Did you understand the logic of dividing by 48?
  2. A question, why the projectile has to be by "Picture" and not a map event?
Thanks Dev, it worked! had days without enter here
 

Latest Threads

Latest Profile Posts


It's a Spanish devlog don't get scared!. (please)
Q:"Why don't you get a job?"
A: Posting statuses IS my job. It just so happens to not pay and happen periodically over the course of three months.
My new 49" monitor has been dispatched from the warehouse. Will it arrive tomorrow? The day after? I love that we can track packages now, even if it does only tell me when it's left that end and when it's arrived at the local centre. As long as it doesn't end up in Melbourne again, which has happened before ...
My friend's doing a surprise stream of my game Origin Hunt on Twitch here ! Feel free to stop by :yhappy:

Forum statistics

Threads
117,236
Messages
1,105,753
Members
153,396
Latest member
twofacegibby
Top