• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
  • entries
    14
  • comments
    28
  • views
    25456

XNA 4.0 Scripting

Sign in to follow this  
Followers 0
XXChester

3301 views

[size="3"][font="Calibri"]

[size="3"][font="Calibri"][heading]XNA 4.0 Scripting[/heading][/font]


[subheading]Objectives of this journal:[/subheading][/font]
[font="Calibri"][size="3"]
[/font][font="Calibri"][size="3"][font="Calibri"][size="3"][font="Calibri"][size="3"][font="Calibri"][size="3"][font="Calibri"][size="3"][font="Calibri"][size="3"][font="Calibri"][size="3"][font="Calibri"][size="3"][/font][/font][/font][/font]
-Give you a starting point for command based scripting for your XNA game.
[/font][font="Calibri"][size="3"]-Receive feedback on the whole thing and especially alternatives to my ObjectTranslator, because it is extremely sloppy and I do not like it. It feels like a complete hack.[/font][/font][/font][font="Calibri"][size="3"]

[/font][/font][size="3"][font="Calibri"][subheading]Notes:[/subheading]
[/font][font="Calibri"][size="3"][font="Calibri"][size="3"][/font]
-I am in no way claiming this is the best way to do any of this, matter of fact I am positive the way my ObjectTranslator works is garbage, I encourage you to download the example solution and provide your feedback. I am simply stating it is possible and providing a rough example.
[/font][font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]This is a quick and dirty starting point written in a couple hours; its purpose is to give you a starting point that you can either take and write your own or build on to.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]This is a very BASIC implementation, meaning it is very limited such as it does not handle chained together method calls etc. I needed something with the ability to move elements around at runtime for design purposes and that is what this achieves. [/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]You can download a sample solution at the end of the article to see it in action.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]The sample you have to manually close the scripting window because I did not look into tying the rest of the tear down method to timeout the Console.ReadLine().[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]There is also a video included to show it in action[/font]
[font="Calibri"][size="3"]
[font="Calibri"][size="3"][/font]
[font="Calibri"][size="3"][/font]
[subheading]Back history:[/subheading][/font]
[font="Calibri"][size="3"][font="Calibri"][size="3"][/font]
A couple months ago I was just starting to fall into the rabbit hole in which they call scripting. Then I made the change to the XNA framework, and to my great disappointment after hours upon hours of searching, there was no scripting solution available for XNA. Even more so to my disappointment everyone was stating it was not possible, nor feasible sense you have to redeploy to the Xbox anytime you make a change anyway. This is true. Let me reiterate this thought, you CANNOT use this on your Xbox, however no one (that I could find) was talking about using scripting and more specifically command based scripting to make designing your game easier and faster. By this I mean the ability to access and alter objects on the fly so that you can quickly position them etc without having to stop, change, compile, and run all over again.[/font]
[size="3"][font="Calibri"]

[subheading]Quick, what is command based scripting:[/subheading][/font]
[font="Calibri"][size="3"][font="Calibri"][size="3"][/font]
Command based scripting is essentially what it sounds like. You type in a command and it is parsed and executed. Basically it runs beside your main application (or inside it if you write it to be so) and it has access to methods and data within the program and is able to manipulates it. [/font]
[size="3"][font="Calibri"]
[subheading]Technique:[/subheading]
[/font][font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]Have a system of receiving input running either externally or internally, in its own thread.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]Take the commands input to said system and send them to a parser.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]The parser determines if we are running a high level command such as getValue or help or a command against a registered object.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]If the command is high level, it simply executes[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]If the command is against a registered object, we first have to find our registered object via the reference name specified on creation.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]Once we find the object, we pass the registered object the input and it is parsed again to determine if it is a method or property.[/font][size="3"]
[font="Calibri"][size="3"][font="Arial"]-[/font]Then it is further parsed to determine if parameters were specified such as: test.Position = Vector2(10,10)[/font][font="Calibri"][size="3"]
-[/font][font="Calibri"][size="3"]Once a command and its parameters (if any) are found, the command is executed.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]Now you need to design error handling so that if you put in an invalid command it will not crash your game (defeats the purpose of on the fly changes) and it will provide useful feedback as to WHY the command was invalid.[/font]
[font="Calibri"][size="3"]-[/font][font="Calibri"][size="3"]Now that you have your scripting system in place, just wrap everything about scripting in like the below example to ensure it only runs on WINDOWS and in DEBUG mode;[/font][font="Calibri"][size="3"]

