Floating Point Z-Index?

Started by Heretic86, June 04, 2012, 10:53:08 pm

Previous topic - Next topic

Heretic86

So im screwing around with Game_Character def screen_z(height=0) trying to figure out why changing Ints to Floats arent causing the adjusted numbers to work.  But need to ask someone with a bit more experience than I have as what I have to do for making Floats work.  IE, for the non super duper scripter crowd (myself usually included in that), Z-Index usually returns as a Whole Number.  Something like 29 or 341.  Decimals are Floats.  8.125, 34.7. 6.075.  Are the floats getting floored somewhere in other code that can be modified?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

The Z values are calculated in the underlying library, which unlike Ruby is a strongly typed language, meaning you can just change a value around from one type to another as you please. An integer is an integer, a float is a float, and a variable containing one will never be another. I am quite certain that a non-integer value is going to be coerced into an integer before being used by the engine.

Aside from that, it really doesn't make sense for a Z index to have to be a float. For all intended purposes, you have as many Z values to work with as you want. If you are forced to keep a viewport Z within a certain range (i.e. between 2 map layers), then just change the Z index of the sprites on that viewport.  The same can be said vice-versa.

To answer your question, no you can't modify the engine to use floats for Z indices by means of Ruby. They are complete different animals.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

A Z coordinate as float only makes sense in 3-dimensional space. In 2D or 2.5D the Z coordinate (also called Z-Index or Z-Order) should always be int. This makes things simpler, trust me.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Heretic86

Okay.  I believe you.  I was trying to come up with a creative way to adjust the z-indexes with more fine control and keep it in a ballpark range without clamping.  Was messing with larger party sizes and came across some bugs that were caused by those z-index adjustments.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)