python in the game world

16
Python í leikjaheiminum Guðmundur Jón Halldórsson Tölvunarfræðingur frá HR CCP Games 2012

Upload: gudmundur-halldorsson

Post on 11-Nov-2014

1.050 views

Category:

Technology


1 download

DESCRIPTION

Used in SKY presentation http://www.sky.is/index.php?option=com_content&view=article&id=1780:2012-vinnuumhverfi-forritarans&catid=25&Itemid=100074

TRANSCRIPT

Page 1: Python in the game world

Python í leikjaheiminum

Guðmundur Jón Halldórsson Tölvunarfræðingur frá HR

CCP Games 2012

Page 2: Python in the game world

Python

• Höfundur málsins er Guido van Rossum • Málið er skýrt eftir „Monty Python‘s Flying

Circus“ • Python kóðinn er „Open Source“ • Dæmi um mismunandi útfærslur:

– CPython – PyPy ( 5x hraðara en CPython ) – IronPython (Microsoft útgáfa af Python) – Stackless ( CCP Games ) – ...

Page 3: Python in the game world

Nokkrir kostir við Python

• Stórt standard library • Gagnvirk skel • Víðtæka grafískan pakka • Mjög færanlegt, með túlk fyrir flest stýrikerfi • Styður hlutbundna högun, fjöl erfðir, klasa, namespaces, módúla,

hluti, villur og late (runtime) binding • Styður functional og structured programming methods ásamt

hlutbundinni höfun • Very high-level dynamic data types • Dynamic type checking • Sjálfvirk rusla söfnun • Run type checking • Auðveldlega samþætt við C, C++, …, Java og .NET

Page 4: Python in the game world

Stackless

• Microthreads – „Tasklets“ Hjúpar föll til að leyfi þeim að vera keyrð

sem „microthreads“

• Channels – Tví átta samskipti milli „tasklets“

• Scheduling – „Round robin scheduler“. Schedule tasklets

• Serialization – Tasklets má serialize á disk til að halda áfram með

framkvæmd síðar

Page 5: Python in the game world

Python/Ruby/Lua Family Tree

Page 6: Python in the game world

Dæmi um leiki skrifaða í Python

• Battle Field 2 og 2142

• Battlefield Heroes

• BalazarBrothers

• EVE Online

• Freedom Force

• Mount&Blade

• OpenRTS

• pydance

• PySol

• Slune

• Snakeworlds

• SolarWolf

• Umbra

• Interstate Outlaws

• Evil Greg Vs. Eight Year Olds

• Toontown

• Pirate of the Caribbena Online

• Code3D

• Termal Enforcer

• Traitors Gate 2

Page 7: Python in the game world

Áhugaverð leikjavéla/söfn

• PyGame

• PySoy

• Pyglet

• Python-Orge

• Panda3d

• Blender3d

• Horde3d (Mjög áhugaverð)

• ...og svo má lengi telja

Page 8: Python in the game world

DÆMI PANDA3D Vídeó

Page 9: Python in the game world

DÆMI BLENDER3D Vídeó

Page 10: Python in the game world

DÆMI PYTHON

Panda3d dæmi

Procedure Cube

Vídeó

Page 11: Python in the game world

Skref

• Teikna tening

• Snúa tening

• Hjálparföll (event) – toogleLightsUp

– toogleLightsSide

– toogleTex

– makeSquare

• Tengja event-a fyrir [1, 2, 3]

• Hlaða inn texture (mynd)

Page 12: Python in the game world

Teikna tening

Fram Hægri Bak

Niður

Up

Vinstri

Page 13: Python in the game world

Teikna tening square0 = makeSquare(-1,-1,-1, 1,-1, 1) square1 = makeSquare(-1, 1,-1, 1, 1, 1) square2 = makeSquare(-1, 1, 1, 1,-1, 1) square3 = makeSquare(-1, 1,-1, 1,-1,-1) square4 = makeSquare(-1,-1,-1,-1, 1, 1) square5 = makeSquare( 1,-1,-1, 1, 1, 1) snode = GeomNode('square') snode.addGeom(square0) snode.addGeom(square1) snode.addGeom(square2) snode.addGeom(square3) snode.addGeom(square4) snode.addGeom(square5) cube = render.attachNewNode(snode)

Page 14: Python in the game world

Snúa, tengja og hlaða

# snúa cube.hprInterval(5.5, Point3(360,360,360)).loop() # tengja self.accept("1", self.toggleTex) self.accept("2", self.toggleLightsSide) self.accept("3", self.toggleLightsUp) # hlaða texture sem er mynd self.testTexture=loader.loadTexture("maps/photo.png")

Page 15: Python in the game world

Spurning

• Netfang [email protected]

• Twitter @gudmundurjon

• LinkedIn [email protected]

Page 16: Python in the game world

Áhugaverðir hlekkir Python

• http://www.python.org

• http://www.stackless.com

• http://www.ironpython.net/

• http://pypy.org/

• http://wiki.python.org/moin/PythonGames

• http://www.python.org/about/success/

3D

• http://www.panda3d.org

• http://www.blender.org

• http://www.horde3d.org

Youtube

• http://www.youtube.com/watch?v=WwMHnJC08vo&feature=related

• http://www.youtube.com/watch?v=mQ4qr5bEP6U&feature=mfu_in_order&list=UL

Kóða dæmi

• C:\Panda3D-1.7.2\samples\Procedural-Cube\Tut-Procedural-Cube.py