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 7 years ago.
Improve this question
I searched everything on the internet but I cannot find a way to make a simple parallax background for my title screen.
In general, a way to show a horizontally repeating background that should work with any library capable of showing images:
image is a background image.
image2 is a second copy of the background.
On update:
// Move the background to the left.
image.x -= PerUpdateDeltaX;
// If the background is off the screen, move it back on.
// You can use modulo/remainder to do this better.
if (image.x < -image.width)
image.x = image.width;
// Put the second image to the right of the first.
image2.x = image.x + image.width;
To make this look good, the edges of the background image that touch need to be seamless.
Then, to make parallax (where there appear to me multiple layers moving in 3D), just add in a few more things:
Transparency.
More pairs of repeating background images, one pair for each layer of parallax.
Different PerUpdateDeltaX values for each layer. To look good, the higher/closer layers should move faster than lower layers.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Which form element can do the following:
- I press the button, the "additional" part of the form unfolds to the right.
Once I saw something like that, but I do not remember where.
I try to do it with "ToolStripPanel", but it does not work ...
"ToolStripPanel" makes the "red" panel expand to the "blue" territory.
It does not suit me.
What element of the form to use so that the “red” was of a constant size, and the “blue”
part was unwrapped and rolled up so that the form would increase and decrease?
image - link
According to your image, you could use a SplitContainer but what you see is a 2-step action. First, remove the panel 2, then resize panel 1 to take the newfound space.
Another option is to gradually decrease the size of panel 2, hence giving the illusion of "unfolding"
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 6 years ago.
Improve this question
I have used html5 camera capture attribute, when user try to capture image from the devices image gets rotated
Do we need to provide any setting on this?
Can we correct the image rotation using C#?
We are successfully using the following code to capture images and it works fine:
var canvas = document.getElementById("canvas")
var video = document.getElementById("video")
// Start video code omitted...
// Capture function
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext("2d").drawImage(video, 0, 0);
var imgData = canvas.toDataURL("image/jpeg")
The image should be fine unless there is some specific hardware configuration not allowing this.
And yes, it is possible to rotate the image using C#. Google it.
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
I want to resize and rotate image on my canvas . I implemented this for touch devices using gestures which works fine, but now i want to do this for pc so that it can be resized and rotate with mouse .I know that pointer events will be used but I dont know how to do this.
Need help?
You can use manipulation events for moving. For scaling and rotating you can use mouse scroll events (with PointerWheelChanged event) and modifiers like Ctrl, Alt (with Window.Current.CoreWindow.KeyDown/Up), but really there should be some control points that show up when you use a mouse:
this.PointerEntered += (s, e) =>
{
if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
{
this.isUsingMouse = true;
this.UpdateVisualState(true);
}
else
{
this.isUsingMouse = false;
this.UpdateVisualState(true);
}
};
UpdateVisualState would call in to VisualStateManager.GoToVisualState() and a visual state you define would display the manipulation adorners that you'd drag with mouse to resize/rotate.
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
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
Given an image with an undefined amount of rectangles that are separated by predefined lines with undefined coordinates (the lines in the image only represent the coordinates where the predefined lines should be).
Every rectangle should become a separate System.Drawing.Bitmap and put into an array of Bitmaps.
The rectangles will always be rectangle shaped and will all have the same dimensions (so if you can find one proper rectangle, you may assume that the rest of the rectangles are the same).
You may assume that all the lines in all images are a predefined fixed width (e.g. 5 pixels)
The grid will always be parallel & perpendicular to the sides of the image.
All lines will go from top to bottom, or side to side, even if it doesn't look like it in the image.
The amount of rectangles is undefined (not always 4x4 as in the images)
These images are meant to find the rectangles, which will then be cut from the original image. But if I can cut these images in the proper rectangles, I should be able to do the same for the original image.
I can imagine that this question is rather hard to understand; I've had a hard time trying to explain. All questions are more than welcome.
I'm not quite sure what your question really is, so I'm assuming you are searching for an algorithm to detect your rectangles.
From the images it looks like you can separate the border lines of the rectangles with some kind of binarization filter from the background texture in the image.
I would try a Hough transformation on your images to detect the rectangles and look for similar sized rectangles in the Hough space to narrow down the results. The Hough Transform can be easily implemented and is not very complicated. But I guess a bit of googling will get you a sample code as well.