Roulette Wheel C# - c#

I'd like to create a game with some kind of a Roulette Wheel with C#.
I have no relevant experience in GUI.
The first thing that comes to my mind when I want to develop such Roulette Wheel, is silver light but I prefer to implement it in a winform (unless you think otherwise).
If you can give me some ideas were to start...
1. How can I create the wheel
2. How can I make the ball go over it (don't want 3D grapics with bouncing and other fantastic ideas)
And please, as simple and basic as possible
Thanks
Asaf

Microsoft released a great framework for 2D and 3D game developemnt - XNA. You can easily add sounds and keyboard events to your game. There is also possibility to put your game onto a windows Forms. Here is a blog post about this by Roy Triesscheijn:
http://royalexander.wordpress.com/2008/10/09/xna-30-and-winforms-the-easy-way/
I've learned XNA 2D basics in one day so you shuld check it out.
Check out also this tutorial, it's really nice and for absolute beginner:
http://creators.xna.com/en-US/education/gettingstarted/bg2d/chapter1

Windows Forms has this amazing feature called nonrectangular forms wherein you can create "shaped" forms like polygons etc. Perhaps that can help you create the wheel.
http://msdn.microsoft.com/en-us/library/6k15y9et.aspx
Child controls placed on that form can act like the wedges on the wedges. Again, these "child controls" themselves could be nonrectangular forms.
I think it would be way easier if you opt for WPF for this instead of Winforms. WPF offers a wide range of controls and features that seem tailormade for such applications.

You can create a gif of a spinning wheel the slowly slows down. Then you can plot the known relative co-ordinates of each of the balls finishing positions.
For example 00 might be at the top when the animation has finished. In your page generate a random number (pseduo random is fine for a roulette wheel where no real money is being staked!), and have a ball gif. Use javascript to 'spin' the ball in the opposite direction of the wheel gif and slowly come to a stop the same time as the wheel animation, finishing at your plotted known co-ordinates.
Hope this gives you some ideas. There are several ways to do this!

Related

Any Silverlight-based Thumbstick controls out there?

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.

is there a way to make a 3D game in winforms or WPF in C#?

I'm thinking about making a 3D point and click game, is it possible to make one in winforms or WPF? I don't need any physics or anything all I need is to make the application render 3D objects. I know that I can use XNA but if I do then I will have to relearn almost everything again. My third approach would be to make the scenes in a 3D game engine and then print the screen and then load it as a image. Any suggestion would be appreciated.
There's a big difference between a 3D game, and just letting players interact with a rendered image.
Your approach of loading a pre-rendered image is possible to do in both Winforms and WPF. You would just need to capture click events on the image and check the location against your list of active areas. Then just handle what needed to be done, ie: move to the next area, activate item, etc.
Edit from comment:
It's not so much which is friendlier. You can host an XNA viewport in Winforms/WPF. It's more about how you want your game to work. If you never have moving 3D scenes, XNA is overkill, and images will work just fine.
If you want dynamic scenes, you'll need to be able to render them on the fly. Then, XNA makes more sense. It is a lot more work though compared to just displaying images.
If you just want to show pre-rendered 3d images in your game, why not create them using a real 3d graphics tool, such as 3D Studio Max or Maya (or a free one, such as Blender)? It sounds like there's no need for actually rendering the 3d scenes in a game engine at all.

What is best way to create scrolling WORLD?

In this game im trying to create, players are going to be able to go in all directions
I added one single image(1024x768 2d texture) as background, or terrain.
Now, when player moves around I want to display some stuff.
For example, lets say a lamp, when player moves enough, he will see lamp. if he goes back, lamp will disappear because it wont be anymore in screen
If Im unclear, think about mario. when you go further, coin-boxes will appear, if you go back they will disappear. but background will always stay same
I thought if I spawn ALL my sprites at screen, but in positions like 1599, 1422 it will be invisible because screen is only 1024x768, and when player moves, I will set place of that sprite to 1599-1,1422-1 and so. Is it a good way to do this ?
Are there better ways?
There are two ways you can achieve this result.
Keep player and camera stationary, move everything else.
Keep everything stationary except the player and the camera.
It sounds like you are trying to implement the first option. This is a fine solution, but it can become complicated quickly as the number of items grows. If you use a tile system, this can become much easier to manage. I recommend you look into using a tile engine of some sort. There are a lot of great tile map editors as well.
Some resources for using Tiles:
Tiled -- Nice Map Editor
TiledLib -- XNA Library for using Tiled Maps
What you're describing there is a Viewport, which describes a portion of the 'world' that is currently visible.
You need to define the contents of your 'world' somehow. This can be done with a data structure such as a scene graph, but for the simple 2D environment you're describing, you could probably store objects in an array. You would need to bind your direction keys to change the coordinates of the viewport (and your character if you want them to stay centered).
It's a good idea to only draw objects that are currently visible. Without knowing which languages or packages you are using it's difficult to comment on that.
I would look into Parallax scrolling. Here is an example of it in action.
If this is what you require, then here is a tutorial with source code.
XNA Parallax Scrolling
After you are finished with basic scrolling, try to implement some frustum culling. That is only draw objects which are actually visible on the screen and avoid unnecessary drawing of stuff that cannot be seen anyway.
I would prefer solution number 2 (move player and camera) - It would be easier for me, but maybe its just personal preference.

XNA 2d arcade game sprite follow

I am going to make a game like XNA example game "Platformer1" which comes with the XNA. But I need longer levels which doesn't fit in the screen (like Super Mario levels). How can I manage this kind of level? Do I need to use a 2d camera that follows the sprite? If I do this way how can I load the level? I am a bit confused and I am not sure if I could explain my problem clearly. Hope someone can help?
The tutorial based on Platformer Starter Kit in MSDN has a step Adding a Scrolling Level which guides you through creation of longer levels. The tutorial is very detailed, I highly recommend it.
I couldn't find the tutorial in the section for XNA Game Studio 4.0, but differences should be minimal. According to the comment at the bottom of the page, all you need to change is replace
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, cameraTransform);
with
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, cameraTransform);
in the tutorial code.
If you want to create a side scrolling game, then I would look into parallax scrolling. A quick google/bing will help you find lots of tutorials. Also, another useful tip is to search YouTube for XNA videos has we a lot of posters share their source code .
Here is a link to Microsofts Parallax Scrolling.
Sounds like you have a few problems ahead of you.
But I need longer levels which doest'n fit in the screen(like super mario levels). How can I manage this kind of levels.
There are several ways to do this, but a fairly easy way would be to have a 2d array (or sparse array, depending on how large your levels are) of a class named Tile that stores info about the tile image, animation, ...whatever.
Yes, you'll probably want a "camera". This can be as simple as only drawing a certain range of that array or a more featured camera that uses transforms to zoom out and translate across your level.
Hopefully this will help get you started.
I've done a decent amount of work in XNA, and from my experience, there are 2 ways to draw a 2D scene:
1) Strictly 2D. This method is much easier, but has a few limitations. There is no "camera" per se, what you do is move everything underneath the fixed 2D "camera". I say "camera" in quotes because the camera is fixed (as far as I know). The upside is that it's easy, the downside is that you can't easily zoom in or out or do other camera effects.
2) 2D in 3D. Set up a 3D world with a 2D plane. This is more flexible, but is also more challenging to work with because you will need to set up a 3D world and 3D camera. If this is your first attempt with making a game, I would highly recommend against this method.
I'm really only familiar with the strictly 2D method, and you would want a list of map objects that have a 2D coordinate. You would also want to store which section of the map you are looking at, I do this with a Rectangle or Vector2 that stores this. This value would move forward as the character moves. You can then take your 2D map objects' coordinate and subtract the (X,Y) of the top-left of what you are looking at to determine an object's screen position. So:
float screenX = myMapObject.X - focusPoint.X;
float screenY = myMapObject.Y - focusPoint.Y;
An other thing to note, use floats or Vector2/3 to store locations, you may not think it's required now, but it will be down the line.
It might be overkill, but my SF project uses XNA to draw a Strictly 2D scene that you can move around: http://sourceforge.net/projects/asteroidoutpost/
I hope this helps.
Have a look at Nick Gravelyns tutorials. They helped me tonne when I was first starting out - Really really worth a look for learning a lot on 2D games.
All the videos are now on youtube here

