XNA Screen Management - c#

im using this example from the AppHub http://create.msdn.com/en-US/education/catalog/sample/game_state_management
Im using this example to create a menu system for my game. The game is already created and working without any sort of Menu's etc hence why i wish to use the game state management.
I have been looking at the example and it only really says to implement the game code into the GameplayScreen class. However I have problems with this as I cant then load certain game elements at this location for several reasons (One being that this class doesnt inherit the Microsoft.Xna.Framework.Game) So im a bit of a loss how i can load them somewhere else for example and get access to them still. My Game is made up of two pieces primarily, PongSystem Which controls most of the game and PongGame which holds most of the nitty gritty of the game.
If someone could help by explaining how i can implement my game into this example the easiest way that would be appreciated.
My game can be found here - http://min.us/mYZYMgzdC
Thanks for the help :)

If you don't mind a basic winform menu you can always create a menu in windows form and call your game with the Process class.
Process myProcess = new Process();
myProcess.StartInfo.FileName = //You .exe FilePath
myProcess.Start();
If you don't like this approach, someone posted a question like yours here and got a few links.
Good luck with your menu.

Using GameComponent objects you can load everything you need.( http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gamecomponent.aspx ) They are threaded and ideal for handling different sections of logic without cluttering your screens.
Create a main screen and add components to it, then create your main game class and it can refereence your comoponents.
Sorry If I am not explaining this very clearly.

From my past projects, I have found that these tutorials (1-7) are very helpful on using GSM,
first part - http://www.youtube.com/watch?v=-mw6kGYCllI
last part - http://www.youtube.com/watch?v=3fbCZMuPCe0
It will give you a nice base which you can build upon if you follow the tutorials.
Heres a screenshot the latest game menu/game i developed.
http://philipstarritt.com/wave/ironfist
Hope this helps

Related

Creating buttons (all controls Behaviour) in XNA

I am just a hobby programmer.. and even tough I know how, I don't want to mix windows forms and XNA for my level editor.
Has anyone done this before? Are there any examples around how to create "Windows like" controls for XNA, including events like mouse over, click and double-click and even accept keyboard input(if possible using language specific keyboard input)?
Below you find the basic layout of my editor but it needs so much more.
Yeah.
I'm now creating something like that.
See my project on Bitbucket.
I'm making own lib and voxel engine for Minecraft-like game. Just for fun.
So, in GameHelper lib you can fing folders Input (keyboard and mouse input) and GUI (forms and controls with events). I will be happy if it helps you, but there is almost no comment :P
Examples of use you can find in the Player class in main project (see ProcessInput method).
If you need I can give you better examples :)

How to create different "pages" in XNA?

