Personal Information

We're trying to increase the speed of the annotation. It has been using GDI+. It seems the next gen technology is Direct2D and that the C# version is a wrapper named SharpDX.
Would it really take that much code to do what GDI+ is able to do in 2 lines? I'm not familiar with SharpDX, so I'm asking.

Does anyone know how you would do simple text annotation using "SharpDX" library (for C#)?
Here is how GDI+ does it currently in my app (in particular, the bold red lines are of interest):
using (Graphics g = Graphics.FromImage(bm))
using (SolidBrush solidWhiteBrush = new SolidBrush(Color.White))
using (SolidBrush solidBlackBrush = new SolidBrush(Color.Black))
{
// Write out annotation text
[color=#ff0000][b] g.FillRectangle(solidWhiteBrush, 0, 0, bm.Width, bm.Height);[/b][/color]
[color=#ff0000][b] g.DrawString(AnnotationText, AnnotationFont, solidBlackBrush, new PointF(7f, 2f));[/b][/color]
Thank you for sample code showing how this would be done using SharpDX!
Tom

I am struggling with making my sprite sheets work correctly.
It seems like every time I make a small change, like adding a few more cells to an animation sequence - I start to get some "drift" in the animation. Instead of the animation staying in one place it kind of moves while it is animating. I hope somebody knows what I am talking about. Sometimes playing with the width of the destination rectangle seems to adjust it and fix it, but not this time.
Are there tools that can help me create and maintain stable dependable spritesheets?

[quote name='Tsus' timestamp='1324716005' post='4897033']
[quote name='flashinpan' timestamp='1324694350' post='4896982']
I was wondering if there was a way to add more of a delay once the frame hits frame 4. The reason I ask is that on frame 4 the power "light" has hit the max intensity before it fades again and I want it to stay "fully lit" for longer than the other cells in the sequence. I just think it makes the power source "pulsing" look cooler. How can I do that?
[/quote]
The trick would be to manipulate the progress of the time.
You can keep a variable that stores “your” totally passed time and with every update you add the elapsed time since the last update, but (here it comes) if your currentFrame == 4 then you add only a fraction of it. This way it takes you longer to leave the time window of frame 4.
So store in some member of the AnimatedSprite that total time:
[code]double virtualTotalTimeInMsecs = 0;[/code]
And in the update method you can add:
[code]if (currentFrame == 4)
virtualTotalTimeInMsecs += gameTime.ElapsedGameTime.TotalMilliseconds * 0.25;
else virtualTotalTimeInMsecs += gameTime.ElapsedGameTime.TotalMilliseconds;[/code]
And change the previous code to this:
[code]int frame = ((int) virtualTotalTimeInMsecs ) / updateRateInMsecs;[/code]
This is rather a hack, though. However, if you want to change the animation speed you have to manipulate the time somehow.
Hope this helps!
[/quote]
Worked like a charm!!!
Thank you very much for your help.
Tom

[quote name='Tsus' timestamp='1324688651' post='4896968']
Hi!
[quote name='flashinpan' timestamp='1324660211' post='4896853']
I want to slow down the frame rate...it is really fast.
[/quote]
At the moment you update you animation [b]every[/b] frame. Usually you want animations to be played in a certain rate measured per milliseconds (to make them independent from the performance of your game, since this depends among other things on the hardware). You can get the total elapsed time since start of your application from the GameTime object that is a parameter of the Game’s update method. You can pass it to the update method of your AnimatedSprite and do something like this:
Store in some member of your Animator:
[code]
int lastFrame = -1;[/code]
And in your update:
[code]
int updateRateInMsecs = 500; // update each 500 ms
int frame = ((int)gameTime.TotalGameTime.TotalMilliseconds) / updateRateInMsecs; // compute the frame we are in.
if (frame != lastFrame) // are we in a new frame now?
{
currentFrame = frame % totalFrames; // compute the number of the frame to show.
}
lastFrame = frame; // memorize for the next pass.[/code]
[quote name='flashinpan' timestamp='1324660211' post='4896853']
I set the background color to "CornflowerBlue" so that the background of the cell would blend in with the background, but it ended-up adding a slight blue tint to the image as well. How can I prevent that?
[/quote]
The last argument of the draw call is the tint color (usually set to white). This color is multiplied with your texture when it is rendered. By this you can implement by very simple means different colors for teams or add some diversity to objects. It is not meant to define a transparent color.
If you want to remove the white borders you have to add an alpha channel to your textures (many image editing tools can do that). Then you have to enable alpha blending, by specifying the following arguments when drawing:
[code]spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);[/code]
Actually it would be better to use an Alpha Test for that, since it rejects pixels based on their alpha value if they are below or above some specified threshold. The test is much faster than blending, but in XNA 4.0 it was removed, because it is deprecated in modern DirectX. You’d have to do the test manually in a shader or use the built-in AlphaTestEffect. For starters, I’d recommend sticking with blending until you hit performance problems or feel ready to take the leap to shader development.
Hope this helps!
[/quote]
Okay....I think I have the delay down now. Thank you.
I am still struggling with the blue tint thing.
I tried adding those params as you suggested to the Begin method of the spriteBatch, but it did not seem to work right.
The .png is actually saved with a transparent background, not a white background. Does that make a difference in your advice?
Are you saying that if I had saved the png with a White background instead of a Transparent background this suggestion of yours would have worked???
I'll keep experimenting, but I am hoping for a reply from you.
Regardless...thanks for the help with the timing.
[[EDIT]] - [color="#FF0000"]UPDATE: Actually....the .png was NOT saved with a transparent background, it WAS saved with a White background. Once I saved it with a transparent background it began working and looking as it was intended....so that is sorted out now...thank you!!
This still remains a question though:
[/color]
Oh....one more thing on the timing.....I was wondering if there was a way to add more of a delay once the frame hits frame 4. The reason I ask is that on frame 4 the power "light" has hit the max intensity before it fades again and I want it to stay "fully lit" for longer than the other cells in the sequence. I just think it makes the power source "pulsing" look cooler. How can I do that?

[url="http://www.youtube.com/watch?v=N-VgBMzO25g&feature=mfu_in_order&list=UL"]xna chat and multiplayer[/url]
For clarity, the above link gives the essentials of what I am looking for.
So...yes it is possible....just looking for source code at this point.
Thank you for the posts and guidance so far! I really appreciate all the help!
Tom

[quote name='Hyunkel' timestamp='1324166454' post='4894903']
Unless you want to use LIVE, which I assume you are not since you aren't targeting the 360, networking will be identical to any other C# application, so you don't necessarily need to look at XNA examples.
Of the top of my head I can only think of Terraria, which uses XNA and has multiplayer support, but I'm sure there's quite a few more.
If you want to use UDP I can recommend "lidgren-network" [url="http://code.google.com/p/lidgren-network-gen3/"]http://code.google.c...n-network-gen3/[/url] which I have used with XNA before.
[/quote]
Yeah...I don't want to use LIVE (I take it that LIVE is only available for the xBox 360...PC games written with XNA can't use LIVE?).
I'll check-out Terraria, thx.
So, given that my choices are UDP / TCP-IP etc. --- are there wrappers or 3rd party components that can make the talking back and forth between two players easier?
For example...are there xna code snippets or tutorials that show how two xna games can talk to each other....both real time chat (so you can trash talk, etc.) as well as internal communications that the players do not see (like game board updates).
I am also interested in hosting a site where people who are available to play a game can see other players who are waiting to play and join a game.

Can we / are we allowed to embed movie clips in our posts?
Like if I wanted to share a short movie clip showing some sort of demo from my game?
How is this done? I know how to share a link to a movie on You Tube, but not how to embed the movie inside my post.
Thank you,
Tom

[quote name='Auskennfuchs' timestamp='1324317900' post='4895382']
How your current result looks like? Is the sprite flickering? After a quick look I would guess your Framecounter is way too fast. You go to next Spriteframe every Draw-Frame of your application. So if you have 60fps you rotate your Sprite 7,5 times. First try would be to make your currentFrame a float and add in Update just the elapsed Time. To calculate your Frame cast it to int. Then you can vary the speed of animation by dividing or multiply some value. And your animation is "time-safe"
[/quote]
Auskennfuchs:
Thank you for your reply. Here's an update on this problem:
The two lines of code commented-out at the top were the original lines (the cause of the problem) and the next 2 lines that follow (where width and height are hard-coded) are my fix.
[code]
public void Draw(SpriteBatch spriteBatch, Vector2 location)
{
//int width = Texture.Width / Rows;
//int height = Texture.Height / Columns;
int width = 31;
int height = 31;
int row = (int)((float)currentFrame / (float)Columns);
int column = currentFrame % Columns;
Rectangle sourceRectangle = new Rectangle(width * column, height * row, width, height);
Rectangle destinationRectangle = new Rectangle((int)location.X, (int)location.Y, width, height);
spriteBatch.Begin();
spriteBatch.Draw(Texture, destinationRectangle, sourceRectangle, Color.CornflowerBlue);
spriteBatch.End();
}
[/code]