Description:
Add ImageMap class I left out by mistake.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,69 | |||
|
1 | ||
|
2 | using System; | |
|
3 | ||
|
4 | using Num = System.Numerics; | |
|
5 | using Microsoft.Xna.Framework; | |
|
6 | using Microsoft.Xna.Framework.Graphics; | |
|
7 | ||
|
8 | namespace isometricparkfna | |
|
9 | { | |
|
10 | public class ImageMap | |
|
11 | { | |
|
12 | static public Texture2D ImageMapTexture; | |
|
13 | ||
|
14 | public int TileWidth; | |
|
15 | public int TileHeight; | |
|
16 | ||
|
17 | public ImageMap(int tileWidth, int tileHeight ) | |
|
18 | { | |
|
19 | this.TileHeight = tileHeight; | |
|
20 | this.TileWidth = tileWidth; | |
|
21 | } | |
|
22 | ||
|
23 | public Rectangle GetSourceRectangle(int tileIndex) | |
|
24 | { | |
|
25 | int tileY = tileIndex / (ImageMapTexture.Width / TileWidth); | |
|
26 | int tileX = tileIndex % (ImageMapTexture.Width / TileWidth); | |
|
27 | ||
|
28 | return new Rectangle(tileX * TileWidth, tileY * TileHeight, TileWidth, TileHeight); | |
|
29 | } | |
|
30 | public Num.Vector2 GetSourceUVStart(int tileIndex) | |
|
31 | { | |
|
32 | int tileX = tileIndex % (ImageMapTexture.Width / TileWidth); | |
|
33 | int tileY = tileIndex / (ImageMapTexture.Width / TileWidth); | |
|
34 | ||
|
35 | int imageMapX = (tileX) * TileWidth; | |
|
36 | int imageMapY = (tileY) * TileHeight; | |
|
37 | ||
|
38 | ||
|
39 | return new Num.Vector2( ((float)imageMapX)/ImageMapTexture.Width, | |
|
40 | ((float)imageMapY)/ImageMapTexture.Height); | |
|
41 | ||
|
42 | } | |
|
43 | public Num.Vector2 GetSourceUVEnd(int tileIndex) | |
|
44 | { | |
|
45 | int tileX = tileIndex % (ImageMapTexture.Width / TileWidth); | |
|
46 | int tileY = tileIndex / (ImageMapTexture.Width / TileWidth); | |
|
47 | ||
|
48 | int imageMapX = (tileX+1) * TileWidth; | |
|
49 | int imageMapY = (tileY+1) * TileHeight; | |
|
50 | ||
|
51 | ||
|
52 | return new Num.Vector2( ((float)imageMapX)/ImageMapTexture.Width, | |
|
53 | ((float)imageMapY)/ImageMapTexture.Height); | |
|
54 | ||
|
55 | } | |
|
56 | ||
|
57 | public Rectangle GetExtendedSourceRectangle(int tileIndex, int height) | |
|
58 | { | |
|
59 | int tileY = tileIndex / (ImageMapTexture.Width / TileWidth); | |
|
60 | int tileX = tileIndex % (ImageMapTexture.Width / TileWidth); | |
|
61 | ||
|
62 | return new Rectangle(tileX * TileWidth, tileY * TileHeight, TileWidth, TileHeight*height); | |
|
63 | } | |
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 | } | |
|
69 | } |
You need to be logged in to leave comments.
Login now