(I think I heard this being called a "state-based" game, but I'm not sure...)
Basically what I want to do is have my start screen be one class, and then it passes on control (of the window/drawing/updating) to another class (ie the game class) and I can pass back control to the start screen class from the actual game class.
I want to switch logic control without opening a new window, and closing the original, but just seamlessly transfering to another class.
EDIT: I'm not looking for anyone to tell me exactly how to do this, just please nudge me in the right direction because I couldn't find it on Google...
There's a sample for that: XNA Game State Management sample.

How do I run Game1 on click of a button in another form

I'm a beginner programmer and I am trying to get a bit into c# and xna. I was hoping that instead of having the game run immediately (as usual), I wanted to have some sort of a register/login process, although I don't know how to run the game1.cs when the login button is clicked. In a few words, I would like some help with how I can run the:
using (Game1 game = new Game1())
{
game.Run();
}
on the login-button click in the login form.
Have you considered creating your login-screen using XNA itself instead of employing forms? This way you will be able to deploy your XNA game more easily on different platforms such as the XBox360 and Windows Phone.
A gamestate manager and a keyboard-handler class should help you get well underway and allow much more flexibility for background music, sound and video while logging in.
If you really want to though, there's this article that might help you out.

Beginner C# applications [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I just started learning C#, and I want to start making some small applications that are easy, but powerful.
Does anyone have any projects ideas? I'm interested to hear what you have in mind. Most of my experience is with HTML, CSS, JS, PHP.
Thanks
What do you like doing? I find games are always a cool place to start. If you like game-development you can do stuff like pong and pacman, but you can still have a lot of fun just making board and card games without much of the graphics complexity.
Here's some to get you started:
easier: tic-tac-toe, connect-4, go fish, black-jack, candyland, various solitaire games
medium: monopoly, poker, go, checkers, Yahtzee,
harder: scrabble, boggle, chess, Magic: The Gathering
here's different levels of difficulty:
design the logic. For example, make classes and methods to represent the board, properties, and the players in monopoly.
start making a gui. Make the game actually playable!
add AI and computer controlled players. Obviously AI is a huge subject, so there's many different ways you can go.
see here for a ton more projects on various topics
Since C# can be used in multiple types of applications, I'd try to do the same task in each. Perhaps a simple app that connects to a database and performs a lookup based on user input. Maybe connect to the "pubs" database that comes with the SQL Server samples.
You could do this as:
Winforms
ASP.NET WebForms
ASP.NET MVC
Dynamic Data
WPF
A Console app
using
Standard ADO.NET
LINQ
Entity Framework
You can even create a Windows Service that uses WCF, and a WinForms or ASP.NET front-end that consumes that service.
The idea is to get as many TYPES of apps under your belt as possible, so you can see how each is similar, and how each is the same. It will also help you get a better understanding of the "religious wars" over "which is best, Web Forms vs. MVC", etc. The ultimate answers to those "holy war" questions is invariably "what you're most comfortable with". There's nothing like having actual experience with the various options than to actually write something, so a nice, simple app in all of the available flavors would be a very good start.
And finally, since I listed so many things, here are some great starting points for everything I mentioned. There are videos, walk-throughs, etc to help you on your way.
http://www.asp.net/
http://windowsclient.net/default.aspx
http://msdn.microsoft.com/en-us/beginner/default.aspx
How about a scientific calculator? It'll give you basic experience with GUI building and event handling, it shouldn't be too hard to knock one up and most of your focus will be on the language rather than complicated algorithms (which is what you want when you're just starting to pick up a language.)
I've always heard that a simple game like checkers is good place to start. It lets you handle things like:
Separation of Model from UI (possibly
with a view model).
Skinning of controls or custom controls
and is easy to understand and test.
You can try to create something likes todo list. You can to provide a lot of custom feature for it (save/open data files, import to other formats, UI)
A good place to start is something like a calendar/todo application.
You won't beat all the great programs already out there that solve this problem, but you can start with a very simple but functional program, and add a feature a day for the rest of your life without running out of things you can do.
This gives a lot of opportunities for using different UI elements, doing some custom graphics rendering, serialisation/streams/io, database access, and even synchronising with web-based calendars, etc. i.e. It's easy to find a use for many different .net technologies within an application like this, but you don't need to use them: you can write a basic "useful" application in only a few minutes and keep adding to its facilities to learn new technologies.
Personally, something I'd like right now is a program that performs batch file management operations...
Sorting files into subfolders based on date or name patterns;
Renaming files based on user-defined patterns (e.g. add or remove a prefix from all filenames)
Renaming files based on metadata, if you can figure out how to read it (e.g. mp3 ID3 tags)
Then again, maybe this is too advanced. Or boring. I always find it fun to write a game that is a clone of an existing game, but add a twist. Like 3D tic-tac-toe... bad example maybe, but you get the idea.
Write a graphical dice roller simulator. It should be one window and when I press the "Roll Dice" button it simulates a roll of the dice, showing me an image of how my dice landed. And bonus points if it makes a nice dice roll sound. Extra bonus points if you let me choose how many dice to roll.
I expect to see this by tomorrow afternoon.
Good luck.
Maybe a little more advanced, but I enjoyed creating a little cheating program for playing the bejeweled blitz game. I followed Mike Vallotton's blog to get me started. it's here
Another good one would be to count the number of words in a text file.
Add a little more functionality to it by searching for keywords and returning how many of those were found in the text.
Start with writing a simple program using Form Application using a button and when clicked: Open a MessageBox saying Hello World. Then going over to new stuff like a webbrowser and then obtaining the source code from the site
3 basic steps in learning c# by webbrowser development:
1. create a basic browser that opens up a hardcoded site (site preprogrammed, not decided by user)
2. user controlled, textbox that the user can decide webpage with.
3.pulling out source code and changing every picture on a page for example. That will combine HTML and C# and since you have experience with HTML, changing the client side of the WebPage is good practice.
Good Luck :) Look up ThenewBoston on youtube, really great tutorials on C#
got a couple ideas:
you can make a pretty basic calculator [console application or windows form application]
you can make a dice (give random number between 1-6 or a random number between two numbers selected by the user.
a magic 8 ball, this uses the dice in the previous dot point, but instead uses the randomised integer and prints out the corresponding string.
you can make a planner application (an app that saves data such as todo list on a .txt file, etc).
you can also make a desktop assistant (i made one recently), that recognises voice and speaks to the user. It can also obey simple commands.
if you want to go deeper, you can try coding using C# to create unity games, i had some experience in this, it is very easy (got pretty good at it after reading some documentation and watching some tutorials).
but if you are just starting out, then i recommend you to work your way upwards and start off with making something simple.

How do Menu Screens/Screen Changes work in C# and XNA?

I'm working on a game in C# w/ XNA, and I want to make a main menu screen/title and options screens.
I'm not sure how to make them, or what's required to do so.
You might want to take a look at the Game State Management sample.
Also, I'd recommend reading this article for a detailed explanation of how the sample mentioned above works.

Categories