Skip to main content

News

Topic: Project ZeC (My Zelda-esque Clone) (Read 61582 times) previous topic - next topic

0 Members and 2 Guests are viewing this topic.
  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Project ZeC (My Zelda-esque Clone)
Reply #120
MapToScreenX/Y().  You can go in the reverse direction, too.

Edit: Sorry, I see you already knew about them...
  • Last Edit: September 10, 2017, 04:49:03 pm by Fat Cerberus
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: Project ZeC (My Zelda-esque Clone)
Reply #121
I know that in the screen cap I posted they are both using the playerX/Y values so MapToScreen is really doing no conversion at all which I would expect but shouldn't ScreenToMap be displaying a different value for the variables?
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Project ZeC (My Zelda-esque Clone)
Reply #122
By definition if MapToScreen(x,y) == (x,y) then the reverse is also true.

What exactly are you trying to do?
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: Project ZeC (My Zelda-esque Clone)
Reply #123
I'm trying to design a general purpose ladder function that allows the player to pass over the water tiles.

ideally:

Get player X/Y
convert to mapX/Y
add or subtract based on direction
SetTile to ladder
player crosses tile
tile changes back to water

Edit: I originally started doing it with zones but that quickly got very messy and buggy. Player crossed tile and it would change back too early and player obsructed. In some instances, Tile wouldn't change back at all.
  • Last Edit: September 10, 2017, 05:18:57 pm by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Project ZeC (My Zelda-esque Clone)
Reply #124
GetPlayerXY() is already in map coordinates, you don't need to convert.  UNLESS, you're trying to get the tile-based coordinates, in which case the conversion is simple:

Code: [Select]
tileX = Math.floor(playerX / tileWidth);
tileY = Math.floor(playerY / tileHeight);
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: Project ZeC (My Zelda-esque Clone)
Reply #125
I don't even have to use the ScreenTo or the MapTo after all. It never even occurred to me to do it that way.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: Project ZeC (My Zelda-esque Clone)
Reply #126
I don't even have to use the ScreenTo or the MapTo after all. It never even occurred to me to do it that way.
The conversion is only needed if you're going to have something drawn in a render script that moves based on the coordinates of things on the map.

If you're going to use a person/entity and put it on the map then there's no conversion required.

Re: Project ZeC (My Zelda-esque Clone)
Reply #127
hmm, I wonder if that's why one of the other functions I put on hold wasn't responding correctly. I'll have to go back to it and perhaps re-edit the code.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Project ZeC (My Zelda-esque Clone)
Reply #128
Just one of the screwed up ladder zones...
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Project ZeC (My Zelda-esque Clone)
Reply #129
In general, MapToScreen and its inverse correct for scrolling.  Your maps don't scroll because they're smaller than the screen, so the conversion functions do nothing.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: Project ZeC (My Zelda-esque Clone)
Reply #130
Well, these maps don't but I do have 2 maps that are larger than the screen. My "Hyrulian Outpost". It's an indoor map with a bunch of different rooms that all link to one another on the map. It is laid out, however, in a way that you can't see one room to the next even if the map scrolls some. The other map is outside of the Hyrulian Palace map. That's all one map and large compared to the rest of my other maps. It is the equivalent of a 3x3 section of Hyrule (768x528).
  • Last Edit: September 10, 2017, 06:00:59 pm by Miscreant
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Project ZeC (My Zelda-esque Clone)
Reply #131
Oh, make that 3 maps. The whirlpool is a different map that spans all of Hyrule that i use for panning across the land. That map is huge in comparison @ 4096x1232.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Project ZeC (My Zelda-esque Clone)
Reply #132
The ladder function is progressing. Right now, it is setting the tile back to a water tile too soon causing the player to become obstructed. I'm trying to set it so that does not occur but my math appears incorrect due to the fact that the py and pxy2 (temp var used for dbug) keep updating together.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

Re: Project ZeC (My Zelda-esque Clone)
Reply #133
Somehow, I've just broken all functionally of the ladder coding...
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: Project ZeC (My Zelda-esque Clone)
Reply #134
Yeowch! Hope you have an easy way to revert that.

I wonder if you could just check if the ladder is present, and if so, detect how many pixels away from it the player is. If it's > tileWidth pixels away from it in any direction, it could safely disappear.