Spinning a 3D model in C#

How do I take a 3D model that I created in 3D Studio Max and put it into my Winform C# program and make it spin? I'd prefer not to use DirectX if possible. I don't want anything complex. I simply want my model to rotate along the X axis. Thats it.
Thanks
You should use a 3D rendering engine for C#
Something like
http://axiom3d.net/wiki/index.php/Main_Page
http://www.codeproject.com/KB/GDI-plus/exoengine.aspx
http://irrlicht.sourceforge.net/features.html
http://freegamedev.net/wiki/Free,_cross-platform,_real-time_3D_engines
I have never used any rendering engines but for your requirements (letting the user move the object) i think a 3D engine would do. But perhaps this is over kill
If you want it to be dynamic, then the simplest option would be to render out an animation of the object rotating, but make each frame a separate file. Then you just show the correct image based on how the user is dragging the mouse. If the user drags the mouse to the right, then increment the frame and show the next image. If moving to the left, decrement the frame.
For something non interactive:
Export the animation to an AVI and embed that in your form:
Embedding Video in a WinForms app
It's not really what I'd recommend, but it's an alternative to creating an animated gif.
For something partially interactive (i.e. allowing limited movement):
I've seen QuickTime movies that you can control with the mouse. There's an example on this page. It's not 3D though.
For something fully interactive:
You need a 3D rendering engine of some sort and that does (usually) require DirectX or OpenGL. However, if you're only dealing with simple objects you might (repeat might) get away with a software renderer.

Categories

Resources