• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

making a code according to the position of the player

V

Vinicius Alvarenga

Guest
I want that in a certain position of my player (I'm working with 3D), it changes the fog to another color, but i already tried place_meeting and it didn't work because when I started the game the fog was already changed.
Someone can help me?
I'm beginner
 
You don't need place_meeting for that, you could just check if the coordinates match your destination. Just make sure to check for a range instead of exact coordinates, otherwise the condition will never be met.
 

Lazzeking

Member
When my obj_player its in a specific point of the map (x, y) , i tried place_meeting with an invisible object
Or, if you want to make something happen when the player is in a certain spot, you could just check if the coordinates of the player are inside of that object's sprite (even if invisible) .
 
V

Vinicius Alvarenga

Guest
You don't need place_meeting for that, you could just check if the coordinates match your destination. Just make sure to check for a range instead of exact coordinates, otherwise the condition will never be met.
How i could check this?
 
V

Vinicius Alvarenga

Guest
How do i check the coordinates?
Just like:
if (obj_player is on (x_y)) {
d3d_set_fog(true, c_black, 16, 128);
}
 
C

CptChuckles

Guest
You need 4 variables to define a 2D-area:
  • The left edge of the region
  • The right edge of the region
  • The top edge of the region
  • The bottom edge of the region
Then you just use an if-statement using the comparative expressions available to you to ensure that the player's x coordinate is greater than the left edge and less than the right edge, and the player's y coordinate is greater than the top edge and less than the bottom edge.

The "if" statement
Expressions
 
Top