I'm trying to implement a simple game - I've written a dial control but having trouble writing a on-screen thumbstick in Silverlight for Windows Phone - this would be a large circle - say 150px wide with a 25px circle which when held down moves round the centre much like a real thumbstick - like the Xbox 360 controller thumbsticks.
I'm finding creating this a little tricky - if there are any examples such as a Joystick one I can shrink down for example? Been trying to create something for ages and can't seem to figure it out - the centre circle is loaded from an Image and the Larger one too so it can be customised - getting the two to be within each other centred is the easy part!
As discussed, i'd suggest using XNA doing it since its considerably easier to do. With Mango you could combine XNA and Silverlight and therefore satisfy your needs for some Silverlight too.
Look at this example:
http://create.msdn.com/en-US/sample/touchthumbsticks
It shows how to easily create a thumbstick control. To restrict the area which you can touch, just create a new Rectangle at the position of the thumbstick with the size you desire and use the .Contains(...) overload to check if the position of the tap is inside it and then act accordingly (update the stick, or ignore input).
Check out the .Contains(...) function and its overloads:
http://msdn.microsoft.com/de-de/library/microsoft.xna.framework.rectangle.contains.aspx
I have learned that many programmers tend to stick to Silverlight for they think XNA is some kind of holy grail and is complex to program. It is not. It just needs a bit of getting used to, but you will surely enjoy the ride to XNA enlightment. I can tell, i did :) It's fun! Just trust a stranger on the internet!
If you need to stick to Silverlight and Pre-Mango, i fear i can offer nothing of value for you, and i fear you will suffer pain in trying to recreate the same functionality XNA already offers programmers for no charge.
Related
I'm new to Unity and I'm making a car racing Game. Now, I'm stuck at some point. I was looking for some solution of my problem, but couldn't succeed.
My problem is:
When I run my game on my phone, it sticks badly because whenever there are several buildings in front of the car camera, like one building behind another building, it lags. Reason for this is there are so many vertices and edges at that time, So the Car Camera is unable to capture all that stuff at same time.
How do I preload the 2nd Scene while loading 1st Scene?
I am using Unity free version.
In graphics programming, there is a common routine to simply don't draw objects that aren't in the field of view. I'm sure Unity can handle this. Check link: Unity description on this topic
I'm not hugely knowledgeable about Unity, but as a 3D modeller there's a bunch of things you can do to improve performance:
Create a simplified version of your buildings with fewer polygons for use when buildings are a long way away. A skyscraper, for example, can be as simple as a textured box.
If you've done that already, reduce the distance at which the simpler imposters are substituted for the complex versions.
Reduce the number of polygons by other means. A good example is if you've got a window ledge sticking out of the side of a building, don't try and make it an extension of the body. Instead, make it a separate box, delete the facet that won't be seen, and move it to intersect with the rest of the building.
Another good trick is to use bump maps or normal maps to approximate smaller features, rather than trying to model everything.
Opaqueness. Try not to have transparent windows in your buildings. It's computationally cheaper to make them just reflect the skybox or a suitably blurred reflection imposter. Also make sure that the material's shader is in Opaque mode, if it supports this.
You might also benefit a little from checking the 'Static' box on the game object, assuming that buildings aren't able to be moved (i.e. by smashing through them in a bulldozer).
Collision detection can also be a big drain. Be sure to use the simplest possible detection mesh you can - either a box, cylinder, sphere or a combination.
I have a C# application that has an existing WinForm that I now need to display upside down.
The application will be displayed on a touchscreen Windows 7 device. If two people are using the device, one person is viewing it right-side-up while another user will be simultaneously viewing it upside-down. I will need to have one control displayed right-side-up while another control is displayed upside-down, each duplicate forms. Both need to be functional. It is not necessary for the title bar and Windows close, maximize, and minimize to be rotated.
Is there a way to easily rotate this Form and all of its contents without having to rewrite it from scratch?
Unfortunately, rotating controls is not directly possible in WinForms.
At least, not if you want them to retain their functionality. It would be relatively simple to draw the control into a bitmap, rotate the bitmap, and then draw that back to the desired location on the form. But you would obviously lose the ability to interact with the controls. They would just be static representatives of their original selves.
But making functional upside-down controls just isn't going to happen. I mean, you could try to write a bunch of custom drawing code for owner-drawn controls, but you'll still run into a bunch of bugs, corner cases, and compatibility problems. The Win32 controls that WinForms is based on just don't support this. No big surprise, really, considering they were invented some 20–25 years before anyone thought of computer screens that you could carry around in your pocket and rotate in any direction. There is a good reason that UI technologies like WPF came out around the time that touch screens and tablets did.
There are some possibilities that can be explored when it comes to flipping the entire screen, but that's not going to help when you want different controls going different directions. (And I guess it betrays my vantage point as a desktop app guy when I say this, but that just sounds like an incredibly confusing UI.)
If you absolutely have to have this, someone else is going to have to give you another route to hack it, perhaps along the lines of Dhawalk's comment: hosting the WinForms control inside of a WPF app that does provide built-in support for rotated controls. I don't know enough about this to make any concrete suggestions down that path. From a few minutes of searching, it appears that WindowsFormsHost does not actually support rotation transforms, so this may be a non-starter anyway.
I have never written any silverlight apps but I am looking to write a 3d viewer for earthquakes and have it run from my web site.
I would like to create a simple viewer so the user can change the "camera" ie their perspective. The view could contain up to 10,000 objects in the 3d space.
I want the ability to quickly view this - I have seen this on a Power Basic application and want to do this for the web.
I have a current web site at http://canterburyquakelive.co.nz for earthquakes in Canterbury New Zeaalnd and I want to learn the basics so that it can be more interactive.
I want to say for example (to start) place 2 objects in a "space" that I can define and move the camera in real time.
The system must support up to 10,000 objects in the end of the day.
Each object can be a simple circle - no need for special pixel shaders
I am unsure of the exact functionallity of the system at the moment so if I can find a tutorial that allows me to place someone (a circle) into a 3d world (space) and change the camera that would be good.
Any ideas appreciated - there seems to be so much about 3d and silverlight that I may be getting lost in the "gloss" of new features where I need some basics and I can learn and adapt over time.
** Added comment + image **
Basically I am waiting to create a page that look like this using Silverlight. But I am open to any technology.
I've never done 3D in silverlight so I can't exactly answer your question as asked but in general to display geographic markers in a 'real' 3D terrain is quite involved. At a minimum you're probably looking at:
Obtaining binary height data files (last time I looked, NASA gives this away)
Reading and interpreting said files to get 'bitmap' height data
Choosing and dealing with projections (e.g. UTM)
Deciding how to tesselate your bitmap height data
If you want it textured you'll need to also obtain satellite data for that, again converting or processing it to account for projection.
You could ignore the terrain height, but that may not simplify things depending on how 'bumpy' your terrain is.
For a pre-defined small enough area, you could perhaps pre-author a 3d model of the terrain in some 3D package but displaying your markers will still require a projection from long/lat into your 3D space, and you'll still need to know terrain height (unless you do mesh collision with the static model).
Rendering the markers is pretty straightforward by comparison, choose from:
Use a 3D model e.g. a 'pin head' (simple but not always visible)
Render a regular n-gon with 'viewer facing' polygons (resolution independent but maybe ugly)
Render a quad with a circle texture on it (low poly but what size texture to choose?)
There are probably libraries that do some or all of this for you, so if you are set on rolling your own then some of the things I've mentioned could form the basis for your search.
However, given what you've described of your site and situation I suspect you'd be better off avoiding all that work by using a pre-existing solution. E.g. the Google Earth API.
You could consider 3D web plugins that -granted- take you away from Silverlight but that might speed up your development process. I'm thinking in particular of e.g. the Blender 3D web plugin. I can understand the need to write your own viewer, but think twice before you re-invent the wheel. Good luck!
I think a lot of people used application "Fraps" for recording video from game. I use it for displaying FPS (frames per second) in the games. Fraps can show digits at the corner of screen when game runs.
I want to display core temperature of processor. The temperature I will find, but I need to khow, how can I display it in the game? (I need it for testing core temperatures in the game, because stress tests of Everest/AIDA64 doesn't much load the system).
Want to use C# (but can listen to all solutions, C++, Java)
Example games: Dirt2, Call of Duty 5 (DirectX)
P.S. This post was similar...
c# text/winForm overlay video games like xfire,PIX,steam,fraps etc
What you want to do is a bit more complex than you might think. There are different sources on the web about this, some might be a bit outdated. A good search Term is "Hook direct 3d", there are also other threads on stackoverflow about this topic. A good thread is also this.
One advice: You are changing the runtime code of the game, which can be detected by anti cheat mechanism and can cause banning if the game is a multiplayer game. It is even possible that widely known applications like fraps are on some sort of whitelist against these checks, but i'm not sure about that.
An alternative to what you want could be to make your form always stay on top (form.TopMost = true;). Then you can set the transparency color the same color as your form (by default it would be form.TransparencyKey = System.Drawing.SystemColors.Control;). After that you can remove the border of your form (form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;).
Be careful not to use the transparency color anywhere else (it'll make part of images transparent if it contains this color).
Make sure to have a way of closing the form. (and moving it if needed).
I want to write a simple game like pacman in C# in order to learn
the new language.
However, I don't know how to make a circle move?
Which part of knowledge in C# is needed?
You should check out XNA Game Studio from Microsoft. It's a version of Visual Studio that's targetted especially for writing games. You use C# but get a lot of things for free - graphics, sound, timing...
Here's a tutorial for making a ball move in XNA.
The simplest way would be to move your circle a small bit with every tick of a timer control.
If you want to learn a new language stay away from all fuss and just look into the most essential parts.
Having knowledge about previous programming languages helps a lot, espesially if one of those are Java.
You don't need to look into XNA for this, all you really do need is to Start Visual Studio, create a new Windows Form, drag over an PictureBox and start playing with the KeyEvents.
Your game does not have to be awesome for you to learn the very basics of C# and .NET. And you certainly don't need to dig down in the deep jungle of XNA!
Once you have your form up and running with a PictureBox or two and you have conqured the Event-system, take a look at the other fundamental parts of .NET that makes your life easier. Properties, Generics, Data Sources and much much more.
Well, for a simple single player game like that, some of the most important things you need to know about are data structures and GDI.
Data structures are important because you need to store information such as what does a map look like? Where are the walls? Can you go from one end to the other? How does the map draw itself?
GDI is used in C# to draw. This uses the Graphics context. You'll find lots of examples online, and I'd suggest checking out BobPowell.Net GDI+ FAQ to avoid some of the common mistakes.
You probably want to look into XNA - http://creators.xna.com/
Simply download the studio, install, then run Visual Studio C# (mine is Express Edition).
So when you run, you create a new Windows Game Project and you've created your first game.
Good to read up some books and articles on XNA.
Book: Microsoft XNA Game Studio 2.0: Learn Programming Now! by Rob Miles.
if you mean how to move an object around in a circular movement, then you just need math knowledge:
int circlePosX = centerX + Math.Cos(degrees) * radius;
int circlePosY = centerY + Math.Sin(degrees) * radius;
radius is here how big you want the circle to be, and degrees is the position ion the circle the object is moving.
Here's an answer to a question about a radar-type game that demonstrates generally how to do this in C#/WinForms using GDI+ (with a sample and source code):
What would be the best way to simulate Radar in C#?