Can you disable Real Values?

I'm trying to make a RPG with movement and such. However with how I have things setup and there being "Real" values its making a lot of things not working(alignments and checks every X pixels).

Ex. Right is Pressed, Char1 moves +size.width/or 32 pixels on the x axis, When Char1 self.position.x = old saved X position+32/or+self.width, change old X to new X, so player 2 knows where to go(unless this is bad practice).

However even if I was to place their starting positions even off by .5, how things are setup will stop working, so is there anyway to disable any/all forms of real values, if I'm working with a 32x32 grid, so things stop overshooting by .1/.3 etc and messing things up?

P.S All my current setup is in Integer, because I would like things to be solid numbers to follow the grid. And even when I do X+32 or Y+32 and have them displayed, it sometimes shows me real values? Which to me doesn't make sense since I'm keeping things with integer values and move to is always until completion before moving again.

Thanks.

Comments

  • SummationSummation Member, PRO Posts: 476

    @Impervion said:
    I'm trying to make a RPG with movement and such. However with how I have things setup and there being "Real" values its making a lot of things not working(alignments and checks every X pixels).

    Ex. Right is Pressed, Char1 moves +size.width/or 32 pixels on the x axis, When Char1 self.position.x = old saved X position+32/or+self.width, change old X to new X, so player 2 knows where to go(unless this is bad practice).

    However even if I was to place their starting positions even off by .5, how things are setup will stop working, so is there anyway to disable any/all forms of real values, if I'm working with a 32x32 grid, so things stop overshooting by .1/.3 etc and messing things up?

    P.S All my current setup is in Integer, because I would like things to be solid numbers to follow the grid. And even when I do X+32 or Y+32 and have them displayed, it sometimes shows me real values? Which to me doesn't make sense since I'm keeping things with integer values and move to is always until completion before moving again.

    Thanks.

    Are all your characters standing on a whole number to start?
    Also, how exactly are you moving them?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You can "snap to grid" by changing an actor's x position to round(self.Position.X)/32*32. Same for the y position.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ImpervionImpervion Member Posts: 49

    @Summarion I Have 4 Actors Up/Right/Down/Left, When pressed and when Direction = 0 change a game attribute called Direction to 1,2,3,4. In Char1 If Direction = 1,2,3 or 4, move Up/Right/Down/Left using Move To x+32,x-32,y+32,y-32. When Char1.self.x/y =+32/-32 depending on Direction, then set Direction to 0 and update Char1 X/Y for following actors.

    @tatiang I will try that(if I understand what you're saying).

  • ImpervionImpervion Member Posts: 49

    @tatiang is Round a function in GS? because I don't see it.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Yes, it is. The Mac version has Round() and RoundTo(). If the PC version doesn't have it, you can use Floor() or Ceil().

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ImpervionImpervion Member Posts: 49

    @tatiang There is no Round in PC, ill try the other 2 you mentioned.

  • SummationSummation Member, PRO Posts: 476

    @Impervion said:
    tatiang There is no Round in PC, ill try the other 2 you mentioned.

    The Pro version (I'm using 0.13.4) has both round and roundTo

  • ImpervionImpervion Member Posts: 49

    Hmm, I will invest more time into it tomorrow or the day after. Just messed around a bit with Ceil and Floor, but for some silly reason even tho I set Char1 on a integer and move Right/Up and stuff it sometimes gets unaligned and then Floor/Ceil depending on how it gets unaligned makes Char2 shift in either direction. But will mess around with it more. @tatiang For the Snap To Grid, how would that be put together, X/Y set to Char1 X/Y(changed via Ceil/Floor) and then Move To would just be 32, or would I also add Floor/Ceil here, so Move To floor(32)/ceil(32), on the X/Y as well?

    Thanks.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2015

    @Impervion said:
    Summarion I Have 4 Actors Up/Right/Down/Left, When pressed and when Direction = 0 change a game attribute called Direction to 1,2,3,4. In Char1 If Direction = 1,2,3 or 4, move Up/Right/Down/Left using Move To x+32,x-32,y+32,y-32. When Char1.self.x/y =+32/-32 depending on Direction, then set Direction to 0 and update Char1 X/Y for following actors.

    tatiang I will try that(if I understand what you're saying).

    That all sounds quite complicated, I'd just use:

    . . . . . . .

    When > is pressed change current.x to x+32
    Interpolate x to current.x

    When < is pressed change current.x to x-32
    Interpolate x to current.x

    When Λ is pressed change current.y to y+32
    Interpolate y to current.y

    When V is pressed change current.y to y-32
    Interpolate y to current.y

    . . . . . . .

  • ImpervionImpervion Member Posts: 49

    @Summation Hmm good to know, but I am currently using free version.

  • ImpervionImpervion Member Posts: 49

    @Socks Will try that, and see if I have better luck without things getting unaligned.

    Thanks all for the posts.

  • ImpervionImpervion Member Posts: 49
    edited May 2015

    @tatiang , @Socks , @Summation , This is what I have, or what I am trying to do, I still just cant get things to work properly, and must just be retarded :) . If you have the time to take a look, Thanks.
    https://drive.google.com/file/d/0B8Wg-SuZt4oGVk1UNmtnZG9wVWc/view?usp=sharing

  • ImpervionImpervion Member Posts: 49

    It seems like I can get one extra Char to follow, but not a third.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @tatiang For the Snap To Grid, how would that be put together, X/Y set to Char1 X/Y(changed via Ceil/Floor) and then Move To would just be 32, or would I also add Floor/Ceil here, so Move To floor(32)/ceil(32), on the X/Y as well?

    The idea is that you divide the actor's position (let's say x position for example) by the grid size (e.g. 32) and then round to a whole number and multiply by the grid size again.

    So imagine you have an actor at x=32. If you divide by 32, you get 1 and if you then multiply by 32, you get 32. The actor doesn't change position because it was already positioned at a multiple of 32. But in a different example, imagine you have an actor at x=45. If you divide by 32, you get 1.40625 and if you round that to 1 and multiply by 32, you get 32. So the actor "snaps" to the grid.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ImpervionImpervion Member Posts: 49

    @tatiang Did you manage to view my project(Was it terrible?)? I will test this tonight, your previously mentioned "Snap To Grid", since it was described better. Thanks.

  • ImpervionImpervion Member Posts: 49

    Also for the X/Y, Would I use Real or Integer?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I looked at the project but as my comments were focused on the "snap to grid" method, I didn't spend much time with it.

    Actor positions are real (self.Position.X is a real attribute) but you can use either. If you plan to always have your actors on a whole number (x=4 not x=4.155) then use an integer.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ImpervionImpervion Member Posts: 49

    Ok, thanks. Would the "Snap To" be instant and look weird? If I was to get it setup?

  • ImpervionImpervion Member Posts: 49

    Also after using even Integers since I want whole numbers, I notice when displaying the X/Y's, it randomly doesn't stay as a whole number. I'm only moving from a Integer to a Integer. Ex. 240/160 Start X/Y, Move Left 2-3 times, the numbers are right, then on 4th - even when all is saved/moved by Integers, it tosses out a real, like 112.00000354. I think this is why my project is running into issues, unless its also because I start @ 240 which isn't a multiple of 32. I will keep testing things and playing around with GS, thank you for your time, take care!

Sign In or Register to comment.