Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: verion on December 23, 2015, 06:02:26 AM

Title: [help] how to determine if snap is horizontal or vertical?
Post by: verion on December 23, 2015, 06:02:26 AM
how to determine if snap (or any other art) for current game is horizontal or vertical?

I would like to position and scale snap in background differently for vertical and for horizontal snaps - totally different set of coordinates.

something like this

if
snap_width/snap_height < 1
then
set of coorfinates #1

if
snap_width/snap_height > 1
then
set of coorfinates #2
Title: Re: [help] how to determine if snap is horizontal or vertical?
Post by: liquid8d on December 23, 2015, 08:17:35 AM
if you just want to go by the actual object width height it's just:

local aspect = image.width / image.height.tofloat();
if ( aspect > 1.0 )
{
   //wide
} else
{
   //tall
}

but are you concerned about the TEXTURE width height (i.e using preserve art)? If so, it's more complicated, because you have to first make sure that the texture width/height is known in a transition, then check the texture aspect. This is why I made the preserve-art module (https://github.com/liquid8d/attract-extra/blob/master/modules/preserve-art.nut), and if you are using that you should be able to just go by the width/height of your object.
Title: Re: [help] how to determine if snap is horizontal or vertical?
Post by: verion on December 23, 2015, 08:56:00 AM
I have to do this on every transition (snap change) and for the [snap] - but maybe I'll just adapt your preserve art approach. This way I can focus more on how-to-use-it, not how-to-code-it.
Thanks.