Using animation in Picturebox [duplicate] - c#

This question already has answers here:
Can a PictureBox show animated GIF in Windows Application?
(3 answers)
Closed 9 years ago.
Im working in 2D space invaders game and i have done all the important part. Then, I decided to add some animation in the pictureBox to make my game look much better. My idea is to make the background picture as stars and i want to move this stars so it appears that my spaceship is actually moving.In different words, i want to make the background picture moving and repeat it again and again.
i feel there is easy way to make, can help me please with key points to overcome this issue.
thanks in advance

I think this has sort of been answered already in how to use an animated gif for a PictureBox, in this case you'd have your stars moving as part of a gif.
Link to Answer
Although I wouldn't be surprised if it's a better approach to use some other control altogether rather than a PictureBox, but if that's what you're looking to use then hopefully my answer leads you to a solution.

Related

C# WPF How to make Canvas.SetTop look like as if it were moving [duplicate]

This question already has answers here:
RenderTranform not render transforming
(1 answer)
WPF. Easiest way to move Image to (X,Y) programmatically?
(5 answers)
Closed 1 year ago.
How can I make my Canvas.Settop command look like the image is moving there instead of just teleporting to it? I wan't to make it look like its just moving there. This is what I currently have: Canvas.SetTop(MarioCharacter, 454);
And I've also tried this: WPF. Easiest way to move Image to (X,Y) programmatically? but this did not really end up working too great for me since it teleports the image to a random location and then just slides the image to its end point from there.
TL;DR: I need it so that the Canvas.Settop function looks like as if it would move the image to its end point.

How I can make a custom vertical slider in C#? [duplicate]

This question already has answers here:
Custom WPF Slider with image as Thumb
(2 answers)
Closed 7 years ago.
I'm learning C#, and I'm making a WPF Application.
The trouble is:
I have tried, but I don't know how to make a simple image object be a slider.
I have an idea to get values, calculating by the position of image object. I only need help to move the object image by the mouse.
Can you help me?
This is probably not the answer that you wanted, but it is the answer. You need to declare a custom ControlTemplate for the Slider control. This is no task for a new developer really, but there is some help at hand. First, I recommend that you read through the WPF Control Templates - An Overview page on MSDN for some background to this task.
Next, if you're not put off by that read, you can find the default ControlTemplate for the Slider in the Slider Styles and Templates page on MSDN. It's always best to start with the default ControlTemplate and to get that working before you make any changes to it. From there, you should just make small changes and run your project regularly to ensure that your changes are what you wanted. You'll get there in the end.

.NET | How to keep form on fullscreen game [duplicate]

This question already has answers here:
How to make a window always stay on top in .Net?
(14 answers)
Closed 8 years ago.
I googled some sites but can't find. I want to keep form on fullscreen game. I make gametool software and that feature is important. I need *VB.NET or C# example for this.
Thank you!
NOT: I saw that topic:How to make a window always stay on top in .Net?. Bu the answer not work on games.
You need to HOOK into the game so you can render with the game (this is a pretty huge topic), unless the game is windowed, in that case you can just force the form to be the top window (Like the link in one of your comments explains).
Beware that this is considered an hack by most anti-cheat software (as it should..).
Things such as Steam are whiteflagged.

Is displaying the tiles of a 2d game for an editor in seperate pictureboxes even a good idea? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
So I'm building a map editor for this little game called "Cataclysm". Coding aside (since that isn't really the problem), Is using a picturebox for each tile even a good idea?
Do you have any other ideas that make things a little easier on both me and my PC? (Using visual studio there is notable slowdowns when moving or handling all 144 pictureboxes for a 12x12 quadrant of a map file)
Another idea I had is just assembling the picture for a map and then stuffing it in a single picturebox, but how would I edit individual tiles this way? Put a raster over it and check which tile the mouse is on when you click?
Thanks for your suggestions!
Edit:
This is an editor - not an individual game!
No, I'd say you're best off not using individual picture box controls if you can help it. Each of those controls consumes resources and too many can slow down your application.
There is a per-process limit of 10,000 window handles. At this point, you're far from running into or over that limit. But what if you decide to make the map (significantly) larger in a later version of the game? Besides, it isn't good design to come anywhere close to the limit. There is also a system-wide limit of 32k, so the more handles consumed by one application (up to its 10k limit), the fewer that are available to other applications.
Just use the form's client area as a drawing surface (you don't need any picture boxes at all). Write code that divides it up into the appropriate segments, and then draw your images in each of those sections. Handle the form's MouseClick event, do a hit test to see where the user clicked, and match that up with one of your segments.
The 2D isometric games that I'm using makes use of a single picturebox. What I did was I took the mouse X and Y location and divided it by the height and width of the tile. Convert that number to an int (throwing away the decimal values). That should give you the exact tile. But you might need to play with the formula a bit if you don't use the mouse location on the picturebox itself. So on the mouse click event, you get tile that the user clicked on and just paint a new tile image at that location.
If you want to make games using C# why not use XNA? It's a very nice framework and you get lots of tutorials on it.
http://en.wikipedia.org/wiki/Microsoft_XNA
http://www.microsoft.com/en-za/download/details.aspx?id=23714
http://xnaresources.com/default.asp?page=TUTORIALS

How to resize animated gif file using C#? [duplicate]

This question already has answers here:
How to resize an animated gif image using C#?
(3 answers)
Closed 9 years ago.
Dear all,
I need to re-size an animated gif file on my provided size, using C#.How can i do that.I search the solution on the google but don't get any proper solution.I already see the atalasoft,codeproject,giflib on codeplex but non of this is proper solution.So, Please help me just re-size an animated gif file using c#.
thanks in advance
Riad
Actually, no quick-and-dirty method exists.
You will need to split the GIF into separate frames, then re-size each individual frame, then re-assemble the GIF image.
And sorry, I do not have the code to provide you, other than to refer you to Google
Atalasoft's DotImage should be fine, and they even have sample code on their site.

Categories