reference: chapter 1 high-level languages + python
DESCRIPTION
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:TRANSCRIPT
REFERENCE: CHAPTER 1
High-level languages + Python
Game Programming…???
Half-life 3!
???mov ax, 0x5000add ax, 0x0001………….…(5 billion lines later)…jmp 0x6539
High-level Programming languages to the rescue! Half-Life 3
mov ax, 0x5000add ax, 0x0001………….…(5 billion lines later)…jmp 0x6539
Halo Image from: http://ninjanerdstech.com/wiki/halo-4/
3
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
High Level Languages
Name Some! Interpreted:
Compiled:
Why are there so many?
Python!
+: Easy to read/write (more English-like than many)
+: A ton of libraries pygame (www.pygame.org)
+: Good balance between ease-of-use and power.
-: Interpreted (so a little slower)-: A little harder to distribute
Installing python at home
Go to www.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)
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.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!
Script vs. Interactive mode
Interpreters usually have "interactive" mode[Script mode differences][Demonstrate in IDLE]
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/)NetBeans…
Errors
SyntaxExceptionsTry these:
print(Hello, World”)
print(Hello, World)
Print(“Hello, World”)
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:
Print Functionprint(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]
Comments
[Syntax and evaluation][Why are they useful?]
Input function
[As a means to pause]We'll see the real use shortly…