Games Development 2 Text-based Game Data

Slides:



Advertisements
Similar presentations
DOCUMENT TYPES. Digital Documents Converting documents to an electronic format will preserve those documents, but how would such a process be organized?
Advertisements

XML & Data Structures for the Internet Yingcai Xiao.
Basics of HTML What is HTML?  HTML or Hyper Text Markup Language is the standard markup language used to create Web pages.  HTML is.
1 Introducing Collaboration to Single User Applications A Survey and Analysis of Recent Work by Brian Cornell For Collaborative Systems Fall 2006.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Tutorial 1 Developing a Basic Web Page
XML Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
Chapter 1 Understanding the Web Design Environment
COS 381 Day 16. Agenda Assignment 4 posted Due April 1 There was no resubmits of Assignment Capstone Progress report Due March 24 Today we will discuss.
4.01B Authoring Languages and Web Authoring Software 4.01 Examine webpage development and design.
Efficient XML Interchange. XML Why is XML good? A widely accepted standard for data representation Fairly simple format Flexible It’s not used by everyone,
Exploring Microsoft® Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Robert Grauer and Maryann Barber Using.
MC 365 – Software Engineering Presented by: John Ristuccia Shawn Posts Ndi Sampson XSLT Introduction BCi.
Technical Track Session XML Techie Tools Tim Bornholt.
Web Design Basic Concepts.
Chapter 1 Variables in the Web Design Environment.
Chapter 1 Variables in the Web Design Environment
Games Development 2 Entity / Architecture Review CO3301 Week
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Languages in WEB Presented by: Jenisha Kshatriya BCM SS09.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Zhonghua Qu and Ovidiu Daescu December 24, 2009 University of Texas at Dallas.
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
XML and its applications: 4. Processing XML using PHP.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Chapter 1 Understanding the Web Design Environment Principles of Web Design, 4 th Edition.
Week 1 Understanding the Web Design Environment. 1-2 HTML: Then and Now HTML is an application of the Standard Generalized Markup Language Intended to.
Games Development 2 Text-based Game Data CO3301 Week 4.
Intro to XML Originally Presented by Clifford Lemoine Modified by Box.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Scripting with the DOM Ellen Pearlman Eileen Mullin Programming the Web.
XML Basics A brief introduction to XML in general 1XML Basics.
XML Steve Fisher/RAL. 20 October 2000XML - Steve Fisher/RAL2 Warning Information may not be all completely up to date.
XML and Its Applications Ben Y. Zhao, CS294-7 Spring 1999.
XSLT. XSLT stands for Extensible Stylesheet Language Transformations XSLT is used to transform XML documents into other kinds of documents. XSLT can produce.
Representing data with XML SE-2030 Dr. Mark L. Hornick 1.
©Silberschatz, Korth and Sudarshan10.1Database System Concepts W3C - The World Wide Web Consortium W3C - The World Wide Web Consortium.
Martin Kruliš by Martin Kruliš (v1.1)1.
VCE IT Theory Slideshows by Mark Kelly study design By Mark Kelly, vceit.com, Begin.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Chapter 13 A & B Programming Languages and the.
1 Programming and problem solving in C, Maxima, and Excel.
Lecture Transforming Data: Using Apache Xalan to apply XSLT transformations Marc Dumontier Blueprint Initiative Samuel Lunenfeld Research Institute.
Slice & dice the Web with XmlPL, The XML Processing Language A presentation for Boise Code Camp 2007 Joseph Coffland Cauldron Development LLC.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
Features of Authoring Tools
The Object-Oriented Thought Process Chapter 11
4.01B Authoring Languages and Web Authoring Software
Chapter 1 Introduction to HTML.
SOFTWARE DESIGN AND ARCHITECTURE
Intro to XML.
Software as Data Structure
Haritha Dasari Josue Balandrano Coronel -
XML in Web Technologies
CHAPTER 8 Multimedia Authoring Tools
Microsoft Office Illustrated
Compiler Construction
4.01B Authoring Languages and Web Authoring Software
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
XML Data Introduction, Well-formed XML.
Lecture 1: Multi-tier Architecture Overview
Fundamentals of Data Structures
Code Generation Tips Tricks Pitfalls 5/4/2019 A.Symons CiTR Pty Ltd.
Python and XML Styling and other issues XML
XML and its applications: 4. Processing XML using PHP
Games Development 2 Tools Programming
Windows Forms in Visual Studio 2005: An in-depth look at key features
Games Development 2 Entity / Architecture Review
XML and Web Services (II/2546)
Unit 6 - XML Transformations
Presentation transcript:

Games Development 2 Text-based Game Data CO3301 Week 4

Contents Identifying “Hard-Coding” Types of Game Data Simple Example: INI files XML Overview XML for Games XML APIs Editing Tools

Hard-Coded Data Hard-coding describes the embedding of data in program code Seen early on in relation to program constants: char Name[256]; for (int c = 0; c < 256; c++) { … } The name length (256) is hard-coded – poor practice Solution: define a constant NAME_LENGTH Or: switch to a more flexible string representation Is the line below hard-coded? CMesh* tree = LoadMesh( “Tree1.x” );

Problems with Hard-Coding This is hard-coded CMesh* tree = LoadMesh( “Tree1.x” ); If we decide to use “tree2.x”, we need to change the code: Recompilation, can be slow for a large project Need to know where each LoadMesh call is to make changes Can’t be done at run-time (trying out different trees) How to improve on this - use data files

