Games Development 2 Text-based Game Data CO3301 Week 4.

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

WeB application development
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.
Supervised by Prof. LYU, Rung Tsong Michael Department of Computer Science & Engineering The Chinese University of Hong Kong Prepared by: Chan Pik Wah,
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.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
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.
Technical Track Session XML Techie Tools Tim Bornholt.
HTML 1 Introduction to HTML. 2 Objectives Describe the Internet and its associated key terms Describe the World Wide Web and its associated key terms.
Web Design Basic Concepts.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
Chapter 1 Variables in the Web Design Environment.
Chapter 1 Variables in the Web Design Environment
Games Development 2 Entity / Architecture Review CO3301 Week
1 Networks and the Internet A network is a structure linking computers together for the purpose of sharing resources such as printers and files Users typically.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
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.
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.
HTML, XHTML, and CSS Sixth Edition Chapter 1 Introduction to HTML, XHTML, and CSS.
1 XML: an introduction David Nathan. 2 XML  an in-line markup system  single sequence of plain text only (but can be unicode)  equivalent to a tree.
XML Parsers Overview  Types of parsers  Using XML parsers  SAX  DOM  DOM versus SAX  Products  Conclusion.
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.
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
XML Basics A brief introduction to XML in general 1XML Basics.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
XML Engr. Faisal ur Rehman CE-105T Spring Definition XML-EXTENSIBLE MARKUP LANGUAGE: provides a format for describing data. Facilitates the Precise.
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.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
XML A Language Presentation. Outline 1. Introduction 2. XML 2.1 Background 2.2 Structure 2.3 Advantages 3. Related Technologies 3.1 DTD 3.2 Schemas and.
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.
Tutorial 1 Developing a Basic Web Page. Objectives Learn the history of the Web and HTML Describe HTML standards and specifications Understand HTML elements.
4.01B Authoring Languages and Web Authoring Software 4.01 Examine webpage development and design.
©Silberschatz, Korth and Sudarshan10.1Database System Concepts W3C - The World Wide Web Consortium W3C - The World Wide Web Consortium.
HTML Concepts and Techniques Fifth Edition Chapter 1 Introduction to HTML.
Martin Kruliš by Martin Kruliš (v1.1)1.
Chapter 1 Introduction to HTML, XHTML, and CSS HTML5 & CSS 7 th Edition.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
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.
XML Extensible Markup Language
WEB DESIGN CONCEPTS Brayden Burr. UNDERSTANDING THE CONTENT.
The Object-Oriented Thought Process Chapter 11
4.01B Authoring Languages and Web Authoring Software
Chapter 1 Introduction to HTML.
XML in Web Technologies
Microsoft Office Illustrated
4.01B Authoring Languages and Web Authoring Software
XML Data Introduction, Well-formed XML.
XML and its applications: 4. Processing XML using PHP
Games Development 2 Tools Programming
Games Development 2 Text-based Game Data
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: 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 –Microsoft recommend the use of the registry instead

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 ( ) –Attributes ( ) 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: Ship Luke 0,10,0 Ship Darth 0,10,-100

XML for Games Data can be stored between tags (previous example), but can be store as attributes instead: In either case, the tree-based layout naturally matches many structures in games

XML for Games XML elements (tags) and attributes are customisable: Suiting the wide variety of contexts in a game Values can be constrained with XML Schema:

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 parse (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 Serna Free - Open Source XML Editor 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