Jump to content
• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# First Time Isometric Tiling Engine Problem...

This topic is 5550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

I have a 22*22 "arena" with Civ II sytle control with the mouse. How can I *accurately* detect which tile has been clicked on? My solution is "somewhat jumbled" and is only 90% accurate. You could just ignore my code and point me to an article/website, any help will be gratefully recieved. Be nice, this is my first try! It does work. Cheers, Nop_90h Here is the delphi code: - ++++++++++++++++++++++++++ function TForm1.CalcYcoord(X,Y:Integer):Integer; var StartY:Integer; begin StartY := (DX.SurfaceHeight div 2); Result := StartY + (TileImages.Items.Items[0].Height*Y - TileImages.Items.Items[0].Height*X) div 2; end; function TForm1.CalcXcoord(X,Y:Integer):Integer; var StartX:Integer; begin StartX := 3 - TileImages.Items.Items[0].Width; Result := StartX + (TileImages.Items.Items[0].Width*X + TileImages.Items.Items[0].Width *Y) div 2; end; procedure TForm1.DXMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var XTile,YTile:Double; SuccessfulMove: Boolean; Temp: TCharacter; Str: String[32]; begin SuccessfulMove := False; YTile := (Y - (DX.SurfaceHeight div 2)- (TileImages.Items.Items[0].Height div 2)) / TileImages.Items.Items[0].Height; XTile := (X - (3-TileImages.Items.Items[0].Width)) / TileImages.Items.Items[0].Width; X := Trunc(XTile) - Trunc(YTile); Y := Trunc(XTile) + Trunc(YTile); If (Abs(YTile - Trunc(YTile)) < 0.70 ) AND (Abs(YTile - Trunc(YTile)) > 0.30 ) Then begin If (Abs(XTile - Trunc(XTile)) > 0.70 ) Then begin Temp.X := X; Temp.Y := Y; If YTile > 0 Then Temp.Y := Temp.Y + 1 else Temp.X := Temp.X + 1; SuccessfulMove := True; end else If (Abs(XTile - Trunc(XTile)) < 0.30 ) Then begin Temp.X := X; Temp.Y := Y; If YTile > 0 Then Temp.X := Temp.X - 1 else Temp.Y := Temp.Y - 1; SuccessfulMove := True; end; end else IF (Abs(XTile - Trunc(XTile)) < 0.70 ) AND (Abs(XTile - Trunc(XTile)) > 0.30 ) Then begin Temp.X := X; Temp.Y := Y; SuccessfulMove := True; end;

#### Share this post

##### Share on other sites
Advertisement
Try here. He (TANSTAAFL) even mentions that he got his method of tile selection from looking at how Civ II did it (don't that beat all).

[edited by - SysOp_1101 on August 5, 2003 11:39:14 PM]

#### Share this post

##### Share on other sites
Cheers for that, missed it :S. Funnily enough my current method (as far as I can see) pretty similar to that, except for step 3 which was a stroke of genius! Maybe I played on CivII too much when I was about 11 and something rubbed off? Such a *classic* game...

Cheers, Nop_90h

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5
• Advertisement

• 11
• 17
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632929
• Total Posts
3009278
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!