Project to track on screen object - Unsure how to go about it - c#

I've started learning c# and vb.net and have a project related to tracking a moving object on the screen to help me learn some basics.
In essence, I will have a ball on the screen which moves from left to right (only horizontally), and when it reaches a certain point (e.g. 250 pixels from the "mid" point either side) I need to know this, and click an on-screen counter to increase a value (or decrease depending on left or right) and reset the ball to the centre (note that the ball speed will vary from incredible slow to an instant "jump").
I've been asked to look into c# and vb and decide which is best, then use it to create the program. As a complete newbie in both of these, does anyone have a recommendation and a starting point please?
My background is Javascript, HTML and very basic Java.
Thanks!

Not too sure what you define as a "Starting Point" do you mean like different C# libs to use etc. If all you are trying to do is move a ball from left to right basically and count the difference it would be so simple to do in C# XNA.
You can also do it in windows forms too which I really thing shouldn't be too hard at all. Obviously you would create the velocity formulas yourself I don't believe that's what you're asking.
One way to get the screen size in windows forms is:
public Rectangle GetScreen()
{
return Screen.FromControl(this).Bounds;
}
This will return a rectangle with a width and height that you can call, divide both values by 2 and it will give you the center of the screen. Then just add a method that is called every frame to check the balls value from the middle of the screen.
From what I've read I understand what you want to do, but I'm unsure if you just want a windows form or if you'd prefer to use a small game engine like XNA etc.
Either way best of luck and let me know :)

Related

Unity - healthbar as outlined line around the screen

I have a game in Unity.
The idea of the game is that an object is spawned on the screen.
It exists for several seconds.
You need to click on it, while it exists.
What I want to do, is that while it exists - I want to show a timer, but not with numbers, but with an outlined line on the perimeter of the screen.
I know, how to make a make a slider and how to make circular health bar, yet I do not really have an idea to make a slider, that is decresing from everywhere to the centre as you can see on the screenshots below.
I would be thankful for the inspiration!
This should be a very good fit using alpha cutoff with a custom shader.
Here's a video explaining it in detail (it's only the first half you will need).
The basic idea is to create a texture with a graded alpha depending on how you want the texture to appear/disappear. In this case the alpha value at the top and the bottom would be close to 0 and then gradually around the line on both sides towards the middle increase to 1. The shader then cuts off the texture below a cutoff threshold which you can change depending on the value of the timer.
As a dumb and simple approach:
Have two images with fill, one goes middle towards top the other middle towards bottom.
Just imagine the pnguin is your outline ^^

XNA 2D Transformation

I have actually the following map (isometric projection), and I can move/zoom/rotate without problem with matrix transformations (SpriteBatch): picture.
And I wanted to know if it was possible (if so, how), to get the following result, without referring to 3D: picture.
All suggestions are welcome. Thank you in advance. :)
Its going to be a huge pain in the ass, especially but I think it is at least possible if you don't change the viewing angle.
Some ideas:
Make each tile its own little image unit.
The more far back the tile is from the camera, lower its layer priority when you draw it so that it gets blocked by tiles in front of it. Also you will have to figure out an algorithm that correctly sizes the tiles based on their distance. This algorithm will have to be more and more precise the closer you want to get the tiles, but there should be some mathematical/geometric formula that can do it automatically.
You quite literally CANNOT rotate the camera at all, unless you want to have separate sprites for every single angle for every single tile.

compass shows me the north normally. but I want from it for showing another way (?)

