Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (20 posts)

RPG Programming Using XNA Questions

Last post 12/4/2009 3:51 PM by Dynamic Adventures Inc.. 19 replies.
  • 11/30/2009 4:16 PM

    RPG Programming Using XNA Questions

    Ok, from now on, this is where I am going to post questions to keep from cluttering the forums.

    1. Page 43, for the "private void SaveStats()", Where do I put this?
    I put this in the "Stat" class, but it shows many errors.

    private void SaveStats()  
            {  
                try 
                {  
                    XmlWriterSettings settings = new XmlWriter settings();  
                    settings.Indent = true;  
     
                    XmlWriter writer;  
     
                    foreach (Stat stat in _stats)  
                    {  
                        writer = XmlWriter.Create(Application.StartupPath +  
                            @"\Games\" + _gameName + @"\stats\" = stat.Name +  
                            ".xml", settings);  
                        IntermidiateSerializer.Serialize(writer, stat, null);  
     
                        writer.Close();  
                    }  
                    _saved = true;  
                }  
                catch (Exception e)  
                {  
                    MessageBox.Show(e.Message);  
                }  
            } 


    Errors:
    Line 5 - XmlWriterSettings - The type or namescpace name could not be found.
    Line 5 - XmlWriter - The type or namescpace name could not be found.
    Line 5 - settings(); - A new expression requires (), [], or {} after type.
    Line 8 - XmlWriter - The type or namescpace name could not be found.
    Line 10 - _stats - The name does not exist in the current context.
    Line 12 - XmlWriter - The name does not exist in the current context.
    Line 12 - Application - The name does not exist in the current context.
    Line 13 - _gameName - The name does not exist in the current context.
    Line 15 - IntermidiateSerializer - The name does not exist in the current context.
    Line 19 - _saved - The name does not exist in the current context.
    Line 23 - MessageBox - The name does not exist in the current context.

    Thanks,
  • 11/30/2009 4:48 PM In reply to

    Re: RPG Programming Using XNA Questions

    Make sure you are using System.Xml it should be at the top of the file with your other using statements.

  • 11/30/2009 5:19 PM In reply to

    Re: RPG Programming Using XNA Questions

    ok, I added it and it didn't work.
    I'll give you the whole source code:

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Text;  
    using System.Xml;  
     
    namespace RPG  
    {  
        public class Stat  
        {  
            private StatType _type;  
            private string _name;  
            private string _abbreviation;  
            private string _description;  
            private string _statCalculation;  
            private string _StartLevel;  
     
            private static readonly char[] _operators = { '+', '-', '/' };  
     
            public const short MaxStat = (short)DieType.d10;  
     
            public enum StatType  
            {  
                Regular,  
                Calculated  
            }  
     
            public Stat()  
            {  
     
            }  
     
            public Stat(string name)  
            {  
                _name = name;  
            }  
     
            public StatType Type  
            {  
                get { return _type; }  
                set { _type = value; }  
            }  
     
            public string Name  
            {  
                get { return _name; }  
                set { if (!string.IsNullOrEmpty(value)) _name = value; }  
            }  
     
            public string Abbreviation  
            {  
                get { return _abbreviation; }  
                set { if (!string.IsNullOrEmpty(value)) _abbreviation = value; }  
            }  
     
            public string Description  
            {  
                get { return _description; }  
                set { if (!string.IsNullOrEmpty(value)) _description = value; }  
            }  
     
            public string StatCalculation  
            {  
                get { return ConstructStatCalculation(); }  
                set 
                {  
                    if (_type == StatType.Calculated)  
                    {  
                        if (!string.IsNullOrEmpty(value))  
                        {  
                            _statCalculation = value;  
                        }  
                    }  
                    else 
                        _statCalculation = value;  
                }  
            }  
     
            public string StartLevel  
            {  
                get { return _StartLevel; }  
                set { if (!string.IsNullOrEmpty(value)) _StartLevel = value; }  
            }  
     
            public enum DieType  
            {  
                d4 = 4,  
                d6 = 6,  
                d8 = 8,  
                d10 = 10,  
                d12 = 12,  
                d20 = 20,  
                d99 = 99,  
                d999 = 999,  
                MaxDie = 99,  
                hpMaxDie= 999  
            }  
     
            private void SaveStats()  
            {  
                try 
                {  
                    XmlWriterSettings settings = new XmlWriter settings();  
                    settings.Indent = true;  
     
                    XmlWriter writer;  
     
                    foreach (Stat stat in _stats)  
                    {  
                        writer = XmlWriter.Create(Application.StartupPath +  
                            @"\Games\" + _gameName + @"\stats\" = stat.Name +  
                            ".xml", settings);  
                        IntermidiateSerializer.Serialize(writer, stat, null);  
     
                        writer.Close();  
                    }  
                    _saved = true;  
                }  
                catch (Exception e)  
                {  
                    MessageBox.Show(e.Message);  
                }  
            }  
        }  
    }  
     
  • 11/30/2009 6:27 PM In reply to

    Re: RPG Programming Using XNA Questions

    In general, you're going to have to be more specific than "it didn't work". You need to be specific about the error messages you receive.

    Anyway, change this line:

    XmlWriterSettings settings = new XmlWriter settings();

    into this line:

    XmlWriterSettings settings = new XmlWriterSettings();

    You might want to make sure you're comfortable programming in C# before you think about learning XNA Game Studio, though.
  • 11/30/2009 6:39 PM In reply to

    Re: RPG Programming Using XNA Questions

    You've also got a typo:

    IntermidiateSerializer.Serialize(writer, stat, null); 

    should be:

    IntermediateSerializer.Serialize(writer, stat, null); 

    "IntermidiateSerializer" not showing in the correct color in the IDE should have been a tip-off that something was wrong.
  • 11/30/2009 8:12 PM In reply to

    Re: RPG Programming Using XNA Questions

    In general, you're going to have to be more specific than "it didn't work". You need to be specific about the error messages you receive.

    Lol. sorry, its funny because i have the same error messages as before... :(

    Anyway, change this line:
    XmlWriterSettings settings = new XmlWriter settings();

    into this line:
    XmlWriterSettings settings = new XmlWriterSettings();

    Ok Thanks, it worked. but I have the others still, which would be:
    Line 10 - _stats - The name does not exist in the current context.
    Line 12 - XmlWriter - The name does not exist in the current context.
    Line 12 - Application - The name does not exist in the current context.
    Line 13 - _gameName - The name does not exist in the current context.
    Line 15 - IntermidiateSerializer - The name does not exist in the current context.
    Line 19 - _saved - The name does not exist in the current context.
    Line 23 - MessageBox - The name does not exist in the current context.

    Thanks Jim Perry.
  • 11/30/2009 9:15 PM In reply to

    Re: RPG Programming Using XNA Questions

    I strongly recommend that you take my advice above; learn C# before you learn XNA Game Studio. You're grasping at understanding some basic errors in your code. You have to learn to crawl before you can learn to walk.
  • 11/30/2009 9:50 PM In reply to

    Re: RPG Programming Using XNA Questions

    ok. Tonight I will to read Learning C# 3.0. Again.
  • 11/30/2009 10:40 PM In reply to

    Re: RPG Programming Using XNA Questions

    It takes more than reading a book to learn how to program. It takes months of dedicated practice and study.

    For now, try messing around making some text-based adventure games. You can still have some fun making games while you learn how to program, without having to deal with the headaches of learning the XNA Framework at the same time.
  • 12/1/2009 12:12 AM In reply to

    Re: RPG Programming Using XNA Questions

    Text-based RPGs suck. They are the most boring type of game there is. I am already making the sprites for my game, and I know how to do alot of stuff in xna. Besides, if i made a text based RPG, I would still need to know how to solve this problem I'm having trouble with. First off, do I need to have the RPG Start Kit to make this work?

    EDIT: and another thing, your website doesn't work for downloading the files...
    http://www.wordware.com/files/XNARPG
  • 12/1/2009 5:57 AM In reply to

    Re: RPG Programming Using XNA Questions

    Daniel Hanson:
    It takes more than reading a book to learn how to program. It takes months of dedicated practice and study.

    For now, try messing around making some text-based adventure games. You can still have some fun making games while you learn how to program, without having to deal with the headaches of learning the XNA Framework at the same time.

    Listen to him Aflak. Reading don't do much for you. I feel like an idiot, it took me a LONG time to learn C#, I made the same mistake as you, mess around with the Console Applications first. Reading from what you're saying, you need to be extremely comfortable with C#. Sprites are the last thing you worry about with a game. Let's use an example shall we, let's use a game cart, do you worry about working on the circuits, or the label first? The circuit is a lot more important than a label. Let's go back to programming, the mechanics make the game, not the graphics, but graphics can break a game.

    Also, if text-based RPG's are boring to you, you may have too short of an attention span. Believe me, programming requires a good attention span.
    Heck, for console apps, start very simplistic. Make it copy what you say.

    (I don't know XML well enough.)
  • 12/1/2009 2:14 PM In reply to

    Re: RPG Programming Using XNA Questions

    Aflakjuju:
    First off, do I need to have the RPG Start Kit to make this work?

    No. The problems you're having are the result of lack of basic understanding of coding. What kind of project are you trying to do? The first handful of chapters in the book are a Windows Forms Application, not an XNA Game project.

    Aflakjuju:
    EDIT: and another thing, your website doesn't work for downloading the files...
    http://www.wordware.com/files/XNARPG

    The companion files for the book can be found here. The site setup that the publisher that bought Wordware has sucks IMO.
  • 12/1/2009 6:43 PM In reply to

    Re: RPG Programming Using XNA Questions

    Ok. For some reason C# to me looks like all variables, ints etc. and repeating how to use them, add them, subtract them, etc.
    I just need a real teacher, not a book. I'm reading the book, "Learning C# 3.0". Well, I am only 12. I have awhile. I just feel like if i dont finish it in about 3 months, some will have already created a better rpg with half of my ideas. Does anyone have a good book for learning C# besides what I'm reading?
  • 12/1/2009 6:55 PM In reply to

    Re: RPG Programming Using XNA Questions

    You could start here. There's also this thread.
  • 12/1/2009 7:26 PM In reply to

    Re: RPG Programming Using XNA Questions

    You will learn to program only by programming, but starting off with a project of this scale is only going to get you frustrated. And to be honest with you, chances of finishing this without any prior expirience are quite low. RPG, even a simple one, requires you to do tons of design choices that are virtually impossible for beginner to make. So do something simple first, see how things work, and then start designing the big game that you really want to do. Or try to team up with people working on a project, contribute as you can and earn the invaluable expirience.

    Im not trying to get you depressed by saying these things, quite the contrary. As you said you are only 12 so you have all the time in the world to make your games.
  • 12/1/2009 7:36 PM In reply to

    Re: RPG Programming Using XNA Questions

    Ok, I agree. If I don't learn C# now, then I probably will never be able to program. For Some reason I wish I started when I was younger O_O.

    Thanks Jim Perry, I will start this tutorial soon.
  • 12/4/2009 4:22 AM In reply to

    Re: RPG Programming Using XNA Questions

    Aflakjuju:
    Ok, I agree. If I don't learn C# now, then I probably will never be able to program. For Some reason I wish I started when I was younger O_O.

    Thanks Jim Perry, I will start this tutorial soon.


    I know plenty of people older than you who wouldn't be able to program. I had read so many articles on C#, they didn't work, try looking at source code and it's comments. I was a little overwhelmed on how to use C#, then I had an "aha" moment. And I learned it. Have patience. I can not say this enough.
  • 12/4/2009 6:03 AM In reply to

    Re: RPG Programming Using XNA Questions

    I was two years older than you when I started and it still took me a while to work my way up. Trust me: start with something much smaller. I understand your reluctance to to text based RPG's [shudder], and I would have given up on games programming too if that had been where I started (I started with Flash Actionscript).

    If you're determined, try doing a Pong game. That will get you up and going with a working game much quicker, and you'll need to learn how to use classes for the ball and paddles.

    Then move up from there.
  • 12/4/2009 3:30 PM In reply to

    Re: RPG Programming Using XNA Questions

    I understand your reluctance to to text based RPG's [shudder], and I would have given up on games programming too if that had been where I started (I started with Flash Actionscript).

    Ok, the text-based RPG I have played was a truely boring one. You command a soldier(sorry if I misspelled it) and you tell him to attack, or get more reinforcements. Thats it. So if a text-based RPG is where it asks what buildings you want to go in, pick lock a chest, etc. then that sounds alot more fun.

    I have gotten to Lesson 6 - Namespaces in the tutorial Jim told me about. C# makes alot of sense now.
    I made a Console Application that gave the user a math problem to solve, then if he was correct it would tell him so.
    And it worked if he wasn't also. I know this may not sound much to you, but its a start.
    Doing what I told you up above, that was alot of fun :D.

    If you're determined, try doing a Pong game. That will get you up and going with a working game much quicker, and you'll need to learn how to use classes for the ball and paddles.

    That sounds like a good idea. Once I finish the C# Station tutorial, thats what I'll do.
    I was going to make an asteroid game, but I'll make that next.

    I've heard of something used for games called "vector.Reflect".
    If I wasn't just imagining it, that sounds like it could be useful.
  • 12/4/2009 3:51 PM In reply to

    Re: RPG Programming Using XNA Questions

    My first game was a text-based adventure game on a space station that had rpg elements for battles and such.  Keep at it, and you are on the right track with console based programs, doesn't matter what they do, so long as the run and you learn something. 
Page 1 of 1 (20 posts) Previous Discussion Next Discussion