Results 1 to 19 of 19

Thread: Iso Engine Mouse Coordinates -[RESOLVED]-

  1. #1

    Thread Starter
    Addicted Member CodeRonin's Avatar
    Join Date
    Jul 2002
    Location
    Vienna, Austria
    Posts
    233

    Resolved Iso Engine Mouse Coordinates -[RESOLVED]-

    Hi there,
    by now, I've finished the graphical display of my Iso Engine.

    I'm saving the Tiles in a 2dimensional Matrix, so my GameField looks like this...

    GameTile GTMAP[10][10] =
    {
    1,1,1,4,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,
    1,1,2,3,4,1,1,1,1,1,
    1,1,1,2,3,1,1,1,1,1,
    1,1,2,1,6,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,
    }

    Where every number stands for a different type of terrain (not hardcoded, of course).

    Now, my question is: Given a paoint X(x/y) on the map (a mouse coordinate, to be precise), how can I check which tile I am in?

    Since it's not standard rectacular, a normal division by height and width won't work, so my attempt was to first do the normal division to know where about i am, seperate the most likely tile into four triangles, use the formula y=kx+d for linear functions and get the max for my y coordinate this way...

    Unfortunately, that's too slow...
    Any ideas on how to do it?
    Last edited by Electroman; Nov 14th, 2004 at 05:37 PM.
    Code Ronin

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    If you know the height and width of a tile wouldn't it be something like this??

    TileX = int(MousePosX/TileWidth)
    TileY = int(MousePosY/TileHeight)

    Or is that not quite what you want?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3
    noteme he sayd NOT a rectangular so that is wrong.. lemme find a tutorial for you.

  4. #4
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by nareth
    noteme he sayd NOT a rectangular so that is wrong.. lemme find a tutorial for you.
    That was not NoteMe.......SLH has hijacked my avatar..

  5. #5
    gr my matrix is overloaded. sorry

  6. #6
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by nareth
    noteme he sayd NOT a rectangular so that is wrong.. lemme find a tutorial for you.
    Well if it's not recrangular (implied by the array) then how are we to know what would be correct (considering that we don't know the actual shape)??
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  7. #7
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by NoteMe
    That was not NoteMe.......SLH has hijacked my avatar..
    Mwhahahaha!!
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  8. #8
    isometric he mentioned it in the title

  9. #9
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by nareth
    isometric he mentioned it in the title
    Ah.

    Surely he can just pretty much use the code he's already got to display the matrix on the screen, just 'reverse' the formula...
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  10. #10

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    To convert between rectangular and isometric coordinates you just need to do a matrix transformation, you multiply the coordinate with a matrix of which columns are the vectors of how many times each step on rectangular will translate to isometric
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    First Step: Find out what region of the map the mouse is in.

    RegionX=int(MouseX/MouseMapWidth)
    RegionY=int(MouseY/MouseMapHeight)*2 {The multiplying by two is very important}

    Second Step: Find out WHERE in the mousemap our mouse is, by finding MouseMapX and MouseMapY.

    MouseMapX=MouseX MOD MouseMapWidth
    MouseMapY=MouseY MOD MouseMapHeight


    Third Step: Determine the color in the MouseMap at (MouseMapX,MouseMapY).


    Fourth Step: Find RegionDX and RegionDY in the following table:

    Color RegionDX RegionDY
    RED -1 -1
    YELLOW 0 -1
    WHITE 0 0
    GREEN -1 1
    BLUE 0
    1



    Fifth Step: Use RegionX,RegionY, RegionDX, and RegionDY to find out TileX and TileY

    TileX=RegionX+RegionDX
    TileY=RegionY+RegionDY

  13. #13

    Thread Starter
    Addicted Member CodeRonin's Avatar
    Join Date
    Jul 2002
    Location
    Vienna, Austria
    Posts
    233

    Great

    That tutorial helped, thank you very much.
    I really appreciate it.
    Code Ronin

  14. #14
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    hahaha @SLH, nice puppet bashing

    here's the basic idea behind isometric projection, you multiply the vector from right with a transformation matrix with the rectangular coordinates to get the isometric coordinates.

    Attached Images Attached Images  
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  15. #15
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by kedaman
    hahaha @SLH, nice puppet bashing
    Credit where credit's due. It was Electroman that did the avatar.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  16. #16
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by SLH
    Credit where credit's due. It was Electroman that did the avatar.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  17. #17
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Nice one Electroman btw whats that av in yours suppose to be doing
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  18. #18

    Thread Starter
    Addicted Member CodeRonin's Avatar
    Join Date
    Jul 2002
    Location
    Vienna, Austria
    Posts
    233

    Nareth...

    What is the MouseMap?
    Code Ronin

  19. #19
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by kedaman
    Nice one Electroman btw whats that av in yours suppose to be doing
    Opps I missed the second half of your post some how......Its SLH's old avatar (the one with the smilie jumping out the toilet) but I turned it upside down and added water falling out the toilet .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width