AxiosEngine-old 

AxiosEngine-old Commit Details


Date:2012-05-05 23:18:00 (12 years 7 months ago)
Author:Natalie Adams
Branch:default
Commit:2794825e9cdc
Parents: 7516219f30ab
Message:Removing uneeded Game Screen check

Adding SplitFlat that takes in offsets
Changes:
Maxios/Engine/Extensions/Texture2D.cs (1 diff)
Maxios/ScreenSystem/PhysicsGameScreen.cs (1 diff)

File differences

axios/Engine/Extensions/Texture2D.cs
180180
181181
182182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
183231
184232
185233
return r;
}
/// http://gamedev.stackexchange.com/questions/11584/xna-splitting-one-large-texture-into-an-array-of-smaller-textures
/// <summary>
/// Splits a texture into an array of smaller textures of the specified size.
/// </summary>
/// <param name="original">The texture to be split into smaller textures</param>
/// <param name="partWidth">The width of each of the smaller textures that will be contained in the returned array.</param>
/// <param name="partHeight">The height of each of the smaller textures that will be contained in the returned array.</param>
public static Texture2D[] SplitFlat(this Texture2D original, int partWidth, int partHeight, int offsetWidth, int offsetHeight, out int xCount, out int yCount)
{
yCount = original.Height / partHeight; //+ (partHeight % original.Height == 0 ? 0 : 1);//The number of textures in each horizontal row
xCount = original.Width / partWidth; //+(partWidth % original.Width == 0 ? 0 : 1);//The number of textures in each vertical column
Texture2D[] r = new Texture2D[xCount * yCount];//Number of parts = (area of original) / (area of each part).
int dataPerPart = partWidth * partHeight;//Number of pixels in each of the split parts
//Get the pixel data from the original texture:
Color[] originalData = new Color[original.Width * original.Height];
original.GetData<Color>(originalData);
int index = 0;
for (int y = 0; y < yCount * partHeight; y += (partHeight + offsetHeight))
for (int x = 0; x < xCount * partWidth; x += (partWidth + offsetWidth))
{
//The texture at coordinate {x, y} from the top-left of the original texture
Texture2D part = new Texture2D(original.GraphicsDevice, partWidth, partHeight);
//The data for part
Color[] partData = new Color[dataPerPart];
//Fill the part data with colors from the original texture
for (int py = 0; py < partHeight; py++)
for (int px = 0; px < partWidth; px++)
{
int partIndex = px + py * partWidth;
//If a part goes outside of the source texture, then fill the overlapping part with Color.Transparent
if (y + py >= original.Height || x + px >= original.Width)
partData[partIndex] = Color.Transparent;
else
partData[partIndex] = originalData[(x + px) + (y + py) * original.Width];
}
//Fill the part with the extracted data
part.SetData<Color>(partData);
//Stick the part in the return array:
r[index++] = part;
}
//Return the array of parts.
return r;
}
/// http://forums.create.msdn.com/forums/t/79258.aspx
/// <summary>
/// Combines one texture with another
axios/ScreenSystem/PhysicsGameScreen.cs
188188
189189
190190
191
192
193
191
192
194193
195194
196195
197
196
198197
199198
200199
PlayerIndex i;
if (input.IsNewButtonPress(Buttons.Back, PlayerIndex.One, out i) || input.IsNewKeyPress(Keys.Escape, PlayerIndex.One, out i))
{
if (this.ScreenState == GameStateManagement.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
{ //Give the screens a chance to transition
//if (this.ScreenState == GameStateManagement.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
//{ //Give the screens a chance to transition
CleanUp();
ExitScreen();
}
//}
}
base.HandleInput(gameTime, input);
}

Archive Download the corresponding diff file

Page rendered in 0.43124s using 14 queries.