C# Wpf Animation Projectile - c#

I just started using WPF and searched on how to do animations, there is many good tutorials but i can't seem to find the specific thing i need.
My goal is to create a small circle to start at a location and when a timer ticks move the circle smoothly towards another point(within 1 second). There is going to be new starting points and target points each tick.
As i said im fairly new to WPF so XAML is a new area for me, so i don't know how to animate the movement or if i should draw the circle or use an image. I don't even know if this is hard or an easy thing to do.
For reference im trying to make it look like the projectiles in this link:
http://map.norsecorp.com/#/
Would appreciate any help or any google search words i should use.
/ Alexander

If you are trying to work with animations, WPF isn't the right tool for you.
I have done many projects in this direction in the past and i cant recommend WPF. You need to work with multiple threads and your code is getting messy very soon. WPF is optimized for buisness solutions not for drawing circles. You can use Unity 3D. Its easy to learn and there are many examples out there.

Related

Gridless Pathfinding - Unity3D

I was wondering what best approach to take when trying to implement pathfinding but without using a grid.
In this example, the player is a able to place road tiles on a grid, but I only want to pathfind the placed roads (no need to compute for the whole map).
I've tried a couple things but with no luck.
Any help would be appreciated.
Thanks in advance.
I think you are looking for A* algorithm. There are also other ways to do this, but most of them are based on graphs, including Unity NavMesh.
There is amazing site with interactive examples and implementation guide, for sure it will be helpful, whether you want to implement this yourself or just understand how it works:
https://www.redblobgames.com/pathfinding/a-star/introduction.html

Animation Controller/Scripting in Unity

I am working on a 2.5D side scroller/platformer project just kind of as a learning experience. I imported a robot model that came with premade animations. I have 2 questions regarding setting him up for movement and his animations. First, I set up movement for x and y, but do I only need to do x? Right now if I hit the UP arrow, the character appears to jump, but feel like that is probably bad form. Am I correct in assuming I should do just the x value for movement and create a separate method for jumping? My second question is with the animation controller. I set up all my states and set my transitions, but I'm not sure what to do from there. What do I do to actually set up the transitions, if anything, and also I could use some information on setting up the animations on the programming side. I have some very slight general knowledge of it, but not much and I'm having trouble finding good solid tutorials for these specific questions.
Thanks for the help!
Yes, I would recommend doing separate controllers and script files for side to side moving and jumping. That way if you ever need to change one of those behaviours you have a specialized place to do it. Also, perhaps you have an enemy that moves side to side but doesn't jump. Or perhaps something that jumps but doesn't move. You could just drag the correct behaviour onto the game object.
as for animations, the unity learn tutorials are pretty helpful getting you started on animations and very basic state transitions

C# Sidescroller starting advices

since this is my very first time trying to make yet simple but useable sidescroller I'd like to ask some questions and hopefully gather ideas to make a good engine that can change the position of an Image in the form depending on X position of the drawn game character. I'd basically like to recreate just few seconds of a Mario game.
The starting Idea (correct me if it's wrong / poorly performance / whatever) would be to create a picture long in width and whit fixed height and upon the press of, for example, A or D keys, the drawn character moves till a certain X point, after that, character gets locked in place and if the key is still pressed, the background image starts moving.
But the problem there would be the fix for collisions, would be possible to check for the X position of the drawn background picture and set "collisions" accordingly for the character?
Other questions : why picturebox should be avoided at all costs and use the form itself instead ? Placing the greater part of the classes methods inside a timer_tick event is the wrong approach ? I read somewhere that the best way to do games of this kind would be relying on infinite loops in the forms main method, but I simply cannot even think how this could possibly works, taking in count all the times we may need to get out of the loop and do different code in different places.
Any other different ideas/approach and direct links to further explanations would be greatly liked
Edit : yes i'd like to improve with windows forms before moving to xna/unity
Assumption: You want to make a little game and its your first time working with moving graphics and you're working with WindowsForms. Suggestion: try using a more advanced framework such as MonoGame or XNA and working your way through introductory documentation and tutorials. Also WPF has a more advanced graphics platform for doing things like drawing and 3D, you may want to give that a shot.
To expand on my comment a bit.
Windows Forms and GDI (the tech behind drawing) aren't meant for this kind of use. When GDI was created its purpose was essentially drawing lines and fonts on the screen. XNA is a really good framework for learning the basics up to professional design. Unfortunately the XNA framework is no longer supported by Microsoft and as such MonoGame is the recommended development route for managed .NET 3D and 2D game development.
The WPF provides basic access to Direct3D and Direct2D, and has 2D and 3D shapes and animations built into the framework and is what WPF is based on.
But you also have the choice, if need be, to create an XNA component and embed it in a Windows Form as demonstrated in these two tutorials.
XNA in Windows Forms I
XNA in Windows Forms II
Also using a Windows Forms Timer isn't recommended because they are unreliable. The .Net Framework provides a 'Server Timer' and a 'Threading timer' that can be used as well.
If you are really keen on using GDI for a game may I recommend reading about the basics of game programming (I think there are a few XNA docs on the subject) that should guide you on things like the basic run time loop, getting input, and simple physics.

Building a robot simulator GUI using C#. Need some advice

I'm building a 2D robot simulator GUI for my autonomous robot vehicle.
I plan to keep the GUI simple. It consists of a vehicle (represented by a blue square picture), and some obstacles (cones, wall, etc, represented by yellow circle and red line respectively).
The vehicle must be able to move (as in the blue square must be able to move on the GUI) and be able to show its velocity and steering (float values) and its status (string) on the GUI.
I plan to use C# and Windows Forms to do this task, but I'm not sure if this is the right way to it. I remember using picture box a few years ago and I was not able to change the position of the picture box in real-time, or something weird like that.
Just wondering if you guys know a better way to do this. Is Windows Forms the way to go?
I've just moved from Ubuntu to Windows, so I am quite new at .Net stuff.
Here's what I've got so far http://imageshack.us/photo/my-images/708/guilo.png/
Future plans may dictate a change, but for what you describe Windows.Drawing should work fine. The only problem may be if you are using timers for updates, as it may not be fast enough for you.
So, how fast of an update rate do you need?
How much like a game framework will you actually need?
You may want to look at a tutorial like:
http://www.dreamincode.net/forums/topic/67275-the-wonders-of-systemdrawinggraphics/

Using GIFs with XNA

I was looking for a way to use GIFs within XNA when I found this: http://xnagif.codeplex.com/
Can anyone tell me the proper steps in adding and linking this library to my project? I couldn't get it to work when I tried it, and I feel as though I might deleted/overwrite a necessary component to my project.
As I said, spritesheet animation is much easier with spritesheet than gifs and gives you much more flexibility, like storing multiple animations in the same image file.
This nice tutorial will help you get started on spritesheet animation in XNA. It shouldn't take long for you to develop a working animation library with this.
In short, XNA already has a parameter in its Draw method that allows you to draw only a small part of the full image (parameter: source). Using this, you can change the source every X second to make it look like an animated gif. I assure you that it really isn't too complicated and shouldn't be too long to implement (as I have done it myself several times already, always improving my animation engine)

Categories