+ All Categories
Home > Documents > REFERENCE: CHAPTER 1 High-level languages + Python.

REFERENCE: CHAPTER 1 High-level languages + Python.

Date post: 17-Jan-2018
Category:
Upload: derick-lloyd
View: 229 times
Download: 0 times
Share this document with a friend
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:
15
REFERENCE: CHAPTER 1 High-level languages + Python
Transcript
Page 1: REFERENCE: CHAPTER 1 High-level languages + Python.

REFERENCE: CHAPTER 1

High-level languages + Python

Page 2: REFERENCE: CHAPTER 1 High-level languages + Python.

Game Programming…???

Half-life 3!

???mov ax, 0x5000add ax, 0x0001………….…(5 billion lines later)…jmp 0x6539

Page 3: REFERENCE: CHAPTER 1 High-level languages + Python.

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

Page 4: REFERENCE: CHAPTER 1 High-level languages + Python.

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

Page 5: REFERENCE: CHAPTER 1 High-level languages + Python.

High Level Languages

Name Some! Interpreted:

Compiled:

Why are there so many?

Page 6: REFERENCE: CHAPTER 1 High-level languages + Python.

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

Page 7: REFERENCE: CHAPTER 1 High-level languages + Python.

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)

Page 8: REFERENCE: CHAPTER 1 High-level languages + 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!

Page 9: REFERENCE: CHAPTER 1 High-level languages + Python.

Script vs. Interactive mode

Interpreters usually have "interactive" mode[Script mode differences][Demonstrate in IDLE]

Page 10: REFERENCE: CHAPTER 1 High-level languages + Python.

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…

Page 11: REFERENCE: CHAPTER 1 High-level languages + Python.

Errors

SyntaxExceptionsTry these:

print(Hello, World”)

print(Hello, World)

Print(“Hello, World”)

Page 12: REFERENCE: CHAPTER 1 High-level languages + Python.

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:

Page 13: REFERENCE: CHAPTER 1 High-level languages + Python.

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]

Page 14: REFERENCE: CHAPTER 1 High-level languages + Python.

Comments

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

Page 15: REFERENCE: CHAPTER 1 High-level languages + Python.

Input function

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


Recommended