+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: X Y grid

  1. #1
    Lurker bubba is an unknown quantity at this point bubba's Avatar
    Join Date
    Jun 2009
    Posts
    52

    Default X Y grid

    Code:
     [21][22][23][24][25]    5
    
     [16][17][18][19][20]    4
    
     [11][12][13][14][15]    3
    
     [ 6][7 ][ 8][ 9][10]    2
    
     [1 ][2 ][3 ][4 ][5 ]    1
    X 1   2   3   4   5     Y
    
    Im trying to get a formula to get the X and Y values to equal the numbers inside the square. So I want X2 Y3 to give me 12 and ive tried a ton of things and cant get it to work. My cur one that fails alot is..
    Code:
    SP=(ValX)+(ValY*2)+(ValY*2) - (ValX-1)
    

  2. #2
    Wire Sofaking Solece has a little shameless behaviour in the past Solece's Avatar
    Join Date
    Jul 2008
    Location
    Pittsburgh, PA
    Posts
    660

    Default Re: X Y grid

    Use an table?
    Code:
    R["1,1",number]=22)
    R["2,1",number]=23)
    R["1,2",number]=16)
    
    etc...
    Quote Originally Posted by Ehmmett
    Ehmmett <3: Too much effort to play a game to fap.

  3. #3
    Lurker bubba is an unknown quantity at this point bubba's Avatar
    Join Date
    Jun 2009
    Posts
    52

    Default Re: X Y grid

    25 of those can be a pain you know :P I was gonna start with 25 entity markers but thought i should use all E2

  4. #4
    Wire Sofaking N00bDud3 has a spectacular aura about N00bDud3 has a spectacular aura about N00bDud3's Avatar
    Join Date
    Jul 2009
    Location
    Error: Unknown Location
    Posts
    970

    Default Re: X Y grid

    Just start with 1 at the top and go down, and then use Val = X+Y*Width


  5. #5
    Spucatum Tauri Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    4,702

    Default Re: X Y grid

    Val = X+Y*Width is wrong in his case.
    When you fill in his 2 & 3 you get:
    Val = 2 + 3 * 5 = 17

    He starts with 1 instead of 0, it should be:
    Val = X+(Y-1)*Width
    Val = 2 + (3-1) * 5 = 12
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

  6. #6
    Wirererer Riddler is on a distinguished road Riddler's Avatar
    Join Date
    Nov 2007
    Location
    /dev/null
    Posts
    203

    Default Re: X Y grid

    Bull is right, if you don't put in -1 you get X+Y*Width which when filled in for the first line you get 1+1*5 = 6 so you have 5 memory slots wasted. Arrays using this method still gives 2D and would also have less of a memory footprint than a table with a string index of "1,2"

  7. #7
    Wire Sofaking smellslike is on a distinguished road smellslike's Avatar
    Join Date
    May 2009
    Location
    in a lonley world
    Posts
    412

    Default Re: X Y grid

    Doesnt one of the RAMs act like a xy grid? i remember hearing that from somewhere, i never use them
    Working on military pack.
    Remember
    amateurs build the ark....
    Professionals build the titanic

  8. #8
    Wire Sofaking jacoby6000 will become famous soon enough jacoby6000's Avatar
    Join Date
    Feb 2008
    Location
    behind you when you aren't looking
    Posts
    638

    Default Re: X Y grid

    I hope this doesnt look like im just giving code out O_o
    Code:
    interval(500)
    while(Y<=Height &  ops()<4000)
    X++
    Index=toString(X)+","+toString(Y)
    R[Index,number]=X*Y
    if(X>Width){Y++ X=0}
    
    There's your basic formula, edit as needed
    Quote Originally Posted by Garrysmod View Post
    Warning: You're trying to render in the wrong place. This doesn't play nice with multi-core rendering, so we're not going to let you draw here.
    I'm not stupid!
    In [his] experience that was a sentence never to be uttered except to prove its own inaccuracy
    --Orson Scott Card

  9. #9
    Wirezard

    Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte is just really nice Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    3,151

    Default Re: X Y grid

    Quote Originally Posted by jacoby6000 View Post
    I hope this doesnt look like im just giving code out O_o
    Code:
    runOnTick(1)
    while(Y<=Height &  ops()<4000)
    {
        X++
        Index=toString(X)+","+toString(Y)
        R[Index,number]=X+(Y-1)*Width
        if(X>Width){Y++, X=0}
    } 
    There's your basic formula, edit as needed
    Fixed.
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr


    Wire FPGA

  10. #10
    Spucatum Tauri Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    4,702

    Default Re: X Y grid

    Using a lookup table for that is plain stupid.

    With that, he needs do every time:
    Index = R[ X:toString() + "," + Y:toString() , number ]
    Just to retrieve the index.

    Use:
    Index = X+(Y-1)*Width
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Grid
    By codemanj94 in forum Wiremod General Chat
    Replies: 3
    Last Post: 07-07-2009, 07:39 AM
  2. How (Grid)
    By Jarviar in forum Technical Support
    Replies: 4
    Last Post: 05-10-2008, 11:01 AM
  3. Grid on props?
    By Tegro in forum Wiremod General Chat
    Replies: 3
    Last Post: 07-05-2007, 12:35 AM
  4. That Grid thingy
    By kilroy in forum Off-Topic
    Replies: 1
    Last Post: 06-02-2007, 03:15 AM
  5. Holo Grid
    By poco642 in forum Technical Support
    Replies: 7
    Last Post: 05-10-2007, 07:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots