Standardized Representation RenderStates
I came across a great article by Shawn Hargreaves regarding using bit-fields to set RenderStates: Shawn Hargreaves Blog: Bitfield renderstates
After reading it, something peaked my interest: "This makes it impossible to come up with a single standardized
representation, so this bitfield technique is not suitable for
generalized engines or frameworks."
This is true, but I decided to attempt this. Whether I fail or not is besides the point, it's the knowledge that comes between extremes. The purpose of this class is to give a general technique across all frameworks.
Since there are more than 60 RenderStates, an integer, which represents 32 bits, isn't enough. So a long, 64 bits, would be more desirable. Obviously I could have used a BigInteger or equivalent type.
Bit-fields will be using bit-wise operations for checks and modifications, so we represent the RenderStates as a enumeration using the flag atrribute.
| [Flags] |
| public enum RSVar : ulong |
| { |
| AlphaBlendEnable = 1, |
| AlphaBlendOperation = AlphaBlendEnable << 1, |
| AlphaDestinationBlend = AlphaBlendOperation << 1, |
| … |
| } |
We'll need a previous state bit-field that will store changes made. When the user calls the Set functionality, changes will be checked and then we run through each bit position and determine which one has been activated:
| // See what states have changed. |
| ulong ulChanges = (ulong)_Variables ^ m_prevState; |
| … |
| // Run through and search which bit has been activated. |
| while ((ulChanges != 0) && nBitPos < (sizeof(ulong) * 8)) |
| { |
| // Determine if the bit is on. |
| ulong nShiftBitPos = (ulong)(1 << nBitPos); |
| if (IsBitOn((ulong)_Variables, nShiftBitPos)) |
| { |
| // TODO: Set RenderStates Here. |
| … |
| } |
| // Increment to the next bit position. |
| ++nBitPos; |
| // Clear this bit to shorten the loop. |
| ulChanges ^= (nShiftBitPos & (ulong)ulChanges); |
| } |
| // Store the previous state. |
| m_prevState = (ulong)_Variables; |
Once we find a bit that has been requested, we set the appropriate RenderStates, then increment to the next bit position. We toggle the bit from the bit-field to shorten the loop, otherwise we will always loop sizeof(ulong) * 8 bits = 64 times. Finally, we store the previous state for next time.
At first glance, this looks adequate but there are some problems.
1) We are hard-coding the RenderStates within the loop. We'll need to take in some parameters to make it more flexible.
Using a Variable Argument List or Variadic Function will give the flexibility but a minor problem. The function looks like this:
| public void Set(RenderState _RenderState, |
| RSVar _Variables, |
| params object[] _Values) |
| { |
| … |
| } |
The first parameter is the current RenderState that we will be setting. The second is the list of enumerations representing a bit-field. And third is the list of values to set. The problem is, since the list of enumerations is a bitfield, our functionality of checking each bit position from least to most significant needs to be respected. For example:
| RSHelper.Set(GraphicsDevice.RenderState, |
| RSHelper.RSVar.AlphaBlendEnable | |
| RSHelper.RSVar.CullMode | |
| RSHelper.RSVar.DestinationBlend, |
| new object[] { true, |
| CullMode.CullCounterClockwiseFace, |
| Blend.One, }); |
Is the correct way. AlphablendEnable will be set to true, CullMode will be set to CullMode.CullCounterClockwiseFace and DestinationBlend is set to Blend.One. If the third parameter were reversed or mixed, it would cause a crash.
Unfortunately there is no easy solution. So we just mention alphabetically for the second which will make it easier to create a sequence for the third parameter.
Other problems:
2) If the function is called again but different parameters are used.
3) If the function is called again but same parameters are used and modified.
We will need to add more to our current functionality to solve these:
| … |
| // Run through the list of renderstates to check if values have changed. |
| while (m_RSList.Count > 0 && UpdateList.Count < _Values.Length && NewList.Count < _Values.Length && |
| nBitPos < (sizeof(ulong) * 8)) |
| { |
| // Shift to the next bit position and check if the bit is on. |
| ulong nShiftBitPos = (ulong)((ulong)1 << nBitPos); |
| if (IsBitOn((ulong)_Variables, nShiftBitPos)) |
| { |
| // Run through the list of variables. |
| foreach (RSData data in m_RSList) |
| { |
| // Run through the list of values. |
| foreach (object value in _Values) |
| { |
| // Check if the render state has already been activated. |
| if (data.ShiftData == nShiftBitPos) |
| { |
| // Check the data type and value if they have changed. |
| if (data.ObjectType.GetType() == value.GetType() && |
| data.ObjectType.ToString() != value.ToString()) |
| UpdateList.Add(nShiftBitPos); |
| // Break out of the loop. |
| bBreak = true; |
| bNoChange = false; |
| break; |
| } |
| } |
| // Break out of the loop. |
| if (bBreak) |
| break; |
| } |
| // There is a new render state. |
| if (!bBreak) |
| NewList.Add(new RSData(nIndex, nShiftBitPos, _Values[nIndex])); |
| // Reset break flag and increment the next index. |
| bBreak = false; |
| ++nIndex; |
| } |
| // Increment to next bit position. |
| ++nBitPos; |
| } |
| // Determine if there are new renderstates. |
| if (NewList.Count > 0) |
| { |
| // TODO: Set RenderStates Here. |
| … |
| } |
| // |
| // Determine if there has been a change to an already activated renderstate. |
| else if (UpdateList.Count > 0) |
| { |
| // TODO: Set RenderStates Here. |
| … |
| } |
| // Check if there have been changes. |
| else if (bNoChange) |
| { |
| … |
| } |
We will need a list to store the current RenderStates being used and two temporary lists for Updated and New RenderStates that need to be modified and set.
The loop at the beginning will determine for us whether any RenderStates need to be updated or new ones need to be added. Then the if checks will set up those RenderStates respectively.
4) What if the user decides to reset all the RenderStates.
Since we have the list of current RenderStates, we just simply set back the ones being used:
| // Check if there were any changes. |
| if (m_RSList.Count > 0) |
| { |
| // Run through the list of changes. |
| foreach (RSData data in m_RSList) |
| { |
| // Determine the index reference. |
| switch ((RSVar)data.Index) |
| { |
| // TODO: Set RenderStates To Defaults. |
| … |
| default: |
| break; |
| } |
| } |
| // Clear the list and trim excess. |
| m_RSList.Clear(); |
| m_RSList.TrimExcess(); |
| m_prevState = 0; |
| } |
The RSData is a helper structure that contains information about the current RenderState such as the Index, ObjectType and ShiftBitData.
You will call this after you render the scene and want to reset things to default:
| RSHelper.Reset(GraphicsDevice.RenderState); |
Now we have a working class that sets/resets RenderStates easily for us. How is this more efficient then just setting them yourselves? Well lets say you have multiple classes, each setting a RenderState, as the number of classes grow, it will be hard to keep track of which ones are already activated and finally which ones need to be reset. With this implementation, it automatically figures these out.
Of course, this class is pointless for more specific game types or simple applications.
Hopefully this was helpful for some, it was definitely an exercise for the brain. There are room for optimizations and improvements, but it's a start.
Here is the link for the bit-field version: RSHelper
Here is the link for the non-bit-field version: RSHelper
Resources: Masks and flags using bit fields in .NET
Tearing when doing camera transformations
I'm not sure why this is happening.
Basically I render my tile map to the screen using a Spritebatch with a matrix transformation, and I get this weird tearing thing happening.
Tearing
Note that everything looks fine when I render using Matrix.Identity.
This is the code that I use to create the Matrix:
| #region Creating Transformation |
| private void CreateTransformation() |
| { |
| transformation = Matrix.Identity; |
| Vector3 screenCenter = new Vector3 |
| (graphics.Viewport.Width * 0.5f, graphics.Viewport.Height * 0.5f, 0f); |
| transformation *= Matrix.CreateTranslation(-screenCenter); |
| transformation *= Matrix.CreateScale(zoom); |
| transformation *= Matrix.CreateTranslation(screenCenter); |
| transformation *= Matrix.CreateTranslation |
| (position.X * zoom, position.Y * zoom, 0f); |
| mustUpdateTransformation = false; |
| } |
| #endregion |
And this is the code that I use to begin the SpriteBatch:
| ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, camera.Transformation); |
And here is the code used to render each tile:
| public void Draw(SpriteBatch batch) |
| { |
| foreach (var layer in MapLayers) |
| { |
| foreach (Tile T in layer) |
| { |
| batch.Draw(T.SpriteSheet.Texture, T.Position, T.SpriteSheet.SourceRectangle(T.TileIndex), Color.White); |
| } |
| } |
| } |
Does anyone know what is going on?
Standardized Representation RenderStates
I came across a great article by Shawn Hargreaves regarding using bit-fields to set RenderStates: Shawn Hargreaves Blog: Bitfield renderstates
After reading it, something peaked my interest: "This makes it impossible to come up with a single standardized
representation, so this bitfield technique is not suitable for
generalized engines or frameworks."
This is true, but I decided to attempt this. Whether I fail or not is besides the point, it's the knowledge that comes between extremes. The purpose of this class is to give a general technique across all frameworks.
Since there are more than 60 RenderStates, an integer, which represents 32 bits, isn't enough. So a long, 64 bits, would be more desirable. Obviously I could have used a BigInteger or equivalent type.
Bit-fields will be using bit-wise operations for checks and modifications, so we represent the RenderStates as a enumeration using the flag atrribute.
| [Flags] |
| public enum RSVar : ulong |
| { |
| AlphaBlendEnable = 1, |
| AlphaBlendOperation = AlphaBlendEnable << 1, |
| AlphaDestinationBlend = AlphaBlendOperation << 1, |
| … |
| } |
We'll need a previous state bit-field that will store changes made. When the user calls the Set functionality, changes will be checked and then we run through each bit position and determine which one has been activated:
| // See what states have changed. |
| ulong ulChanges = (ulong)_Variables ^ m_prevState; |
| … |
| // Run through and search which bit has been activated. |
| while ((ulChanges != 0) && nBitPos < (sizeof(ulong) * 8)) |
| { |
| // Determine if the bit is on. |
| ulong nShiftBitPos = (ulong)(1 << nBitPos); |
| if (IsBitOn((ulong)_Variables, nShiftBitPos)) |
| { |
| // TODO: Set RenderStates Here. |
| … |
| } |
| // Increment to the next bit position. |
| ++nBitPos; |
| // Clear this bit to shorten the loop. |
| ulChanges ^= (nShiftBitPos & (ulong)ulChanges); |
| } |
| // Store the previous state. |
| m_prevState = (ulong)_Variables; |
Once we find a bit that has been requested, we set the appropriate RenderStates, then increment to the next bit position. We toggle the bit from the bit-field to shorten the loop, otherwise we will always loop sizeof(ulong) * 8 bits = 64 times. Finally, we store the previous state for next time.
At first glance, this looks adequate but there are some problems.
1) We are hard-coding the RenderStates within the loop. We'll need to take in some parameters to make it more flexible.
Using a Variable Argument List or Variadic Function will give the flexibility but a minor problem. The function looks like this:
| public void Set(RenderState _RenderState, |
| RSVar _Variables, |
| params object[] _Values) |
| { |
| … |
| } |
The first parameter is the current RenderState that we will be setting. The second is the list of enumerations representing a bit-field. And third is the list of values to set. The problem is, since the list of enumerations is a bitfield, our functionality of checking each bit position from least to most significant needs to be respected. For example:
| RSHelper.Set(GraphicsDevice.RenderState, |
| RSHelper.RSVar.AlphaBlendEnable | |
| RSHelper.RSVar.CullMode | |
| RSHelper.RSVar.DestinationBlend, |
| new object[] { true, |
| CullMode.CullCounterClockwiseFace, |
| Blend.One, }); |
Is the correct way. AlphablendEnable will be set to true, CullMode will be set to CullMode.CullCounterClockwiseFace and DestinationBlend is set to Blend.One. If the third parameter were reversed or mixed, it would cause a crash.
Unfortunately there is no easy solution. So we just mention alphabetically for the second which will make it easier to create a sequence for the third parameter.
Other problems:
2) If the function is called again but different parameters are used.
3) If the function is called again but same parameters are used and modified.
We will need to add more to our current functionality to solve these:
| … |
| // Run through the list of renderstates to check if values have changed. |
| while (m_RSList.Count > 0 && UpdateList.Count < _Values.Length && NewList.Count < _Values.Length && |
| nBitPos < (sizeof(ulong) * 8)) |
| { |
| // Shift to the next bit position and check if the bit is on. |
| ulong nShiftBitPos = (ulong)((ulong)1 << nBitPos); |
| if (IsBitOn((ulong)_Variables, nShiftBitPos)) |
| { |
| // Run through the list of variables. |
| foreach (RSData data in m_RSList) |
| { |
| // Run through the list of values. |
| foreach (object value in _Values) |
| { |
| // Check if the render state has already been activated. |
| if (data.ShiftData == nShiftBitPos) |
| { |
| // Check the data type and value if they have changed. |
| if (data.ObjectType.GetType() == value.GetType() && |
| data.ObjectType.ToString() != value.ToString()) |
| UpdateList.Add(nShiftBitPos); |
| // Break out of the loop. |
| bBreak = true; |
| bNoChange = false; |
| break; |
| } |
| } |
| // Break out of the loop. |
| if (bBreak) |
| break; |
| } |
| // There is a new render state. |
| if (!bBreak) |
| NewList.Add(new RSData(nIndex, nShiftBitPos, _Values[nIndex])); |
| // Reset break flag and increment the next index. |
| bBreak = false; |
| ++nIndex; |
| } |
| // Increment to next bit position. |
| ++nBitPos; |
| } |
| // Determine if there are new renderstates. |
| if (NewList.Count > 0) |
| { |
| // TODO: Set RenderStates Here. |
| … |
| } |
| // |
| // Determine if there has been a change to an already activated renderstate. |
| else if (UpdateList.Count > 0) |
| { |
| // TODO: Set RenderStates Here. |
| … |
| } |
| // Check if there have been changes. |
| else if (bNoChange) |
| { |
| … |
| } |
We will need a list to store the current RenderStates being used and two temporary lists for Updated and New RenderStates that need to be modified and set.
The loop at the beginning will determine for us whether any RenderStates need to be updated or new ones need to be added. Then the if checks will set up those RenderStates respectively.
4) What if the user decides to reset all the RenderStates.
Since we have the list of current RenderStates, we just simply set back the ones being used:
| // Check if there were any changes. |
| if (m_RSList.Count > 0) |
| { |
| // Run through the list of changes. |
| foreach (RSData data in m_RSList) |
| { |
| // Determine the index reference. |
| switch ((RSVar)data.Index) |
| { |
| // TODO: Set RenderStates To Defaults. |
| … |
| default: |
| break; |
| } |
| } |
| // Clear the list and trim excess. |
| m_RSList.Clear(); |
| m_RSList.TrimExcess(); |
| m_prevState = 0; |
| } |
The RSData is a helper structure that contains information about the current RenderState such as the Index, ObjectType and ShiftBitData.
You will call this after you render the scene and want to reset things to default:
| RSHelper.Reset(GraphicsDevice.RenderState); |
Now we have a working class that sets/resets RenderStates easily for us. How is this more efficient then just setting them yourselves? Well lets say you have multiple classes, each setting a RenderState, as the number of classes grow, it will be hard to keep track of which ones are already activated and finally which ones need to be reset. With this implementation, it automatically figures these out.
Of course, this class is pointless for more specific game types or simple applications.
Hopefully this was helpful for some, it was definitely an exercise for the brain. There are room for optimizations and improvements, but it's a start.
Here is the link for the bit-field version: RSHelper
Here is the link for the non-bit-field version: RSHelper
Resources: Masks and flags using bit fields in .NET
Tearing when doing camera transformations
I'm not sure why this is happening.
Basically I render my tile map to the screen using a Spritebatch with a matrix transformation, and I get this weird tearing thing happening.
Tearing
Note that everything looks fine when I render using Matrix.Identity.
This is the code that I use to create the Matrix:
| #region Creating Transformation |
| private void CreateTransformation() |
| { |
| transformation = Matrix.Identity; |
| Vector3 screenCenter = new Vector3 |
| (graphics.Viewport.Width * 0.5f, graphics.Viewport.Height * 0.5f, 0f); |
| transformation *= Matrix.CreateTranslation(-screenCenter); |
| transformation *= Matrix.CreateScale(zoom); |
| transformation *= Matrix.CreateTranslation(screenCenter); |
| transformation *= Matrix.CreateTranslation |
| (position.X * zoom, position.Y * zoom, 0f); |
| mustUpdateTransformation = false; |
| } |
| #endregion |
And this is the code that I use to begin the SpriteBatch:
| ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, camera.Transformation); |
And here is the code used to render each tile:
| public void Draw(SpriteBatch batch) |
| { |
| foreach (var layer in MapLayers) |
| { |
| foreach (Tile T in layer) |
| { |
| batch.Draw(T.SpriteSheet.Texture, T.Position, T.SpriteSheet.SourceRectangle(T.TileIndex), Color.White); |
| } |
| } |
| } |
Does anyone know what is going on?
Avatar postioning with World Matrix issues
Hey XNA Community,
I am not very good at this and have never really posted a question like
this on a forum so if I am a little wordy I am just trying to make sure I
get everything out.
I have written an Avatar wrapper for a
project I am working on. It is based both the Custom and Blended
Animation examples from this site. The Player Object that holds onto
the Avatar has its own World Matrix that it uses for both the Avatar and
the spaceship that represents the player in-game.
In the Draw I pass in the View and the Projection Matrices (I know now
that I do not need to send the Projection every time and will fix
that) and set the AvatarRenderer's View and Proj to them.
In the Player Update I pass in the corrected world Matrix to the Avatar
and set the AvatarRenderer's World with it. I also *= the ROOT transform
of the bones with the World, which orientates it correctly.
When World is set it is a property which sets my field AND the AvatarRenderer.World.
| 1 | public void CAvatar.Update(GameTime _GameTime, Matrix _World) |
| 2 | { |
| 3 | World = _World; |
| 5 | UpdateTransforms(currtTopAnim.BoneTransforms, currBottomAnim.BoneTransforms); |
| 6 | } |
| 1 | private void UpdateTransforms(ReadOnlyCollection<Matrix> _TopAnim, ReadOnlyCollection<Matrix> _BottomAnim) |
| 2 | { |
| 3 | // Copy the bottom transforms to the final list of transforms |
| 4 | for (int i = 0; i < finalBoneTransforms.Count; i++) |
| 5 | { |
| 6 | finalBoneTransforms[i] = _BottomAnim[i]; |
| 7 | } |
| 9 | // Overwrite the transforms for the bones that are part of the top transform . |
| 10 | if (currentBottomType != currentTopType) |
| 11 | { |
| 12 | for (int i = 0; i < bottomBones.Count; i++) |
| 13 | { |
| 14 | finalBoneTransforms[bottomBones[i]] = _TopAnim[bottomBones[i]]; |
| 15 | } |
| 16 | } |
| 18 | finalBoneTransforms[(int)AvatarBone.Root] *= World; |
| 19 | } |
The Problem is the Avatar moves faster than the ship IDK why because it
just uses the same World as the ship.
I believe that is all that really effects the position of the Avatar but I am still doing something wrong. I don't believe it is the World itself due to the ship being rendered correctly. I must be missing something to do with the Avatar and its world but I don't have a lot of experience with XNA Avatar Code beyond the examples and working on this wrapper to combine both blended and custom animations.
Thanks for any help you can give me…
Avatar postioning with World Matrix issues
Hey XNA Community,
I am not very good at this and have never really posted a question like
this on a forum so if I am a little wordy I am just trying to make sure I
get everything out.
I have written an Avatar wrapper for a
project I am working on. It is based both the Custom and Blended
Animation examples from this site. The Player Object that holds onto
the Avatar has its own World Matrix that it uses for both the Avatar and
the spaceship that represents the player in-game.
In the Draw I pass in the View and the Projection Matrices (I know now
that I do not need to send the Projection every time and will fix
that) and set the AvatarRenderer's View and Proj to them.
In the Player Update I pass in the corrected world Matrix to the Avatar
and set the AvatarRenderer's World with it. I also *= the ROOT transform
of the bones with the World, which orientates it correctly.
When World is set it is a property which sets my field AND the AvatarRenderer.World.
| 1 | public void CAvatar.Update(GameTime _GameTime, Matrix _World) |
| 2 | { |
| 3 | World = _World; |
| 5 | UpdateTransforms(currtTopAnim.BoneTransforms, currBottomAnim.BoneTransforms); |
| 6 | } |
| 1 | private void UpdateTransforms(ReadOnlyCollection<Matrix> _TopAnim, ReadOnlyCollection<Matrix> _BottomAnim) |
| 2 | { |
| 3 | // Copy the bottom transforms to the final list of transforms |
| 4 | for (int i = 0; i < finalBoneTransforms.Count; i++) |
| 5 | { |
| 6 | finalBoneTransforms[i] = _BottomAnim[i]; |
| 7 | } |
| 9 | // Overwrite the transforms for the bones that are part of the top transform . |
| 10 | if (currentBottomType != currentTopType) |
| 11 | { |
| 12 | for (int i = 0; i < bottomBones.Count; i++) |
| 13 | { |
| 14 | finalBoneTransforms[bottomBones[i]] = _TopAnim[bottomBones[i]]; |
| 15 | } |
| 16 | } |
| 18 | finalBoneTransforms[(int)AvatarBone.Root] *= World; |
| 19 | } |
The Problem is the Avatar moves faster than the ship IDK why because it
just uses the same World as the ship.
I believe that is all that really effects the position of the Avatar but I am still doing something wrong. I don't believe it is the World itself due to the ship being rendered correctly. I must be missing something to do with the Avatar and its world but I don't have a lot of experience with XNA Avatar Code beyond the examples and working on this wrapper to combine both blended and custom animations.
Thanks for any help you can give me…
Almost There
Hey Guys,
I have almost have a basic prototype of the gameplay I want for this game. However, I have ran into some problems. I have got the blocks to fall from the screen and stop at the bottom of the playing field. However, the color of the blocks should appear of different colors randomly, all the blocks are yellow. Also, How can I get the blocks to stay inside of the selector? And one last step, How would I do it, so that when the user presses a key, the blocks switch sides? I know how to program input from a controller, I just need the code or an example of how I would switch the two block positions. Here is the code. Thanks for any help.
| 1 | using System; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Linq; |
| 4 | using Microsoft.Xna.Framework; |
| 5 | using Microsoft.Xna.Framework.Audio; |
| 6 | using Microsoft.Xna.Framework.Content; |
| 7 | using Microsoft.Xna.Framework.GamerServices; |
| 8 | using Microsoft.Xna.Framework.Graphics; |
| 9 | using Microsoft.Xna.Framework.Input; |
| 10 | using Microsoft.Xna.Framework.Media; |
| 11 | using Microsoft.Xna.Framework.Net; |
| 12 | using Microsoft.Xna.Framework.Storage; |
| 13 | |
| 14 | namespace Puzzle_Battles |
| 15 | { |
| 16 | /// <summary> |
| 17 | /// This is the main type for your game |
| 18 | /// </summary> |
| 19 | public class Game1 : Microsoft.Xna.Framework.Game |
| 20 | { |
| 21 | GraphicsDeviceManager graphics; |
| 22 | SpriteBatch spriteBatch; |
| 23 | SpriteFont gameFont; |
| 24 | |
| 25 | Texture2D LogoGfx; |
| 26 | Rectangle LogoRect; |
| 27 | |
| 28 | Texture2D[] BlockGfx; |
| 29 | Rectangle[] BlockRect; |
| 30 | |
| 31 | Texture2D TitleGfx; |
| 32 | Rectangle TitleRect; |
| 33 | |
| 34 | |
| 35 | Texture2D[] PlayFieldGfx; |
| 36 | Rectangle[] PlayFieldRect; |
| 37 | |
| 38 | Texture2D[] CharGfx; |
| 39 | Rectangle[] CharRect; |
| 40 | |
| 41 | Texture2D[] SelectorGfx; |
| 42 | Rectangle[] SelectorRect; |
| 43 | |
| 44 | private KeyboardState lastKey = Keyboard.GetState(); |
| 45 | private GamePadState lastButton = GamePad.GetState(PlayerIndex.One); |
| 46 | private GamePadState lastButton2 = GamePad.GetState(PlayerIndex.Two); |
| 47 | |
| 48 | long lastTick = 0; |
| 49 | float FramesPerSec = 0.0f; |
| 50 | float deltaTime = 0.0f; |
| 51 | int lastFrame = 0; |
| 52 | int currentFrame = 0; |
| 53 | int frameCounter = 0; |
| 54 | string FPS = ""; |
| 55 | |
| 56 | string[] GameSelection = new string[] { |
| 57 | "Adventure Mode", //0 |
| 58 | "Gaunlet Mode", //1 |
| 59 | "Tournament Mode", //2 |
| 60 | "Tutorial Mode", //3 |
| 61 | "Local Match", //4 |
| 62 | "Online Match", //5 |
| 63 | "Game Options", //6 |
| 64 | "Exit Game", //7 |
| 65 | }; |
| 66 | |
| 67 | int Selected = 0; |
| 68 | |
| 69 | enum ScreenState |
| 70 | { |
| 71 | LogoScreen, |
| 72 | TitleScreen, |
| 73 | CharacterSelectScreen, |
| 74 | AdventureScreen, |
| 75 | TournamentScreen, |
| 76 | LocalMatchScreen, |
| 77 | TutorialScreen, |
| 78 | GaunletScreen, |
| 79 | OnlineMatchScreen, |
| 80 | OptionScreen |
| 81 | } |
| 82 | |
| 83 | enum GameState |
| 84 | { |
| 85 | Running, |
| 86 | Paused |
| 87 | } |
| 88 | |
| 89 | Color gamePausedColor = Color.TransparentWhite; |
| 90 | bool gamePaused = false; |
| 91 | |
| 92 | ScreenState gScreen = new ScreenState(); |
| 93 | GameState gGameState = new GameState(); |
| 94 | |
| 95 | public const int Field_Width = 334; |
| 96 | public const int Field_Height = 697; |
| 97 | |
| 98 | public const int Block_Width = 32; |
| 99 | public const int Block_Height = 32; |
| 100 | |
| 101 | public const int Selector_Width = 128; |
| 102 | public const int Selector_Height = 128; |
| 103 | |
| 104 | public const float BlockFallSpeed = 0.05f; |
| 105 | public const float BlockAppearRate = 0.10f; |
| 106 | |
| 107 | enum BlockType |
| 108 | { |
| 109 | BlackBlock, |
| 110 | FireBlock, |
| 111 | EarthBlock, |
| 112 | WaterBlock, |
| 113 | WhiteBlock, |
| 114 | WindBlock |
| 115 | } |
| 116 | |
| 117 | Color BlackBlockColor; |
| 118 | Color FireBlockColor; |
| 119 | Color EarthBlockColor; |
| 120 | Color WaterBlockColor; |
| 121 | Color WhiteBlockColor; |
| 122 | Color WindBlockColor; |
| 123 | |
| 124 | BlockType gBlockType = new BlockType(); |
| 125 | |
| 126 | List<Vector2> BlockPos = new List<Vector2>(); |
| 127 | |
| 128 | Random gNxtBlock = new Random(); |
| 129 | Random gNxtFallBlock = new Random(); |
| 130 | |
| 131 | public const int MAX_ROWS = 60; |
| 132 | public const int MAX_COLMNS = 30; |
| 133 | |
| 134 | public int Selector_X = 20; |
| 135 | public int Selector_Y = 50; |
| 136 | public int Selector_X2 = 690; |
| 137 | public int Selector_Y2 = 50; |
| 138 | |
| 139 | public Game1() |
| 140 | { |
| 141 | graphics = new GraphicsDeviceManager(this); |
| 142 | Content.RootDirectory = "Content"; |
| 143 | |
| 144 | this.graphics.PreferredBackBufferWidth = 1024; |
| 145 | this.graphics.PreferredBackBufferHeight = 768; |
| 146 | |
| 147 | this.IsMouseVisible = true; |
| 148 | this.IsFixedTimeStep = false; |
| 149 | |
| 150 | gScreen = ScreenState.LogoScreen; |
| 151 | gGameState = GameState.Running; |
| 152 | } |
| 153 | |
| 154 | /// <summary> |
| 155 | /// Allows the game to perform any initialization it needs to before starting to run. |
| 156 | /// This is where it can query for any required services and load any non-graphic |
| 157 | /// related content. Calling base.Initialize will enumerate through any components |
| 158 | /// and initialize them as well. |
| 159 | /// </summary> |
| 160 | protected override void Initialize() |
| 161 | { |
| 162 | // TODO: Add your initialization logic here |
| 163 | |
| 164 | base.Initialize(); |
| 165 | } |
| 166 | |
| 167 | /// <summary> |
| 168 | /// LoadContent will be called once per game and is the place to load |
| 169 | /// all of your content. |
| 170 | /// </summary> |
| 171 | protected override void LoadContent() |
| 172 | { |
| 173 | // Create a new SpriteBatch, which can be used to draw textures. |
| 174 | spriteBatch = new SpriteBatch(GraphicsDevice); |
| 175 | |
| 176 | // TODO: use this.Content to load your game content here |
| 177 | gameFont = Content.Load<SpriteFont>("mainFont"); |
| 178 | |
| 179 | PlayFieldGfx = new Texture2D[2]; |
| 180 | PlayFieldGfx[0] = Content.Load<Texture2D>("play_field"); |
| 181 | PlayFieldGfx[1] = Content.Load<Texture2D>("play_field"); |
| 182 | |
| 183 | int BlockW = PlayFieldGfx[0].Width / Field_Width; |
| 184 | int BlockH = PlayFieldGfx[0].Height / Field_Height; |
| 185 | int BlockW2 = PlayFieldGfx[1].Width / Field_Width; |
| 186 | int BlockH2 = PlayFieldGfx[1].Height / Field_Height; |
| 187 | |
| 188 | |
| 189 | SelectorGfx = new Texture2D[2]; |
| 190 | SelectorGfx[0] = Content.Load<Texture2D>("selector"); |
| 191 | SelectorGfx[1] = Content.Load<Texture2D>("selector"); |
| 192 | |
| 193 | CharGfx = new Texture2D[9]; |
| 194 | CharGfx[0] = Content.Load<Texture2D>("Cynthia puzzle 2"); |
| 195 | CharGfx[1] = Content.Load<Texture2D>("Cynthia puzzle"); |
| 196 | CharGfx[2] = Content.Load<Texture2D>("Cynthia thumb"); |
| 197 | CharGfx[3] = Content.Load<Texture2D>("Cynthia thumb2"); |
| 198 | CharGfx[4] = Content.Load<Texture2D>("Epic Puzzle"); |
| 199 | CharGfx[5] = Content.Load<Texture2D>("Epic Puzzle2"); |
| 200 | CharGfx[6] = Content.Load<Texture2D>("Epic thumb 2"); |
| 201 | CharGfx[7] = Content.Load<Texture2D>("Epic thumb"); |
| 202 | CharGfx[8] = Content.Load<Texture2D>("trufa heart"); |
| 203 | |
| 204 | LogoGfx = Content.Load<Texture2D>("Logo"); |
| 205 | |
| 206 | CharRect = new Rectangle[3]; |
| 207 | CharRect[0] = new Rectangle(250, 200, 128, 128); |
| 208 | CharRect[1] = new Rectangle(380, 200, 128, 128); |
| 209 | CharRect[2] = new Rectangle(500, 200, 128, 128); |
| 210 | |
| 211 | BlockGfx = new Texture2D[6]; |
| 212 | BlockGfx[0] = Content.Load<Texture2D>("black_block"); |
| 213 | BlockGfx[1] = Content.Load<Texture2D>("earth_block"); |
| 214 | BlockGfx[2] = Content.Load<Texture2D>("fire_block"); |
| 215 | BlockGfx[3] = Content.Load<Texture2D>("water_block"); |
| 216 | BlockGfx[4] = Content.Load<Texture2D>("white_block"); |
| 217 | BlockGfx[5] = Content.Load<Texture2D>("wind_block"); |
| 218 | |
| 219 | BlockRect = new Rectangle[6]; |
| 220 | BlockRect[0] = new Rectangle(15, 32, 32, 32); |
| 221 | BlockRect[1] = new Rectangle(45, 32, 32, 32); |
| 222 | BlockRect[2] = new Rectangle(15, 32, 32, 32); |
| 223 | BlockRect[3] = new Rectangle(15, 32, 32, 32); |
| 224 | BlockRect[4] = new Rectangle(15, 32, 32, 32); |
| 225 | BlockRect[5] = new Rectangle(15, 32, 32, 32); |
| 226 | |
| 227 | SelectorRect = new Rectangle[2]; |
| 228 | SelectorRect[0] = new Rectangle(Selector_X, Selector_Y, Selector_Width, Selector_Height); |
| 229 | SelectorRect[1] = new Rectangle(Selector_X2, Selector_Y2, Selector_Width, Selector_Height); |
| 230 | |
| 231 | PlayFieldRect = new Rectangle[2]; |
| 232 | PlayFieldRect[0] = new Rectangle(10, 30, Field_Width, Field_Height); |
| 233 | PlayFieldRect[1] = new Rectangle(680, 30, Field_Width, Field_Height); |
| 234 | |
| 235 | LogoRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, |
| 236 | graphics.GraphicsDevice.Viewport.Height); |
| 237 | |
| 238 | TitleRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, |
| 239 | graphics.GraphicsDevice.Viewport.Height); |
| 240 | |
| 241 | |
| 242 | } |
| 243 | |
| 244 | /// <summary> |
| 245 | /// UnloadContent will be called once per game and is the place to unload |
| 246 | /// all content. |
| 247 | /// </summary> |
| 248 | protected override void UnloadContent() |
| 249 | { |
| 250 | // TODO: Unload any non ContentManager content here |
| 251 | spriteBatch = null; |
| 252 | gameFont = null; |
| 253 | LogoGfx = null; |
| 254 | BlockGfx = null; |
| 255 | CharGfx = null; |
| 256 | PlayFieldGfx = null; |
| 257 | SelectorGfx = null; |
| 258 | } |
| 259 | |
| 260 | /// <summary> |
| 261 | /// Allows the game to run logic such as updating the world, |
| 262 | /// checking for collisions, gathering input, and playing audio. |
| 263 | /// </summary> |
| 264 | /// <param name="gameTime">Provides a snapshot of timing values.</param> |
| 265 | protected override void Update(GameTime gameTime) |
| 266 | { |
| 267 | // Allows the game to exit |
| 268 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) |
| 269 | this.Exit(); |
| 270 | |
| 271 | // TODO: Add your update logic here |
| 272 | lastTick = gameTime.TotalGameTime.Milliseconds; |
| 273 | |
| 274 | if (lastTick > gameTime.TotalGameTime.Milliseconds) |
| 275 | { |
| 276 | deltaTime = 1000 - lastTick + gameTime.TotalGameTime.Milliseconds; |
| 277 | FPS = Convert.ToString(frameCounter); |
| 278 | |
| 279 | frameCounter = 0; |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | deltaTime = gameTime.TotalGameTime.Milliseconds - lastTick; |
| 284 | } |
| 285 | |
| 286 | UpdateInput(gameTime); |
| 287 | |
| 288 | base.Update(gameTime); |
| 289 | } |
| 290 | |
| 291 | private void UpdateInput(GameTime gameTime) |
| 292 | { |
| 293 | KeyboardState currentKey = Keyboard.GetState(); |
| 294 | GamePadState currentButton = GamePad.GetState(PlayerIndex.One); |
| 295 | GamePadState currentButton2 = GamePad.GetState(PlayerIndex.Two); |
| 296 | |
| 297 | if (currentKey.IsKeyDown(Keys.Escape)) |
| 298 | { |
| 299 | this.Exit(); |
| 300 | } |
| 301 | |
| 302 | switch (gScreen) |
| 303 | { |
| 304 | case ScreenState.LogoScreen: |
| 305 | { |
| 306 | if ((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) |
| 307 | { |
| 308 | gScreen = ScreenState.TitleScreen; |
| 309 | } |
| 310 | break; |
| 311 | } |
| 312 | case ScreenState.TitleScreen: |
| 313 | { |
| 314 | if ((currentKey.IsKeyDown(Keys.Up) || currentButton.DPad.Up == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Up) && lastButton.DPad.Up == ButtonState.Released) |
| 315 | { |
| 316 | if (Selected > 0) |
| 317 | –Selected; |
| 318 | } |
| 319 | else if ((currentKey.IsKeyDown(Keys.Down) || currentButton.DPad.Down == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Down) && lastButton.DPad.Down == ButtonState.Released) |
| 320 | { |
| 321 | if (Selected < GameSelection.Length - 1) |
| 322 | ++Selected; |
| 323 | } |
| 324 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 0) |
| 325 | { |
| 326 | gScreen = ScreenState.CharacterSelectScreen; |
| 327 | } |
| 328 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 1) |
| 329 | { |
| 330 | gScreen = ScreenState.CharacterSelectScreen; |
| 331 | } |
| 332 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 2) |
| 333 | { |
| 334 | gScreen = ScreenState.CharacterSelectScreen; |
| 335 | } |
| 336 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 3) |
| 337 | { |
| 338 | gScreen = ScreenState.TutorialScreen; |
| 339 | } |
| 340 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 4) |
| 341 | { |
| 342 | gScreen = ScreenState.CharacterSelectScreen; |
| 343 | } |
| 344 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 5) |
| 345 | { |
| 346 | gScreen = ScreenState.CharacterSelectScreen; |
| 347 | } |
| 348 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 6) |
| 349 | { |
| 350 | gScreen = ScreenState.OptionScreen; |
| 351 | } |
| 352 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 7) |
| 353 | { |
| 354 | this.Exit(); |
| 355 | } |
| 356 | break; |
| 357 | } |
| 358 | |
| 359 | case ScreenState.CharacterSelectScreen: |
| 360 | { |
| 361 | if (currentKey.IsKeyDown(Keys.Enter)) |
| 362 | { |
| 363 | gScreen = ScreenState.AdventureScreen; |
| 364 | } |
| 365 | break; |
| 366 | } |
| 367 | |
| 368 | case ScreenState.AdventureScreen: |
| 369 | { |
| 370 | for (int b = 0 + gNxtBlock.Next(1,6); b < BlockRect.Length; ++b) |
| 371 | { |
| 372 | BlockRect[b].Y = BlockRect[b].Y + 1; |
| 373 | |
| 374 | if (BlockRect[b].Y >= 686) |
| 375 | { |
| 376 | BlockRect[b].Y = 686; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if ((currentKey.IsKeyDown(Keys.Left) || currentButton.DPad.Left == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Left) && lastButton.DPad.Left == ButtonState.Released) |
| 381 | { |
| 382 | SelectorRect[0].X = SelectorRect[0].X - 5; |
| 383 | } |
| 384 | else if ((currentKey.IsKeyDown(Keys.Right) || currentButton.DPad.Right == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Right) && lastButton.DPad.Right == ButtonState.Released) |
| 385 | { |
| 386 | SelectorRect[0].X = SelectorRect[0].X + 5; |
| 387 | } |
| 388 | else if ((currentKey.IsKeyDown(Keys.Up) || currentButton.DPad.Up == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Up) && lastButton.DPad.Up == ButtonState.Released) |
| 389 | { |
| 390 | SelectorRect[0].Y = SelectorRect[0].Y - 5; |
| 391 | } |
| 392 | else if ((currentKey.IsKeyDown(Keys.Down) || currentButton.DPad.Down == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Down) && lastButton.DPad.Down == ButtonState.Released) |
| 393 | { |
| 394 | SelectorRect[0].Y = SelectorRect[0].Y + 5; |
| 395 | } |
| 396 | |
| 397 | if (SelectorRect[0].X <= 15) |
| 398 | { |
| 399 | SelectorRect[0].X++; |
| 400 | } |
| 401 | else if (SelectorRect[0].X >= 206) |
| 402 | { |
| 403 | SelectorRect[0].X–; |
| 404 | } |
| 405 | else if (SelectorRect[0].Y <= 35) |
| 406 | { |
| 407 | SelectorRect[0].Y++; |
| 408 | } |
| 409 | else if (SelectorRect[0].Y >= 591) |
| 410 | { |
| 411 | SelectorRect[0].Y–; |
| 412 | } |
| 413 | |
| 414 | break; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | lastButton = currentButton; |
| 419 | lastButton2 = currentButton2; |
| 420 | lastKey = currentKey; |
| 421 | |
| 422 | } |
| 423 | |
| 424 | /// <summary> |
| 425 | /// This is called when the game should draw itself. |
| 426 | /// </summary> |
| 427 | /// <param name="gameTime">Provides a snapshot of timing values.</param> |
| 428 | protected override void Draw(GameTime gameTime) |
| 429 | { |
| 430 | GraphicsDevice.Clear(Color.CornflowerBlue); |
| 431 | |
| 432 | // TODO: Add your drawing code here |
| 433 | spriteBatch.Begin(SpriteBlendMode.AlphaBlend); |
| 434 | |
| 435 | switch (gScreen) |
| 436 | { |
| 437 | case ScreenState.LogoScreen: |
| 438 | { |
| 439 | spriteBatch.Draw(LogoGfx, LogoRect, Color.White); |
| 440 | break; |
| 441 | } |
| 442 | case ScreenState.TitleScreen: |
| 443 | { |
| 444 | for (int i = 0, n = GameSelection.Length; i != n; ++i) |
| 445 | { |
| 446 | spriteBatch.DrawString(gameFont, GameSelection[i], new Vector2(430, 190 + 50 * i), (i == Selected) ? Color.Yellow : Color.White); |
| 447 | } |
| 448 | break; |
| 449 | } |
| 450 | case ScreenState.CharacterSelectScreen: |
| 451 | { |
| 452 | spriteBatch.Draw(CharGfx[4], CharRect[0], Color.White); |
| 453 | spriteBatch.Draw(CharGfx[1], CharRect[1], Color.White); |
| 454 | spriteBatch.Draw(CharGfx[8], CharRect[2], Color.White); |
| 455 | break; |
| 456 | } |
| 457 | |
| 458 | case ScreenState.AdventureScreen: |
| 459 | { |
| 460 | spriteBatch.Draw(PlayFieldGfx[0], PlayFieldRect[0], Color.White); |
| 461 | spriteBatch.Draw(PlayFieldGfx[1], PlayFieldRect[1], Color.White); |
| 462 | // |
| 463 | spriteBatch.Draw(SelectorGfx[0], SelectorRect[0], Color.White); |
| 464 | spriteBatch.Draw(SelectorGfx[1], SelectorRect[1], Color.White); |
| 465 | // |
| 466 | foreach (Texture2D BlockGf in BlockGfx) |
| 467 | { |
| 468 | foreach (Rectangle BlockRct in BlockRect) |
| 469 | { |
| 470 | spriteBatch.Draw(BlockGf, BlockRct, Color.White); |
| 471 | } |
| 472 | } |
| 473 | break; |
| 474 | } |
| 475 | |
| 476 | } |
| 477 | |
| 478 | spriteBatch.DrawString(gameFont, "Selector X:" + SelectorRect[0].X, new Vector2(1, 1), Color.Yellow); |
| 479 | spriteBatch.DrawString(gameFont, "Selector Y:" + SelectorRect[0].Y, new Vector2(1, 15), Color.Yellow); |
| 480 | |
| 481 | spriteBatch.End(); |
| 482 | |
| 483 | frameCounter++; |
| 484 | base.Draw(gameTime); |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 |
Almost There
Hey Guys,
I have almost have a basic prototype of the gameplay I want for this game. However, I have ran into some problems. I have got the blocks to fall from the screen and stop at the bottom of the playing field. However, the color of the blocks should appear of different colors randomly, all the blocks are yellow. Also, How can I get the blocks to stay inside of the selector? And one last step, How would I do it, so that when the user presses a key, the blocks switch sides? I know how to program input from a controller, I just need the code or an example of how I would switch the two block positions. Here is the code. Thanks for any help.
| 1 | using System; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Linq; |
| 4 | using Microsoft.Xna.Framework; |
| 5 | using Microsoft.Xna.Framework.Audio; |
| 6 | using Microsoft.Xna.Framework.Content; |
| 7 | using Microsoft.Xna.Framework.GamerServices; |
| 8 | using Microsoft.Xna.Framework.Graphics; |
| 9 | using Microsoft.Xna.Framework.Input; |
| 10 | using Microsoft.Xna.Framework.Media; |
| 11 | using Microsoft.Xna.Framework.Net; |
| 12 | using Microsoft.Xna.Framework.Storage; |
| 13 | |
| 14 | namespace Puzzle_Battles |
| 15 | { |
| 16 | /// <summary> |
| 17 | /// This is the main type for your game |
| 18 | /// </summary> |
| 19 | public class Game1 : Microsoft.Xna.Framework.Game |
| 20 | { |
| 21 | GraphicsDeviceManager graphics; |
| 22 | SpriteBatch spriteBatch; |
| 23 | SpriteFont gameFont; |
| 24 | |
| 25 | Texture2D LogoGfx; |
| 26 | Rectangle LogoRect; |
| 27 | |
| 28 | Texture2D[] BlockGfx; |
| 29 | Rectangle[] BlockRect; |
| 30 | |
| 31 | Texture2D TitleGfx; |
| 32 | Rectangle TitleRect; |
| 33 | |
| 34 | |
| 35 | Texture2D[] PlayFieldGfx; |
| 36 | Rectangle[] PlayFieldRect; |
| 37 | |
| 38 | Texture2D[] CharGfx; |
| 39 | Rectangle[] CharRect; |
| 40 | |
| 41 | Texture2D[] SelectorGfx; |
| 42 | Rectangle[] SelectorRect; |
| 43 | |
| 44 | private KeyboardState lastKey = Keyboard.GetState(); |
| 45 | private GamePadState lastButton = GamePad.GetState(PlayerIndex.One); |
| 46 | private GamePadState lastButton2 = GamePad.GetState(PlayerIndex.Two); |
| 47 | |
| 48 | long lastTick = 0; |
| 49 | float FramesPerSec = 0.0f; |
| 50 | float deltaTime = 0.0f; |
| 51 | int lastFrame = 0; |
| 52 | int currentFrame = 0; |
| 53 | int frameCounter = 0; |
| 54 | string FPS = ""; |
| 55 | |
| 56 | string[] GameSelection = new string[] { |
| 57 | "Adventure Mode", //0 |
| 58 | "Gaunlet Mode", //1 |
| 59 | "Tournament Mode", //2 |
| 60 | "Tutorial Mode", //3 |
| 61 | "Local Match", //4 |
| 62 | "Online Match", //5 |
| 63 | "Game Options", //6 |
| 64 | "Exit Game", //7 |
| 65 | }; |
| 66 | |
| 67 | int Selected = 0; |
| 68 | |
| 69 | enum ScreenState |
| 70 | { |
| 71 | LogoScreen, |
| 72 | TitleScreen, |
| 73 | CharacterSelectScreen, |
| 74 | AdventureScreen, |
| 75 | TournamentScreen, |
| 76 | LocalMatchScreen, |
| 77 | TutorialScreen, |
| 78 | GaunletScreen, |
| 79 | OnlineMatchScreen, |
| 80 | OptionScreen |
| 81 | } |
| 82 | |
| 83 | enum GameState |
| 84 | { |
| 85 | Running, |
| 86 | Paused |
| 87 | } |
| 88 | |
| 89 | Color gamePausedColor = Color.TransparentWhite; |
| 90 | bool gamePaused = false; |
| 91 | |
| 92 | ScreenState gScreen = new ScreenState(); |
| 93 | GameState gGameState = new GameState(); |
| 94 | |
| 95 | public const int Field_Width = 334; |
| 96 | public const int Field_Height = 697; |
| 97 | |
| 98 | public const int Block_Width = 32; |
| 99 | public const int Block_Height = 32; |
| 100 | |
| 101 | public const int Selector_Width = 128; |
| 102 | public const int Selector_Height = 128; |
| 103 | |
| 104 | public const float BlockFallSpeed = 0.05f; |
| 105 | public const float BlockAppearRate = 0.10f; |
| 106 | |
| 107 | enum BlockType |
| 108 | { |
| 109 | BlackBlock, |
| 110 | FireBlock, |
| 111 | EarthBlock, |
| 112 | WaterBlock, |
| 113 | WhiteBlock, |
| 114 | WindBlock |
| 115 | } |
| 116 | |
| 117 | Color BlackBlockColor; |
| 118 | Color FireBlockColor; |
| 119 | Color EarthBlockColor; |
| 120 | Color WaterBlockColor; |
| 121 | Color WhiteBlockColor; |
| 122 | Color WindBlockColor; |
| 123 | |
| 124 | BlockType gBlockType = new BlockType(); |
| 125 | |
| 126 | List<Vector2> BlockPos = new List<Vector2>(); |
| 127 | |
| 128 | Random gNxtBlock = new Random(); |
| 129 | Random gNxtFallBlock = new Random(); |
| 130 | |
| 131 | public const int MAX_ROWS = 60; |
| 132 | public const int MAX_COLMNS = 30; |
| 133 | |
| 134 | public int Selector_X = 20; |
| 135 | public int Selector_Y = 50; |
| 136 | public int Selector_X2 = 690; |
| 137 | public int Selector_Y2 = 50; |
| 138 | |
| 139 | public Game1() |
| 140 | { |
| 141 | graphics = new GraphicsDeviceManager(this); |
| 142 | Content.RootDirectory = "Content"; |
| 143 | |
| 144 | this.graphics.PreferredBackBufferWidth = 1024; |
| 145 | this.graphics.PreferredBackBufferHeight = 768; |
| 146 | |
| 147 | this.IsMouseVisible = true; |
| 148 | this.IsFixedTimeStep = false; |
| 149 | |
| 150 | gScreen = ScreenState.LogoScreen; |
| 151 | gGameState = GameState.Running; |
| 152 | } |
| 153 | |
| 154 | /// <summary> |
| 155 | /// Allows the game to perform any initialization it needs to before starting to run. |
| 156 | /// This is where it can query for any required services and load any non-graphic |
| 157 | /// related content. Calling base.Initialize will enumerate through any components |
| 158 | /// and initialize them as well. |
| 159 | /// </summary> |
| 160 | protected override void Initialize() |
| 161 | { |
| 162 | // TODO: Add your initialization logic here |
| 163 | |
| 164 | base.Initialize(); |
| 165 | } |
| 166 | |
| 167 | /// <summary> |
| 168 | /// LoadContent will be called once per game and is the place to load |
| 169 | /// all of your content. |
| 170 | /// </summary> |
| 171 | protected override void LoadContent() |
| 172 | { |
| 173 | // Create a new SpriteBatch, which can be used to draw textures. |
| 174 | spriteBatch = new SpriteBatch(GraphicsDevice); |
| 175 | |
| 176 | // TODO: use this.Content to load your game content here |
| 177 | gameFont = Content.Load<SpriteFont>("mainFont"); |
| 178 | |
| 179 | PlayFieldGfx = new Texture2D[2]; |
| 180 | PlayFieldGfx[0] = Content.Load<Texture2D>("play_field"); |
| 181 | PlayFieldGfx[1] = Content.Load<Texture2D>("play_field"); |
| 182 | |
| 183 | int BlockW = PlayFieldGfx[0].Width / Field_Width; |
| 184 | int BlockH = PlayFieldGfx[0].Height / Field_Height; |
| 185 | int BlockW2 = PlayFieldGfx[1].Width / Field_Width; |
| 186 | int BlockH2 = PlayFieldGfx[1].Height / Field_Height; |
| 187 | |
| 188 | |
| 189 | SelectorGfx = new Texture2D[2]; |
| 190 | SelectorGfx[0] = Content.Load<Texture2D>("selector"); |
| 191 | SelectorGfx[1] = Content.Load<Texture2D>("selector"); |
| 192 | |
| 193 | CharGfx = new Texture2D[9]; |
| 194 | CharGfx[0] = Content.Load<Texture2D>("Cynthia puzzle 2"); |
| 195 | CharGfx[1] = Content.Load<Texture2D>("Cynthia puzzle"); |
| 196 | CharGfx[2] = Content.Load<Texture2D>("Cynthia thumb"); |
| 197 | CharGfx[3] = Content.Load<Texture2D>("Cynthia thumb2"); |
| 198 | CharGfx[4] = Content.Load<Texture2D>("Epic Puzzle"); |
| 199 | CharGfx[5] = Content.Load<Texture2D>("Epic Puzzle2"); |
| 200 | CharGfx[6] = Content.Load<Texture2D>("Epic thumb 2"); |
| 201 | CharGfx[7] = Content.Load<Texture2D>("Epic thumb"); |
| 202 | CharGfx[8] = Content.Load<Texture2D>("trufa heart"); |
| 203 | |
| 204 | LogoGfx = Content.Load<Texture2D>("Logo"); |
| 205 | |
| 206 | CharRect = new Rectangle[3]; |
| 207 | CharRect[0] = new Rectangle(250, 200, 128, 128); |
| 208 | CharRect[1] = new Rectangle(380, 200, 128, 128); |
| 209 | CharRect[2] = new Rectangle(500, 200, 128, 128); |
| 210 | |
| 211 | BlockGfx = new Texture2D[6]; |
| 212 | BlockGfx[0] = Content.Load<Texture2D>("black_block"); |
| 213 | BlockGfx[1] = Content.Load<Texture2D>("earth_block"); |
| 214 | BlockGfx[2] = Content.Load<Texture2D>("fire_block"); |
| 215 | BlockGfx[3] = Content.Load<Texture2D>("water_block"); |
| 216 | BlockGfx[4] = Content.Load<Texture2D>("white_block"); |
| 217 | BlockGfx[5] = Content.Load<Texture2D>("wind_block"); |
| 218 | |
| 219 | BlockRect = new Rectangle[6]; |
| 220 | BlockRect[0] = new Rectangle(15, 32, 32, 32); |
| 221 | BlockRect[1] = new Rectangle(45, 32, 32, 32); |
| 222 | BlockRect[2] = new Rectangle(15, 32, 32, 32); |
| 223 | BlockRect[3] = new Rectangle(15, 32, 32, 32); |
| 224 | BlockRect[4] = new Rectangle(15, 32, 32, 32); |
| 225 | BlockRect[5] = new Rectangle(15, 32, 32, 32); |
| 226 | |
| 227 | SelectorRect = new Rectangle[2]; |
| 228 | SelectorRect[0] = new Rectangle(Selector_X, Selector_Y, Selector_Width, Selector_Height); |
| 229 | SelectorRect[1] = new Rectangle(Selector_X2, Selector_Y2, Selector_Width, Selector_Height); |
| 230 | |
| 231 | PlayFieldRect = new Rectangle[2]; |
| 232 | PlayFieldRect[0] = new Rectangle(10, 30, Field_Width, Field_Height); |
| 233 | PlayFieldRect[1] = new Rectangle(680, 30, Field_Width, Field_Height); |
| 234 | |
| 235 | LogoRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, |
| 236 | graphics.GraphicsDevice.Viewport.Height); |
| 237 | |
| 238 | TitleRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, |
| 239 | graphics.GraphicsDevice.Viewport.Height); |
| 240 | |
| 241 | |
| 242 | } |
| 243 | |
| 244 | /// <summary> |
| 245 | /// UnloadContent will be called once per game and is the place to unload |
| 246 | /// all content. |
| 247 | /// </summary> |
| 248 | protected override void UnloadContent() |
| 249 | { |
| 250 | // TODO: Unload any non ContentManager content here |
| 251 | spriteBatch = null; |
| 252 | gameFont = null; |
| 253 | LogoGfx = null; |
| 254 | BlockGfx = null; |
| 255 | CharGfx = null; |
| 256 | PlayFieldGfx = null; |
| 257 | SelectorGfx = null; |
| 258 | } |
| 259 | |
| 260 | /// <summary> |
| 261 | /// Allows the game to run logic such as updating the world, |
| 262 | /// checking for collisions, gathering input, and playing audio. |
| 263 | /// </summary> |
| 264 | /// <param name="gameTime">Provides a snapshot of timing values.</param> |
| 265 | protected override void Update(GameTime gameTime) |
| 266 | { |
| 267 | // Allows the game to exit |
| 268 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) |
| 269 | this.Exit(); |
| 270 | |
| 271 | // TODO: Add your update logic here |
| 272 | lastTick = gameTime.TotalGameTime.Milliseconds; |
| 273 | |
| 274 | if (lastTick > gameTime.TotalGameTime.Milliseconds) |
| 275 | { |
| 276 | deltaTime = 1000 - lastTick + gameTime.TotalGameTime.Milliseconds; |
| 277 | FPS = Convert.ToString(frameCounter); |
| 278 | |
| 279 | frameCounter = 0; |
| 280 | } |
| 281 | else |
| 282 | { |
| 283 | deltaTime = gameTime.TotalGameTime.Milliseconds - lastTick; |
| 284 | } |
| 285 | |
| 286 | UpdateInput(gameTime); |
| 287 | |
| 288 | base.Update(gameTime); |
| 289 | } |
| 290 | |
| 291 | private void UpdateInput(GameTime gameTime) |
| 292 | { |
| 293 | KeyboardState currentKey = Keyboard.GetState(); |
| 294 | GamePadState currentButton = GamePad.GetState(PlayerIndex.One); |
| 295 | GamePadState currentButton2 = GamePad.GetState(PlayerIndex.Two); |
| 296 | |
| 297 | if (currentKey.IsKeyDown(Keys.Escape)) |
| 298 | { |
| 299 | this.Exit(); |
| 300 | } |
| 301 | |
| 302 | switch (gScreen) |
| 303 | { |
| 304 | case ScreenState.LogoScreen: |
| 305 | { |
| 306 | if ((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) |
| 307 | { |
| 308 | gScreen = ScreenState.TitleScreen; |
| 309 | } |
| 310 | break; |
| 311 | } |
| 312 | case ScreenState.TitleScreen: |
| 313 | { |
| 314 | if ((currentKey.IsKeyDown(Keys.Up) || currentButton.DPad.Up == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Up) && lastButton.DPad.Up == ButtonState.Released) |
| 315 | { |
| 316 | if (Selected > 0) |
| 317 | –Selected; |
| 318 | } |
| 319 | else if ((currentKey.IsKeyDown(Keys.Down) || currentButton.DPad.Down == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Down) && lastButton.DPad.Down == ButtonState.Released) |
| 320 | { |
| 321 | if (Selected < GameSelection.Length - 1) |
| 322 | ++Selected; |
| 323 | } |
| 324 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 0) |
| 325 | { |
| 326 | gScreen = ScreenState.CharacterSelectScreen; |
| 327 | } |
| 328 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 1) |
| 329 | { |
| 330 | gScreen = ScreenState.CharacterSelectScreen; |
| 331 | } |
| 332 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 2) |
| 333 | { |
| 334 | gScreen = ScreenState.CharacterSelectScreen; |
| 335 | } |
| 336 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 3) |
| 337 | { |
| 338 | gScreen = ScreenState.TutorialScreen; |
| 339 | } |
| 340 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 4) |
| 341 | { |
| 342 | gScreen = ScreenState.CharacterSelectScreen; |
| 343 | } |
| 344 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 5) |
| 345 | { |
| 346 | gScreen = ScreenState.CharacterSelectScreen; |
| 347 | } |
| 348 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 6) |
| 349 | { |
| 350 | gScreen = ScreenState.OptionScreen; |
| 351 | } |
| 352 | else if (((currentKey.IsKeyDown(Keys.Enter) || currentButton.Buttons.Start == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Enter) && lastButton.Buttons.Start == ButtonState.Released) || currentButton.Buttons.A == ButtonState.Pressed && lastButton.Buttons.A == ButtonState.Released && Selected == 7) |
| 353 | { |
| 354 | this.Exit(); |
| 355 | } |
| 356 | break; |
| 357 | } |
| 358 | |
| 359 | case ScreenState.CharacterSelectScreen: |
| 360 | { |
| 361 | if (currentKey.IsKeyDown(Keys.Enter)) |
| 362 | { |
| 363 | gScreen = ScreenState.AdventureScreen; |
| 364 | } |
| 365 | break; |
| 366 | } |
| 367 | |
| 368 | case ScreenState.AdventureScreen: |
| 369 | { |
| 370 | for (int b = 0 + gNxtBlock.Next(1,6); b < BlockRect.Length; ++b) |
| 371 | { |
| 372 | BlockRect[b].Y = BlockRect[b].Y + 1; |
| 373 | |
| 374 | if (BlockRect[b].Y >= 686) |
| 375 | { |
| 376 | BlockRect[b].Y = 686; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if ((currentKey.IsKeyDown(Keys.Left) || currentButton.DPad.Left == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Left) && lastButton.DPad.Left == ButtonState.Released) |
| 381 | { |
| 382 | SelectorRect[0].X = SelectorRect[0].X - 5; |
| 383 | } |
| 384 | else if ((currentKey.IsKeyDown(Keys.Right) || currentButton.DPad.Right == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Right) && lastButton.DPad.Right == ButtonState.Released) |
| 385 | { |
| 386 | SelectorRect[0].X = SelectorRect[0].X + 5; |
| 387 | } |
| 388 | else if ((currentKey.IsKeyDown(Keys.Up) || currentButton.DPad.Up == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Up) && lastButton.DPad.Up == ButtonState.Released) |
| 389 | { |
| 390 | SelectorRect[0].Y = SelectorRect[0].Y - 5; |
| 391 | } |
| 392 | else if ((currentKey.IsKeyDown(Keys.Down) || currentButton.DPad.Down == ButtonState.Pressed) && !lastKey.IsKeyDown(Keys.Down) && lastButton.DPad.Down == ButtonState.Released) |
| 393 | { |
| 394 | SelectorRect[0].Y = SelectorRect[0].Y + 5; |
| 395 | } |
| 396 | |
| 397 | if (SelectorRect[0].X <= 15) |
| 398 | { |
| 399 | SelectorRect[0].X++; |
| 400 | } |
| 401 | else if (SelectorRect[0].X >= 206) |
| 402 | { |
| 403 | SelectorRect[0].X–; |
| 404 | } |
| 405 | else if (SelectorRect[0].Y <= 35) |
| 406 | { |
| 407 | SelectorRect[0].Y++; |
| 408 | } |
| 409 | else if (SelectorRect[0].Y >= 591) |
| 410 | { |
| 411 | SelectorRect[0].Y–; |
| 412 | } |
| 413 | |
| 414 | break; |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | lastButton = currentButton; |
| 419 | lastButton2 = currentButton2; |
| 420 | lastKey = currentKey; |
| 421 | |
| 422 | } |
| 423 | |
| 424 | /// <summary> |
| 425 | /// This is called when the game should draw itself. |
| 426 | /// </summary> |
| 427 | /// <param name="gameTime">Provides a snapshot of timing values.</param> |
| 428 | protected override void Draw(GameTime gameTime) |
| 429 | { |
| 430 | GraphicsDevice.Clear(Color.CornflowerBlue); |
| 431 | |
| 432 | // TODO: Add your drawing code here |
| 433 | spriteBatch.Begin(SpriteBlendMode.AlphaBlend); |
| 434 | |
| 435 | switch (gScreen) |
| 436 | { |
| 437 | case ScreenState.LogoScreen: |
| 438 | { |
| 439 | spriteBatch.Draw(LogoGfx, LogoRect, Color.White); |
| 440 | break; |
| 441 | } |
| 442 | case ScreenState.TitleScreen: |
| 443 | { |
| 444 | for (int i = 0, n = GameSelection.Length; i != n; ++i) |
| 445 | { |
| 446 | spriteBatch.DrawString(gameFont, GameSelection[i], new Vector2(430, 190 + 50 * i), (i == Selected) ? Color.Yellow : Color.White); |
| 447 | } |
| 448 | break; |
| 449 | } |
| 450 | case ScreenState.CharacterSelectScreen: |
| 451 | { |
| 452 | spriteBatch.Draw(CharGfx[4], CharRect[0], Color.White); |
| 453 | spriteBatch.Draw(CharGfx[1], CharRect[1], Color.White); |
| 454 | spriteBatch.Draw(CharGfx[8], CharRect[2], Color.White); |
| 455 | break; |
| 456 | } |
| 457 | |
| 458 | case ScreenState.AdventureScreen: |
| 459 | { |
| 460 | spriteBatch.Draw(PlayFieldGfx[0], PlayFieldRect[0], Color.White); |
| 461 | spriteBatch.Draw(PlayFieldGfx[1], PlayFieldRect[1], Color.White); |
| 462 | // |
| 463 | spriteBatch.Draw(SelectorGfx[0], SelectorRect[0], Color.White); |
| 464 | spriteBatch.Draw(SelectorGfx[1], SelectorRect[1], Color.White); |
| 465 | // |
| 466 | foreach (Texture2D BlockGf in BlockGfx) |
| 467 | { |
| 468 | foreach (Rectangle BlockRct in BlockRect) |
| 469 | { |
| 470 | spriteBatch.Draw(BlockGf, BlockRct, Color.White); |
| 471 | } |
| 472 | } |
| 473 | break; |
| 474 | } |
| 475 | |
| 476 | } |
| 477 | |
| 478 | spriteBatch.DrawString(gameFont, "Selector X:" + SelectorRect[0].X, new Vector2(1, 1), Color.Yellow); |
| 479 | spriteBatch.DrawString(gameFont, "Selector Y:" + SelectorRect[0].Y, new Vector2(1, 15), Color.Yellow); |
| 480 | |
| 481 | spriteBatch.End(); |
| 482 | |
| 483 | frameCounter++; |
| 484 | base.Draw(gameTime); |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 |
CodePlex Daily Summary for Monday, February 08, 2010
CodePlex Daily Summary for Monday, February 08, 2010
New Projects
- Agile Poker Cards for Windows Mobile: During a scrum or other agile processes, you have to estimate the size of a user story during a planning session. With the Agile Poker Cards progr…
- Allegro.net Computational Libraries: Allegro.net libraries provide computational support on the .NET platform. Allegro Mathlib contains classes that implement mathematical operations. …
- Assembly Signer: This tool is designed to sign unsigned assemblies(in compiled libraries) with specified key .snk file for .net 1.1 and 2.0. This is a required t…
- AxLINQ: AxLINQ provides a LINQ like query syntax for the X++ language found in Dynamics Ax. enumerator = xFrom(myInt).in(myIntArray) …
- Begin C#: kano's personal project
- BITSCopy: Transfer content by BITS (Background Intelligent Transfer Service). Command line utility. Add item to Explorer Context Menu.
- CC.Votd: A screensaver that displays a verse of the day or a random verse. Verses are provided from the RSS feed hosted by Good News & Crossway at www.gnpc…
- CKEditor SliverlightUploadImage plugin: An image manager plugin for CKEditor that uses Micheal Posts Silverlight uploader Control (http://slfileupload.codeplex.com/). The source included…
- Claymore MVP: Claymore is a simple MVP (Model View Presenter) framework targetting .NET developers.
- CMT Lite: CMT Lite is a content management project I started some time ago and have used to develop a number of websites.
- Dynamic Unity: DynamicUnity
- ferrum.contract: Design by Contract library implemented using PostSharp
- GTAScript.Net: GTAScript.Net is a collection on CLI wrapper classes & services to provide an object oriented scripting structure in .Net CLR languages for GTA IV.
- KleinWereldje: At first this is a pet project meant to be a ducth social community building site. Meanly meant to learn MVC architecture
- Netology SuperHero: Hero is data access layer generator for Microsoft Application Block. I wanna try mini O/R Map tool. Enjoy !
- NukeCS: this is a complete c# version of DotNetNuke, based on the latest version(5.2.2).
- RaidTracker: RaidTracker is lightweight Raid and DKP tracking system.
- RetryActivity Sample: This project contains examples of the use of WorkflowQueue in Windows Workflow Foundation (WWF). Language: C#
- Team Legacy: Here is our Legacy project because we are a Legacy
- Team WTF - Software Project: This software project is for Team WTFs course project at Concordia University. The aim is to build a game from the ground up using C#, using the un…
- TwitterPad: TwitterPad is a software to work with twitter.com web site without any proxy or anti-filter
- Urdu Controls: This is a library of .Net controls for easily developing Urdu applications. The edit controls support phonetic Urdu keyboard. The included sample a…
- VFPnfe: Projeto Open Source sob licença pública GNU,GPL para emissão de nota fiscal eletronica em Visual FoxPro. Visite o blog -> http://supervfp.blogsp…
- VSV: VSV A Visual Basic Syntax Highlighter written in Visual Basic .net.
- WCF Metal: By utilizing LINQ to SQL classes (made by either the designer or SqlMetal), WCFMetal generates configurable, extensible WCF based data access web s…
- WebLoadGen: I created this application for the analysis one of my ideas. This application would simulate n web users by initiating a thread for each user, rand…
- Whale watch: Whale watch is a volunteer developer whale watch site, uses C#, MVC, Fluent NHiberate, NUnit and Castle. The project is at a vey early stage, bu…
- WpfTelemetry: WpfTelemetry is a library for WPF projects to allow tracking of feature usage and client computer capabilities.
- Xplora Web Browser: Xplora Web Browser is an advanced Visual Basic 2008 Web Browser. Xplora is now gradually moving to C# WPF.
- xProject: system for online marketing
New Releases
- Aero Wizard .NET Library: Aero Wizard 1.0 Release: Public 1.0 release. Includes control library and test/demo application. Since beta 2: Updated control toolbox bitmap Fixed problem with WizardC…
- Agile Poker Cards for Windows Mobile: Agile Poker Cards v1.0.5.0: Agile Poker Cards v1.0.5.0 This is the first release of the Agile Poker Cards application. Use this application to display poker cards in a planni…
- Assembly Signer: Initial Release: The initial release. Sources and binaries are in archive below
- AxLINQ: AxLINQ version 1.0: AxLINQ provides a LINQ like query syntax for the X++ language found in Dynamics Ax. enumerator = xFrom(myInt).in(myIntArray) …
- BITSCopy: BITSCopy 1.0.0 x86: BITSCopy Setup x86
- CC.Utilities: CC.Utilities 1.0.10.208: Minor update release of CC.Utilities to add some new features. Still marked as beta since I don't have much outside feedback yet.
- DiskLight.NET: Disklight 1.0.2 (compatible with .NET 2.0 and up): The Disklight 1.0.2 setup project has been rebuilt so that it no longer has a dependency on .NET 3.5
- HSS Interlink File Upload/Download: HSS.Interlink_2.0.0_Installer_x86: BE SURE to download and install the HSS Core Framework first!HSS.Core_4.0.200_Installer_x86.msi Release Notes: http://highspeed-solutions.net/down…
- IdeaSparks ASP.NET CoolControls: Build 20100207: Release Notes COLGROUP and COL is back. These are generated for the header, table content and footer. Added AllowResizeColumn property to CoolGr…
- jQuery Web Controls ASP.Net: jQueryWebControls 1.1: Se han solucionado varios problemas que tenían los controles. Se ha compatibilizado el ControlFx para que detecte los controles de las páginas Mast…
- MiniTwitter: 1.07: MiniTwitter 1.07 更新内容 追加 ハッシュタグの入力補完を実装 更新チェック機能を実装 変更 入力補完が大文字と小文字を区別していたのを区別しないように変更 ハッシュタグとして認識する条件を変更 検索パネル周りの挙動を改善 140 文字を超える場合は強制的に…
- OAuthLib: OAuthLib (1.4.0.1): Same for the last one of 1.4.0.0 except for version number.
- Ox Game Engine for XNA: Release 69 Beta - Removed Superfluous Interfaces: There were a large amount of API changes this release. I'll explain. For a year or so I've been regretting my massive overuse (abuse) of C# interf…
- Paint.NET PSD Plugin: 1.0.5: Notes Retargeted to Paint.NET 3.5.2 and .NET Framework 3.5. Changes Smaller file sizes for multi-layer images. Layer blend modes are now saved c…
- PoshOnTap: PoshOnTap 2.1.0: Added NFS module! Fixed a couple typo's, and reworked installer.
- RaidTracker: RaidTracker: This is fully working version with not so user friendy administration.
- SAF - (A SharePoint Build and Deployment Tool): SAF 2.0.3900.09: SAF is a way to automate and repeat configuration changes in SharePoint using "Actions". These actions can then be grouped together as Xml into a "…
- SharePoint LogViewer: SharePointLogViewer development release: This is the development release which has live monitoring support.
- Task Scheduler Managed Wrapper: Release 1.5 Beta: Stable and production ready for all classes and controls other than TaskEditDialog and TaskSchedulerWizard. Labeled Beta as those two controls are …
- Urdu Controls: Urdu_Controls_v_0.01: This is the initial release of the .net library of Urdu Controls.
- VCC: Latest build, v2.1.30207.0: Automatic drop of latest build
- VFPnfe: vfpnfe: Projeto VFPnfe - Emissão de nota fiscal eletrônica sob licença pública GNU,GPL desenvolvido em Visual FoxPro para maiores informações visite o blog…
- Visual Studio DSite: Monster Hunter Mouse Cursors: These cursors of monster hunter were made by me monsterhunter445 aka Daniel Lopez. The windows installer package will install the cursors in the d…
- VivoSocial: VivoSocial 7.0.1: VivoSocial version 7.0.1 VivoSocialzip includes a DotNetNuke 5.2.2 Community edition site setup using the modules listed as "Other Available Downl…
- WCF Metal: WCFMetal 0.2.9.1a: By utilizing LINQ to SQL generated classes (generated by either the designer or SqlMetal), WCFMetal generates configurable, extensible WCF (Windows…
- WinForms Group Controls: WinForms Group Controls 1.1: Full release. If you find problems, please post them. If you like it, please comment.
- XsltDb - DotNetNuke XSLT module: 01.00.78: The module was tested in a new commercial project (~50 instances fo XsltDb). Also some new features were added: PA or SU modules (PA - Portal Admin…
Most Popular Projects
- Rawr
- WBFS Manager
- AJAX Control Toolkit
- Microsoft SQL Server Product Samples: Database
- Silverlight Toolkit
- Windows Presentation Foundation (WPF)
- BlogEngine.NET
- PHPExcel
- ASP.NET
- Microsoft SQL Server Community & Samples
Most Active Projects
- Rapid Entity Framework. (ORM). CTP 2
- BlogEngine.NET
- patterns & practices – Enterprise Library
- Rawr
- Ox Game Engine for XNA
- iTuner - The iTunes Companion
- TwitterVB - A .NET Twitter Library
- PHPExcel
- DotNetZip Library
- SharePoint Learning Kit
CodePlex Daily Summary for Sunday, February 07, 2010
CodePlex Daily Summary for Sunday, February 07, 2010
New Projects
- ATAPI - Managed TAPI wrapper for TAPI 2.0: Managed .NET library for interacting with the Microsoft Telephony API (TAPI) 2.x. This library is for creating clients that consume telephony serv…
- BahaiReader: BahaiReader
- Benchmarks, Performance and Speed Tests for the .NET and Mono Frameworks: Benchmarks, performance and speed tests of basic algorithms, structures and patterns for the Microsoft .NET Framework and Novell Mono Framework. G…
- Campus RTS: This is an RTS game built with Microsoft's XNA Framework built by four college students in a senior project course. Fun!
- CodeEdit: CodeEdit is a more code based version of notepad. It's developed in C#.
- EasyColor: EasyColor makes it easier for programmers to Get Pixel colors. You'll no longer have to rely on complex imaging software. It's developed in VB.NET …
- EasyDump: EasyDump makes it easier for DBAs to perform backups. You'll no longer have to write complex batch files. It's developed in VB.NET 2008.
- HSS Core Framework: The HSS Core Framework extends the .NET Framework providing several key sub-systems that provide enhanced functionality and consistency to any prod…
- HSS Interlink: HSS Interlink™ The Silverlight File Upload and Download Suite, is a free Silverlight 4 application. It can be used to upload and download files to/…
- IncEditor: IncEditor is an editor which is a little better than Notepad. It is built in WPF using the MVVM Design Pattern and Managed Extensions Framework.
- ITAPI3 - Managed .NET Library for TAPI 3.0 Development: This C++/CLI library is for applications that want to access TAPI 3.x functions. The existing .NET RCW cannot be used with TAPI 3.0 due to some is…
- JulMar MVVM Helpers + Behaviors: The MVVM Helper + Behavior library is a set of classes for WPF developers to help them build Model-View-ViewModel oriented applications. It includ…
- Left 4 Dead 2 Gore Loader: Left 4 Dead 2 Gore Loader. Uncensor L4D2 game in censored regions. Automated checks of changing files and L4D2 updates to ensure there the approria…
- NetCourseGreg: NetCourseGreg
- nicheer: nicheer
- Paint.NET PSD Plugin: A Paint.NET plug in for loading and saving Photoshop files.
- Powershell Hyper-V Extensions: Powershell Extension for Hyper-V and supporting technologies like Failover-Clustering and SCVMM.
- PowershellCertificateHelper: A certificate helper module for powershell. Augments the certificate provider that ships with powershell.
- RedditClone: An attempt to make a very simple Reddit clone in as little code as possible, while still being somewhat well designed. Mainly for fun, because Redd…
- SEMICO Framework: Componen Framework Code
- SharePoint 2007 - Create SharePoint Meeting Workspace (Fix for non-Site Admins): In SharePoint Meeting Workspaces cannot be created by users that do not have "Create Sites" permission. I do not want to allow my users access to …
- Splish Splash: Splish Splash is a pair of C++ executables (splish and splash) that stream the audio from one Vista+ PC to another. Play music on your laptop and …
- Taffy: Taffy changes the playback speed of your podcasts without affecting their pitch. Written in ASP.NET, it's a podcast "proxy" of sorts. It "stretche…
- Tim Murphy: This project is a collection of library, examples and applications written in VB.NET by Tim Murphy, www.26tp.com.
- Utf8Checker: C# class that determines if given file or stream is encoded in UTF8
- Voodoo toolkit for SharePoint: Welcome to the Voodoo toolkit for SharePoint, the goal of this project is to develop and distribute tools for users of SharePoint Foundation (curre…
- WPF ShaderEffect Generator: The WPF ShaderEffect Generator is an integration to Visual Studio to automatically generate the code-behind ShaderEffect classes for shader (*.fx) …
New Releases
- ATAPI - Managed TAPI wrapper for TAPI 2.0: ATAPI 1.2.0.0: Initial release to Codeplex.
- CodeEdit: CodeEdit 1.7: This is a beta release of CodeEdit. I will fix any bugs reported and try to add any feature requests.
- DNN LocalizationEditor: 03.02.00 B1: This is a beta release. There are no guarantees you can upgrade to the next version. Please use for testing purposes. In this release you'll find …
- EasyColor: Release 1.0.0: EasyColor 1.0.0. 1st release Color Capture Color Selector RGB & HEX support
- EasyDump: Release 1.0.0: EasyDump 1.0.0 *Exports Tables & Data(5k row inserts) *Exports Views *Exports Procedures & Functions *Exports Triggers *Exports Event *Handles nul…
- Fluent Validation for .NET: 1.2 Beta 2: Please note: The ASP.NET MVC integration in this release is only compatible with ASP.NET MVC2 RC2. If you need to use FluentValidation with ASP.NET…
- Google Voice Visual Voicemail: .10 (first release): This is a "CTP" or "Alpha" or "Early Beta" or whatever you want to call it. It will download and play your voicemails and not much else. It is us…
- HeadLinx AD: HeadLinx AD 1.0.0.15: This release contains a minor feature and bug fix: Ability to use JpegPhoto attribute in AD instead of ThumbnailPhoto. This may be necessary in so…
- HSS Core Framework: HSS.Core_4.0.200_Installer_x86: Latest release. Stable but will remain in BETA status as .NET 4 is still in BETA.
- ITAPI3 - Managed .NET Library for TAPI 3.0 Development: Version 1.0.0.3: Initial release to codeplex.
- JC Change Calculator Control: Beta v1.0: Easily integrate touch screen change calculation into any Point of Sale (POS) style application. This is a beta release and should be tested before…
- JulMar MVVM Helpers + Behaviors: Version 1.05: Added support for VS2010 Beta 2 Removed ViewModel.OnPropertiesChanged - merged into ViewModel.OnPropertyChanged BREAKING CHANGE Added generic s…
- MAC Name Server: MacNS 0.99 Beta: This new version is now based on the Streambolics library to perform background tasks. The polling of MAC addresses is now done in a background thr…
- MDownloader: MDownloader-0.14.4.55402: Fixed performance bugs. Changed RSS links update policy.
- NUnrar: NUnrar 0.5: This adds the RarArchiveFactory to allow different creations for the non-seekable streaming usage. Declaring this as beta :)
- PerceptiveMCAPI - A .NET wrapper for the MailChimp Api: V1.2.3 — PerceptiveMCAPI .Net Wrapper and UI: PerceptiveMCAPI – v 1.2.3 Change log .NET WrapperNew wrapper directives; api_MethodType and api_EncodeRequest – CodePlex #3610The api_MethodType di…
- Project WIFE: v0_0_0_5: This release version Includes A capability to "Tidy Up" Ini Files. Bug Fix: Allow a few more additional characters in Values.
- Sharp Tests Ex: Sharp Tests Extensions 1.0.0RC1: Project Description #TestsEx (Sharp Tests Extensions) is a set of extensible extensions. The main target is write short assertions where the Visual…
- Splish Splash: Splish Splash 0.1: Initial release. Not many features, but it works. Known issues: The default sound format in Windows must be configured to 44100Hz. Connecting by…
- Splish Splash: Splish Splash 0.2: Changes: Added pointer to Configuring Windows Default Audio Format in the error message if the sample rate isn't 44100. Changed splish.exe to con…
- Taffy: 0.5.0 beta: Taffy stretches your podcasts. Version 0.5.0 beta: Initial public release.
- Thinktecture.IdentityModel: Thinktecture.IdentityModel v0.7: Updated version. This is the version included in StarterSTS 1.0 B1
- TS3QueryLib.Net: TS3QueryLib.Net Version 0.17.12.0: Changelog Fixed memory leak. (undisposed SocketAsyncEventArgs)
- TwitterPad: TwitterPad 0.5.1 beta Portable: TwitterPad 0.5.1 beta Portable for test usage
- TwitterVB - A .NET Twitter Library: TwitterVB-2.2.1: This release corrects the issues with special characters. NOTE - As of this version of the library, multibyte characters and non-english character…
- Utf8Checker: UtfChecker 0.1: First public release - feel free do downlad the code and use it in your project.
- VCC: Latest build, v2.1.30206.0: Automatic drop of latest build
- Visual Studio DSite: Windows Live Messenger Phisher (Visual Basic 2008): DISCLAMER: This source code is for educational purposes and I hereby do not wan't people to use this source code in a malicious way. If you do I…
- Voodoo toolkit for SharePoint: Initial beta release: The SharePoint 2010 solution package is provided as well as a source package. For Read/Unread marks it is feature complete but perhaps a bit buggy.
- VsTortoise - a TortoiseSVN add-in for Microsoft Visual Studio: VsTortoise Build 21 Beta: Here is the changelog since latest stable release: Build 21 (beta) Fix: Fixed error at Visual Studio startup when VsTortoise' en-US satellite DLL …
Most Popular Projects
- Rawr
- WBFS Manager
- AJAX Control Toolkit
- Microsoft SQL Server Product Samples: Database
- Silverlight Toolkit
- Windows Presentation Foundation (WPF)
- BlogEngine.NET
- PHPExcel
- ASP.NET
- Microsoft SQL Server Community & Samples
Most Active Projects