I am making an app with c# for my windows phone 7.
I want to use compass for showing me the qibla direction (or which way I want).
how can I make it? I can calculate the degrees of qibla direction from my location with lang and latitute.(for example result is 150 degress east of north)
but then, I cannot draw the direction line for it.it shows north, not my way which I want.
so now I am using this code for drawing line:
magneticLine.X2 = magneticLine.X1 - (200 * Math.Sin(MathHelper.ToRadians((float)compassReading.MagneticHeading)));
magneticLine.Y2 = magneticLine.Y1 - (200 * Math.Cos(MathHelper.ToRadians((float)compassReading.MagneticHeading)));
can you help me about how I can make this. thanks.
The way you have it built currently you are merely using the center of the screen as the point of origin and then rendering a line that is always 200 pixels in length. You need to adjust/tamper with the degree reading prior to drawing your line (that's why it's not pointing in the correct direction for you).
Also, once you have something you think is correct, use the Windows Phone emulator to plot GPS points around Kaaba in Mecca (i.e. Make a circle of points around the Kaaba and then run a simulation). That will allow you to see if your solution will work for individuals in a 360* radius correctly.
Furthermore, this toolkit on Augmented Reality may help you as it does some of the math for you when calculating the direction based on your GPS location: http://gart.codeplex.com/
I hope this helps. If you are still stuck after the above reading, I can code it out for you so you have a better understanding.
Lastly, scope this out: http://www.jeffblankenburg.com/2011/11/04/31-days-of-mango-day-4-compass/
It's a tutorial on how to make a compass with working source code to download at the bottom of the article. Good luck!

How to simulate a card been played in a card game?

I am developing a card game using WPF and since i do not have any knowledge about animations i would like to know if someone could help me in how to write an animation to simulate a Card ( Image ) been played over a table.
At the bottom and top of my game table i have my cards on vertical position.
At the right and left my cards are on horizontal position.
What i really want is give an impression that a human is selecting and throwing the card.
Since your question is pretty open-ended, I'll give you an open-ended start...
Look into Storyboards, and how to use the same to modify the RenderTransform of your Card UserControl.
Your first step should really just be animating your card's position from its initial spot to the center of the table. As an additional hint (which will come in handy after you've learned about Storyboards), your DoubleAnimation.From property does not need to be specified. You just need to specify the DoubleAnimation.To property.
I see questions like this all the time on SO, and it really does give the impression of "I haven't tried, and I have not read anything". You already have your cards on the table (so to speak), and the question is, make it look like a human did it.
There are a variety of ways, some cheap and simple, some more complex and involved. You won't know the answer until you try.
For example, perhaps you want a card to go from one position to another (optionally flipping). You have varying degrees of difficulty here:
Move the card to the position, as is. Cheap and easy. You could even use the distance between the source and the target to determine the speed to have some kind of residual momentum.
Cards are at different angles. How do we rotate? XNA makes this pretty simple, have you looked up on XNA and general rendering? Or do you want to this purely using WPF?
Does the move involve showing the card face-up, or not? Will there be an animation involved? Are you happy with just the face changing or do you want to see an actual "flip"? If it's the latter than some kind of a plane in XNA using 3D might be better, at least then you can have two faces with two different textures.
What I am saying is, and why this is an answer as opposed to a comment, is that you have given no indication of anything that might be considered trying to solve the problem. You seem like you've got halfway there, you've already got cards rendered on the screen. But to ask "Make it look like a human put a card in"...? Well, sorry... it's not that simple. You can make this task as easy or had as you wish.

How do I implement a wave gesture in kinect?

I would like to use a gesture, so the kinect can select the person with the gesture as the main player. After this he can control the PC. Selecting the person and giving them control is done. Now i have to implement a gesture, but i dont know how to start.
Can anyone help me?
I guess that is what you want (if you like to recognize gestures by yourself):
MS explains how to recognize a wave gesture with a full code example here:
http://blogs.msdn.com/b/mcsuksoldev/archive/2011/08/08/writing-a-gesture-service-with-the-kinect-for-windows-sdk.aspx
By now there are also some gesture recognizer toolkits available.
See this for example:
http://kinecttoolbox.codeplex.com/
You can also surf on http://channel9.msdn.com for similar projects, like that one:
http://channel9.msdn.com/coding4fun/kinect/Gestures-and-Tools-for-Kinect-and-matching-Toolkit-too
Did you get as far that you have the skeleton?
The easiest is to check how many times the hand changed velocity direction
+x --> -X means it went left and is now coming back right, you can do a distance check between these points to determine if the wave gesture is obvious enough (omits very tiny waves/jitter)
Take some reference for hand have - say elbow - and store it into a variable and take some reference distance for the hand move such that whenever the hand moves on both sides beyond the reference distance on both sides, calculate the number of waves with the waves you require in your program. If both match select that person for your program

Categories