Presentation is loading. Please wait.

Presentation is loading. Please wait.

REFERENCE: CHAPTER 1 High-level languages + Python.

Similar presentations


Presentation on theme: "REFERENCE: CHAPTER 1 High-level languages + Python."— Presentation transcript:

1 REFERENCE: CHAPTER 1 High-level languages + Python

2 Game Programming…??? Half-life 3! ??? mov ax, 0x5000 add ax, 0x0001 … …. …(5 billion lines later)… jmp 0x6539

3 High-level Programming languages to the rescue! Half-Life 3 mov ax, 0x5000 add ax, 0x0001 … …. …(5 billion lines later)… jmp 0x6539 Halo Image from: http://ninjanerdstech.com/wiki/halo-4/

4 Compilers / Interpreters compiler or interpreter  Specific to architecture and OS  Steps:  Reads source file(s).  Generates machine code (CPU instructions) Compilers  Stand-alone executable (.exe file) Interpreters  re-generate machine code every run

5 High Level Languages Name Some!  Interpreted:  Compiled: Why are there so many?

6 Python! +: Easy to read/write (more English-like than many) +: A ton of libraries  pygame (www.pygame.org)www.pygame.org +: Good balance between ease-of-use and power. -: Interpreted (so a little slower) -: A little harder to distribute

7 Installing python at home Go to www.python.orgwww.python.org  Or…use the link(s) on ssugames Python 2.x vs. 3.x  Not a lot of differences.  We’ll be using 3.1 in-class  Find the one appropriate to your OS.  Available on: Windows, OSX, Linux, etc.  VERY IMPORTANT: Get the 32-bit version, even if you have a 64- bit OS (pygame only works with 32-bit python)

8 Installing python at home, cont. Pygame  We won’t use it for a few weeks, but go ahead and get it.  Go to www.pygame.orgwww.pygame.org  Find the version that matches your python version and OS. Test it.  Start IDLE  Type this:  If you don’t get an error, you’re all set!

9 Script vs. Interactive mode Interpreters usually have "interactive" mode [Script mode differences] [Demonstrate in IDLE]

10 python "IDE's" (and pro's and con's of each) IDLE (comes with python)  interactive mode  script mode DOS (in Win7)  Start Menu => "cmd"  cd myDir (cd.. goes back a level)  z:  c:\python31\python myfile.py Notepad++ PyScripter (http://code.google.com/p/pyscripter/)http://code.google.com/p/pyscripter/ NetBeans …

11 Errors Syntax Exceptions Try these:  print(Hello, World”)  print(Hello, World)  Print(“Hello, World”)

12 Errors, cont. Call Stack: The bottom section is the actual error: We got to the error from here: We got there from here: This is the line number of the error: This is the type of Error:

13 Print Function print(expression) expression can be:  A string  A number  A mathematical expression:  4 + 5  4 - 5  4 * 5  4 / 5  2 ** 3  A comma-separated sequence of expressions  [sep and end]

14 Comments [Syntax and evaluation] [Why are they useful?]

15 Input function [As a means to pause] We'll see the real use shortly…


Download ppt "REFERENCE: CHAPTER 1 High-level languages + Python."

Similar presentations


Ads by Google