CSCE 552 Spring 2010 Language and Programming By Jijun Tang.

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Configuration management
Configuration management
Programming Paradigms and languages
CSCE 590E Spring 2007 Game Design II By Jijun Tang.
Chapter 3.5 Debugging Games
CSCE 590E Spring 2007 Game Programming By Jijun Tang.
Programming Creating programs that run on your PC
Chapter 3.2 C++, Java, and Scripting Languages. 2 C++ C used to be the most popular language for games Today, C++ is the language of choice for game development.
Chapter 3.1 Teams and Processes Being a programmer.
Object Oriented System Development with VB .NET
Chapter 3.3 Programming Fundamentals Languages Paradigms Basic Data Types Data Structures OO in Game Design Component Systems Design Patterns.
Chapter 3.2 C++, Java, and Scripting Languages “The major programming languages used in game development.”
Chapter 3.1 Teams and Processes. 2 Programming Teams In the 1980s programmers developed the whole game (and did the art and sounds too!) Now programmers.
Chapter 3.2 C++, Java, and Scripting Languages hacked by jeffery.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Chapter 3.4 Programming Fundamentals. 2 Data Structures Arrays – Elements are adjacent in memory (great cache consistency) – They never grow or get reallocated.
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
Software design and development Marcus Hunt. Application and limits of procedural programming Procedural programming is a powerful language, typically.
Software Development Concepts ITEC Software Development Software Development refers to all that is involved between the conception of the desired.
Chapter Languages, Programming and Architecture.
Games Development 2 Entity / Architecture Review CO3301 Week
CS 355 – Programming Languages
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
1 Shawlands Academy Higher Computing Software Development Unit.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Object Oriented Analysis and Design Introduction.
CSCE 552 Spring 2009 Game Design III By Jijun Tang.
CS101 Introduction to Computing Lecture Programming Languages.
Configuration Management (CM)
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
CSCE 552 Spring 2009 Programming Fundamentals By Jijun Tang.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
CHAPTER TEN AUTHORING.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Objected Oriented Programming & Design JAVA Shishir Gupta (704) (704)
Chapter 14 Part II: Architectural Adaptation BY: AARON MCKAY.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Software Development Process.  You should already know that any computer system is made up of hardware and software.  The term hardware is fairly easy.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Chapter 3.1 Teams and Processes. CS Programming Teams In the 1980s programmers developed the whole game (and did the art and sounds too!) Now programmers.
Intermediate 2 Software Development Process. Software You should already know that any computer system is made up of hardware and software. The term hardware.
What is Testing? Testing is the process of finding errors in the system implementation. –The intent of testing is to find problems with the system.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
CSCE 552 Fall 2012 Language and Programming By Jijun Tang.
CS5103 Software Engineering Lecture 02 More on Software Process Models.
Object-Oriented Programming Chapter Chapter
M1G Introduction to Programming 2 5. Completing the program.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
Object Oriented Software Development 4. C# data types, objects and references.
CSCE 552 Fall 2012 Language and Programming By Jijun Tang.
Introduction to OOP CPS235: Introduction.
Review of the numeration systems The hardware/software representation of the computer and the coverage of that representation by this course. What is the.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
Getting ready. Why C? Design Features – Efficiency (C programs tend to be compact and to run quickly.) – Portability (C programs written on one system.
Java How to Program, 9/e Presented by: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Design and Development Development Methodoligies Computing Science.
CSCE 552 Spring 2011 Language and Programming By Jijun Tang.
Language and Programming
Chapter 11 Object-Oriented Design
Introduction to Data Structure
(Computer fundamental Lab)
Games Development 2 Entity / Architecture Review
Presentation transcript:

CSCE 552 Spring 2010 Language and Programming By Jijun Tang

Announcements Send me group names and logos XNA demo/learning on Feb 1 st, in 1D11  Install XNA Game Studio and VC# Express on your laptop  Please bring your laptop to the class Presentation on Feb 3 rd  In 1D11  Each group 10 minutes to present, 3 minutes to answer question Homework #1

Game Design Presentation Expecting formal presentations with powerpoint files, pictures, musics, etc 10 points total for this presentation Grade will be group based, you can have the whole group or part of the group to present Grade will be based on scores from me and from the class

Homework #1 Game Treatment Document Due on Feb 8 th after class Each group turn in one hard copy and the grade will be assigned based on group

Example of Treatment ser/DH2650/spel08/The%20Game%20 Treatment.doc

Design Procedure Waterfall method  Development methodology  Design and production are broken into phases Iterative development  Practice of producing things incrementally  Refining and re-refining the product  May iterate many cycles before get it right

Waterfall vs. Iterative testing

Brainstorming Generating ideas without discrimination Evaluation after elaboration, can be unfocused

Programming Teams In the 1980s programmers developed the whole game (and did the art and sounds too!) Now programmers write code to support designers and artists (content creators)

Different Programs Game code Anything related directly to the game Game engine Any code that can be reused between different games Tools In house tools Plug-ins for off-the-shelf tools

Methodologies: Code and Fix Unfortunately very common Little or no planning Always reacting to events Poor quality and unreliability of finished product “Crunch” time normal

Methodologies: Waterfall Very well-defined steps in development Lots of planning ahead of time Great for creating a detailed milestone schedule Doesn't react well to changes Game development is too unpredictable for this approach

Methodologies: Iterative Multiple development cycles during a single project  Each delivering a new set of functionality  Refinements are needed The game could ship at any moment Allows for planning but also for changes

Methodologies: Agile Methods Deal with the unexpected Very short iterations: 2-3 weeks Iterate based on feedback of what was learned so far Very good visibility of state of game Difficult for publishers or even developers to adopt because it's relatively new

Make Coding Easier Version control Coding standards Automated build Code review Unit testing and acceptance testing

Version Control Recommended to use for team project Version control is  Database with all the files and history.  Only way to work properly with a team.  Branching and merging can be very useful  Used for source code as well as game assets (text and binary) Tools:  CVS is one of the most popular tool  Source anywhere

Coding standards Coding standards are  Set of coding rules for the whole team to follow  Improves readability and maintainability of the code  Easier to work with other people's code  They vary a lot from place to place Some simple, some complex Get used to different styles Sample standards can be found at: lott.org/resources/cstyle/CppCodingStandard.htmlhttp:// lott.org/resources/cstyle/CppCodingStandard.html

Automated builds Dedicated build server builds the game from scratch Takes the source code and creates an executable Also takes assets and builds them into game-specific format Build must never break

Quality Control Code reviews  Knowing others will read the code will make coding more carefully  Another programmer reads over some code and tries to find problems  Sometimes done before code is committed to version control  Can be beneficial if done correctly Follow coding standards, and put comments

Avoid Run-time Errors Run-time errors are hardest to trace and have the biggest damage Initialize variables, use tools (Visual.Net is good at this), check boundaries, etc.  purify on Windows  valgrind on Linux Asserts and crashes  Use asserts anytime the game could crash or something could go very wrong  An assert is a controlled crash in the debug version  Much easier to debug and fix  Happens right where the problem occurred  Don't use them for things that a user could do Open a non-existing file Press the wrong button

Leveraging Existing Code A lot of code that games use is the same It's a total waste of time to write it over and over Instead, spend your time in what's going to make your game unique Avoid Not Invented Here (NIH) syndrome!

Where Are Existing Codes Reuse code from previous project  Easier in a large company if you have an engine and tools group Use freeware code and tools  No support  Make sure license allows it Middleware  Companies provide with components used in game development physics, animation, graphics, etc Commercial game engines  You can license the whole engine and tools and a single package  Good if you're doing exactly that type of game

Languages C/C++ Java Script: Flash, Python, LISP, etc. C# XNA for PC and Xbox

C++ C used to be the most popular language for games Today, C++ is the language of choice for game development

C++: Strengths - I Performance  Control over low-level functionality (memory management, etc)  Can switch to assembly or C whenever necessary  Good interface with OS, hardware, and other languages High-level, object-oriented  High-level language features are essential for making today's complex games  Has inheritance, polymorphism, templates, and exceptions  Strongly typed, so it has improved reliability

C++: Strengths - II C Heritage  C++ is the only high-level language that is backwards-compatible with C  Has APIs and compiler support in all platforms  Easier transition for experienced programmers Libraries  STL (Standard Template Library) Comprehensive set of standard libraries  Boost: widely used library with wide variety of functionality  Many commercial C++ libraries also available

C++: Weaknesses - I Too low-level  Still forces programmers to deal with low-level issues  Too error-prone  Attention to low-level details is overkill for high-level features or tools Slow iteration  C++ is fully compiled into binary format from source code  Compiling large numbers of files is very slow  This will only become more of a problem as games become more complex

C++: Weaknesses - II Too complicated  Because of its C heritage, C++ is very complicated  Long learning curve to become competent with the language Lacking features  No reflection or introspection features  No method of object serialization  No native support for message passing

C++: When to Use It? When performance is crucial If your current code base is mostly C and C++ If you have a lot of in-house expertise in C++ Avoid using it for high-level code, such as tools

Java for Game Development Why use Java?  It's a high-level OO language that simplifies many C++ features  Adds several useful high-level features  Easy to develop for multiple platforms because of intermediate bytecode  Good library support

Java Performance Has typically been Java's weak point Has improved in the last few years: still not up to C++ level, but very close Uses Just-In-Time compiling and HotSpot optimizations Now has high-performance libraries Also has access to native functionality

Java Platforms Well suited to downloadable and browser-based games Dominates development on mobile and handheld platforms Possible to use in full PC games, but more likely to be embedded into a game

Commercial Games using Java Downloadable games like those from PopCap Games: Mummy Maze, etc Online card games PC games using Java as a scripting language: Vampire: The Masquerade, Star Wars Galaxies PC games fully written in Java: You Don't Know Jack, Who Wants to Be a Millionaire

C# Developed by MS, now ISO standard A simple, modern, general-purpose, object- oriented programming language Support for software engineering principles:  strong type checking  array bounds checking  detection of attempts to use uninitialized variables  automatic garbage collection. Software robustness, durability, and programmer productivity are important.

Strength and Weakness C# is intended to be suitable for writing applications for both hosted and embedded systems Source code portability is very important, as is programmer portability Although is intended to be economical (memory/processing power), it cannot compete directly with C or assembly language.

Scripting Languages Why use scripting languages?  Ease and speed of development  Short iteration time  Code becomes a game asset  Offer additional features and are customizable

Drawbacks of Scripting Languages Slow performance Limited tool support Dynamic typing makes it difficult to catch errors Awkward interface with the rest of the game Difficult to implement well

Popular scripting languages Python Lua Other off-the-shelf options such as Ruby, Perl, Javascript Custom scripting languages  UnrealScript, QuakeC, NWNScript

Lua Example

Choose a Scripting Languages Consider whether you need one at all What features do you need? What kind of performance do you need? What debugging facilities does the language have? On what platforms does it need to run? What resources and expertise are available?

Programming Fundamentals

Data Structures: Array Elements are adjacent in memory (great cache consistency)  Requires continuous memory space They never grow or get reallocated  Use dynamic incremental array concept  GCC has a remalloc function In C++ there's no check for going out of bounds  Use vector if possible  Keep in mind of checking boundaries Inserting and deleting elements in the middle is expensive

List Very cheap to add/remove elements. Available in the STL (std::list) Every element is allocated separately, not placed contiguously in memory  Lots of little allocations  Bad cache awareness, but can use arrays to hold pre-allocated items Single/Double linked list

Lists

Dictionaries Maps a set of keys to some data. std::map, std::hash, etc Very fast access to data Perfect for mapping IDs to pointers, or resource handles to objects May waste space, need to design comparison operators

Hash Table

Others Stacks  First in, last out  std::stack adaptor in STL Queues  First in, first out  std::deque  Priority queue is useful in game to schedule events

Stack/Queue/Priority Queue

Bit packing Fold all necessary data into a smaller number of bits Bool in C++ may use up to 4 bytes, thus is very expensive Very useful for storing boolean flags: pack 32 in an integer Possible to apply to numerical values if we can give up range or accuracy Very low level trick  Use shifts to handle the operation or use assembly  Only use when absolutely necessary

Bits

Inheritance Models “is-a” relationship Extends behavior of existing classes by making minor changes Do not overuse, if possible, use component systerm UML diagram representing inheritance

Polymorphism The ability to refer to an object through a reference (or pointer) of the type of a parent class Key concept of object oriented design C++ implements it using virtual functions

Multiple Inheritance Allows a class to have more than one base class Derived class adopts characteristics of all parent classes Huge potential for problems (clashes, casting, dreaded diamond, etc) Multiple inheritance of abstract interfaces is much less error prone (virtual inheritance) Java has no multiple inheritance

Dreaded Diamond It is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If a method in D calls a method defined in A (and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B, or C?

Component Systems Component system organization

Object Factory Creates objects by name Pluggable factory allows for new object types to be registered at runtime Extremely useful in game development for passing messages, creating new objects, loading games, or instantiating new content after game ships

Factory Pattern

Simple Sample Factory - I

Simple Sample Factory - II

Singleton Implements a single instance of a class with global point of creation and access For example, GUI Don't overuse it!!!

Singleton Example

Adapter Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces Real interface

Adapter Pattern

Adapter Example - I

Adapter Example - II

Observer Allows objects to be notified of specific events with minimal coupling to the source of the event Two parts  subject and observer

Observer Pattern

Composite Allow a group of objects to be treated as a single object Very useful for GUI elements, hierarchical objects, inventory systems, etc

Composite Pattern

Composite Pattern Example - I Add many more inherited classes

The Five Step Debugging Process 1. Reproduce the problem consistently 2. Collect clues 3. Pinpoint the error 4. Repair the problem 5. Test the solution

Expert Debugging Tips Question assumptions Minimize interactions and interference Minimize randomness Break complex calculations into steps Check boundary conditions, use assertions Disrupt parallel computations Exploit tools in the debugger (VC is good, purify) Check code that has recently changed Explain the bug to someone else Debug with a partner (A second pair of eyes) Take a break from the problem Get outside help (call people)