More Examples Hard-coding comes in other forms: This seems flexible: MessageBox( “Enter your name:” ); What if the application is released in another language? Or several… Effective localisation requires that no text strings are hard-coded. All should come from data files This seems flexible: bool enableWiggle = true; if (enableWiggle) { // Wiggle code } Programmer can toggle wiggle, but no-one else can If attached to UI, then OK. Otherwise enableWiggle should be a setting in a data file

What Can Be Stored as Data? Game data files can contain: Graphic settings (video card, res, AA, etc.) Game settings (difficulty, control setup, etc.) In-game level set-up: Entity templates needed per level Will drive resources to load (see last week) As well as provide some starting entity stats Level layout – entity positions Other required resources Localised text Hi-scores, network settings, menu layout…...

Text-based Data One positive point about hard-coded data is that it is stored in a text format (e.g. C++) Human read/writeable Use text-based data for equal convenience However, text-based data will often need to be parsed – at run-time Consider parsing performance and validation issues Can use binary data files, or compile text files to a binary form. Will not consider that here Can help for very large data sets

Issues with Text-based Data Parsing text-based files is slower than using hard-coding or binary data files However, most data is read at game or level set-up time, where performance is less critical Can be a issue regarding loading times Text files need more storage than binary data Data files are rarely significant in size, so only relevant with regards parsing time Text validation can be a headache True, good QA processes can help here Additional code development required (parsing) Reusable though

Rationale for Text Data Files Hard-coded data is inflexible: Requires recompilation for every change Requires programmer for every change Requires knowledge of code locations Text-based data files provide flexibility All settings in a few easily located files No recompilation required Can be even be coded to allow run-time changes to settings Changes can be made by anyone Including post-release

Simple Example: INI files The Microsoft “.ini” file is used in many applications to store simple settings: The format is long out-of-date, but still used for its simplicity A set of sections, each with keys and values: [Graphics] EnableWiggle=1 TreeType=“Tree1.x” [Input] MaxNameLength=256 Use functions such as GetPrivateProfileString & WritePrivateProfileSection

XML Overview XML (eXtensible Mark-up Language) is a general purpose mark-up language XML is used to store structured data Hence “mark up”: the data is marked with structure XML is not a programming or scripting language Not a sequence of operations, just structure XML has similar syntax to HTML Tags (<a> </a>) Attributes (<entity type=“Ship” />) XML is a text-based format But it isn’t really intended to be read

XML Overview XML is part of a family of technologies E.g. XSL – Style sheets for presenting XML XSLT – Transformations to convert XML data XML Schemas – To define constraints on XML data Etc. XML is platform independent and license-free Well supported, many implementations Lots of supporting tools too Plenty of free sources

XML Popularity XML was originally designed for transferring data across the internet But well suited to store structured data for general use XML is growing in popularity as the standard for data files For it’s portability and simplicity Microsoft, Apache, Mozilla etc. A number of games use XML too… Perhaps not for all their data needs, but certainly popular for configuration files and the like PC titles mainly

XML for Games XML stores data in a tree structure: <Level> <Entities> <Entity> <Type>Ship</Type> <Name>Luke</Name> <Position>0,10,0</Position> </Entity> <Name>Darth</Name> <Position>0,10,-100</Position> </Entities> </Level>

XML for Games Data can be stored between tags (previous example), but can be store as attributes instead: <Level> <Entities> <Entity template=“X-Wing” name=“Luke”> <Position X=“0” Y=“10” Z=“0” /> </Entity> <Entity template=“Tie-X1” name=“Darth”> <Position X=“0” Y=“10” Z=“-100” /> </Entities> </Level> In either case, the tree-based layout naturally matches many structures in games

XML for Games XML elements (tags) and attributes are customisable: <EntityTemplate Type="Ship" Name=“X-Wing" Mesh=“XWing1.x" HP="90" MaxSpeed="280" Acceleration="25" TurnSpeed="1.2"/> Suiting the wide variety of contexts in a game Values can be constrained with XML Schema: <xs:element name=“MaxSpeed"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="120"/> </xs:restriction> </xs:simpleType> </xs:element>

XML for Games XML is fairly easy to parse with its consistent tag structure Parsing speed can be reasonable Depending on the amount of validation Although XML data gets large quite easily which has an impact XML data is robust: Needs to be “well formed” But otherwise resilient to missing/duplicate data etc. So overall a good choice for game data More powerful than .ini files More data-centric than a scripted solution Will look at XML game data in the labs

XML APIs Two types of API for parsing: Stream-oriented – parses XML as a stream, uses callbacks as tags are opened and closed Potentially faster, especially on large documents Event / State based programming can be clumsy E.g. The expat parser (will see in the labs) Tree-traversal – reads entire document, passes back complete hierarchical structure Easier to work with Problems with large files E.g. TinyXML (good for projects)

XML APIs Popular APIs: Expat: Free, event driven, fast, used by Mozilla and others Libxml2: Free, event or document driven, powerful Xerces: Free, event / document driven, validates TinyXML: Free, simple document driven parser designed for simple integration into C++ programs Using Expat in the labs, though TinyXML may be a good choice for projects

XML Editors XML Notepad (Microsoft): Free, well supported XMLPad (WMHelp): Free powerful Many others Each allows editing in plain text or graphically Allow some measure of validation Can also create style sheets, schema etc. Visual Studio also has some support which is convenient for small files and simple changes