MATH PROBLEM
Posts
Pages:
1
I have been trying to create a grid of my game world, but for some reason the math keeps changing in game. The values for variable 1 = 41 and variable 2 = 27. I should end up with grid x = 3 and grid y = 2, but they equal 1, 2 or 3 inside the game. Here is a pic of what I did.
http://rpgmaker.net/users/McBick/locker/Problem.png
http://rpgmaker.net/users/McBick/locker/Problem.png
if as you say variable 0001 = 41 and variable 0002 = 27 then you will indeed end up with grid x = 3 and grid y = 2, so the error is likely to lie elsewhere.
Care to explain more precisely what you're trying to do btw? Like where does the numbers 41 and 27 come from for example. And what's the point of the "Mod" variables?
Care to explain more precisely what you're trying to do btw? Like where does the numbers 41 and 27 come from for example. And what's the point of the "Mod" variables?
Variables 1 and 2 are hero x and hero y. The point of mod variables is to determine whether or not your on point 1 or 2. I don't know how else to explain it.
Edit: I am trying to create a grid of 20x15 tiles per point.
Edit: I am trying to create a grid of 20x15 tiles per point.
In that case it's not so weird that you find it hard to explain, because unless you somehow invent negative tile coordinates in the maker, the mod variable will always be 0 or higher.
I'm also still not sure what you're grid is like, maybe you could show pictures/drawings there as well?
I'm also still not sure what you're grid is like, maybe you could show pictures/drawings there as well?
When you transition from one point to another the screen shifts to that point. Basically each point is one screen of the world, similar to Zelda 2d games. Hope that makes sense.
then offsets should be sufficient.
When you're the top left point, you'd take the hero coordinates and subtract them with an "offset x" and an "offset y" which are both 0 at the top left point. when you move one "point" to the right, you update the "offset x" variable with +20, so that it now subtracts 20 from the hero x coordinate each time you're trying to get the coordinates.
When you're the top left point, you'd take the hero coordinates and subtract them with an "offset x" and an "offset y" which are both 0 at the top left point. when you move one "point" to the right, you update the "offset x" variable with +20, so that it now subtracts 20 from the hero x coordinate each time you're trying to get the coordinates.
Why don't you just track the X and Y coordinate of the hero, and then branch conditions every 20/15 units, and pan the screen accordingly?
I just read that and it is extremely impractical. But hey, it's a way.
I just read that and it is extremely impractical. But hey, it's a way.
I need to be able to pan the screen at the center of a point when ever I transition from a house to the overworld. I haven't figured a way to do that yet. I have done it in the past, but it was a long time ago and I forgot how I did it.
Actually, you can do that quite simply by using screen related coordinates instead of tile ones. When you take screen related x coordinate of the hero, and its less than 0, you're heading to the left, and if it's above 320 to the right. Then you just pan the screen and you keep using screen related coordinates
@Kazesui
Can you show me an example? I tried using screen related coridinates, but they're always the same when I exit a house to the overworld.
Can you show me an example? I tried using screen related coridinates, but they're always the same when I exit a house to the overworld.
Sorry for delay.
Guess I misunderstood you up there as well, and thought the house (i.e. the interior) was part of you map grid as well.
Anyway, as long as I'm still not misunderstanding you, I should have a working sample right now which you can look at.
Explained in short, you just get the tile coordinates, mod them with 20 and 15 to get their coordinates relative to the grid, then subtract them with 9 and 7 to see how far off from the center you are, and then pan the screen according to the offset you now have.
Important to note here is that you'll need to pad your map with 20x15 grid elements which you won't be able to access, otherwise you'll have to have map specific events to determine whether you're close to the edge of the map so that you can adjust accordingly in terms of panning the screen (more complicated).
Anyway, here's the sample project
The first common event is probably the one you're looking for
Guess I misunderstood you up there as well, and thought the house (i.e. the interior) was part of you map grid as well.
Anyway, as long as I'm still not misunderstanding you, I should have a working sample right now which you can look at.
Explained in short, you just get the tile coordinates, mod them with 20 and 15 to get their coordinates relative to the grid, then subtract them with 9 and 7 to see how far off from the center you are, and then pan the screen according to the offset you now have.
Important to note here is that you'll need to pad your map with 20x15 grid elements which you won't be able to access, otherwise you'll have to have map specific events to determine whether you're close to the edge of the map so that you can adjust accordingly in terms of panning the screen (more complicated).
Anyway, here's the sample project
The first common event is probably the one you're looking for
Pages:
1