protected override void LoadContent() {

// Create a new SpriteBatch, which can be used to draw textures.

spriteBatch = new SpriteBatch(GraphicsDevice);

this.spriteFont = Content.Load("SpriteFont1");

this.text = new Test("Foo bar", new Vector2(100f,100f));

#if WINDOWS

#if DEBUG

// register objects

ScriptManager.getInstance().registerObject(this.text, "text");

Thread consoleInputThread =

new Thread(new ThreadStart(listenForInput));

consoleInputThread.Start();

this.running = true;

#endif

#endif

}



#if WINDOWS

#if DEBUG

private void listenForInput() {

string input;

do {

Console.Write(">>");

input = Console.ReadLine();

ScriptManager.getInstance().handleInput(input);

} while (running);

}

#endif

#endif



[size="3"][font="Calibri"][subheading]Programmers speak:[/subheading][/font]
[font="Calibri"][size="3"][font="Calibri"][size="3"][/font]
The way I achieved all of the above technique is with some basic string manipulation and via the magic of Reflection (System.Reflection).[/font]
[font="Calibri"][size="3"]
[subheading]Video:[/subheading][/font]
[color="#800080"]

[/color]
[media]
[/media]
[font="Calibri"][size="3"]

[subheading]Example program download (Written in Visual Studio Express 2010 with Game Studio 4):[/subheading][/font]
Due to permission problems I am unable to attach a rar/zip file to the blog entry so unfortunately I have to use RapdiShare\MediaFire to host the solution for now until I can get in touch with admins to get this resolved.
Example


Thank you for reading my blog entry on XNA 4.0 Scripting and I hope you found it interesting, helpful and most importantly; understandable.
Thanks, XXChester



**EDIT** Fixed the link and changed to mediafire because not only did my link become broken, rapdishare actually deleted my file as well. I am still working with admins to figure out why I cannot just attach the source here to avoid the third party software. Also please note that I deleted the old .rar I had saved off my desktop so this one is a bit different because it has some enhancements (such as automatic closing of the window on destruction) and the start of some rework(should all be commented out). This example should however still work. I also embedded the YouTube video.

Thanks again.

[/font]

0
Sign in to follow this  
Followers 0


7 Comments


who'd you contact for the upload issue? If no one yet I can take a look at it before we bump it up to Mike
0

Share this comment


Link to comment
I reported it via feedback...I wasn't sure how else to get ahold of an admin. The report ID is listed below;

[b]Report ID #1273:[/b]
Thank you for taking the time to read my blog and looking into this issue.
0

Share this comment


Link to comment
The rapidshare link isn't working. It's showing up in my browser as the version with the ellipsis (...) in it.
0

Share this comment


Link to comment
Thank you for the information Dementia, I will re-upload it tonight when I get home from work (as I don't have the files here). Hopefully Gaiiden can figure out my permission's issue soon so I don't have to rely on RapidShare.
0

Share this comment


Link to comment
Link should be fixed, sorry again about that. Please read the **EDIT** blurb as there are some small changes.
0

Share this comment


Link to comment
This past weekend I have implemented a generic object translator which is working like a charm and a much better approach to object translation. I will write a new article (and reference this one) soon to show how to do generic object translations.
0

Share this comment


Link to comment
Here is the much overdue journal entry about my [url="http://www.gamedev.net/blog/908/entry-2250559-generic-object-translator/"]Generic Object Translator[/url] hope you enjoy it.

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now