haxe for flash game dev

49
haXe for Flash Game Dev. Nicolas Cannasse, Motion-Twin http://ncannasse.fr March 8, 2010

Upload: others

Post on 09-May-2022

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: haXe for Flash Game Dev

haXe for Flash Game Dev.

Nicolas Cannasse, Motion-Twinhttp://ncannasse.fr

March 8, 2010

Page 2: haXe for Flash Game Dev

WARNING !!!code(); // ahead !

Page 3: haXe for Flash Game Dev

Compiler ?

Page 4: haXe for Flash Game Dev

Compiler ?

Page 5: haXe for Flash Game Dev

Compiler ?

Page 6: haXe for Flash Game Dev

Compiler ?

Before haXe : MTASC

Page 7: haXe for Flash Game Dev

D.R.Y.Don't Repeat Yourself

haXe@FGS

Page 8: haXe for Flash Game Dev

DRY

Page 9: haXe for Flash Game Dev

DRY

Page 10: haXe for Flash Game Dev

DRY

Type Inference

Page 11: haXe for Flash Game Dev

Data Structures

• AS : Array, Dictionary, Vector– (+) native speed– (-) not customizable

• Algorithms ~= Data Structures

• How to express your own (abstract) DS ?

Page 12: haXe for Flash Game Dev

Generics

class Foo {var arr : Array<Sprite>;function new() {arr = new Array();

}}

Page 13: haXe for Flash Game Dev

Generics

Page 14: haXe for Flash Game Dev

Generics in use

http://lab.polygonal.de

Page 15: haXe for Flash Game Dev

K.I.S.S.Keep it Simple, Stupid

haXe@FGS

Page 16: haXe for Flash Game Dev

Enums

Page 17: haXe for Flash Game Dev

Enums

Page 18: haXe for Flash Game Dev

Enums

Page 19: haXe for Flash Game Dev

Enums

Page 20: haXe for Flash Game Dev

Enums

In action !PBJ Assembler

Page 21: haXe for Flash Game Dev

Iterators

Page 22: haXe for Flash Game Dev

Iterators

Page 23: haXe for Flash Game Dev

Iterators

Page 24: haXe for Flash Game Dev

Iterators

Page 25: haXe for Flash Game Dev

Iterators

• Use them as you wish– By simply adding .iterator() method

• Optimized for common cases– Array, Vector, ....

• Iterator + Generics + Functional = Lambda

Page 26: haXe for Flash Game Dev

I.N.M.S.I Need More Speed !

haXe@FGS

Page 27: haXe for Flash Game Dev

Compiler Speed

• hxFormat Benchmark– 64 files , 10.000 lines, 300KB

• haXe : 0.31s

• AS3 conversion

• MXMLC : 3.3s

Page 28: haXe for Flash Game Dev

Inlining

Page 29: haXe for Flash Game Dev

Inline

In Action !

Page 30: haXe for Flash Game Dev

Back to Generics

Page 31: haXe for Flash Game Dev

Generics

• The issue with Generics

• The solution : haxe.rtti.Generic

• Tradeoff

Page 32: haXe for Flash Game Dev

Poll

What is the most fast way to read/write data ?

A) ArrayB) VectorC) ByteArrayD) SomethingElse

Page 33: haXe for Flash Game Dev

Poll

What is the most fast way to read/write data ?

A) ArrayB) VectorC) ByteArrayD) SomethingElse

Page 34: haXe for Flash Game Dev

Poll

What is the most fast way to read/write data ?

A) ArrayB) VectorC) ByteArrayD) Alchemy Global Memory

Page 35: haXe for Flash Game Dev

Alchemy

Page 36: haXe for Flash Game Dev

flash.Memory

// Quake Fast Inverse Square Rootfunction invSqrt( x : Float ) : Float { var half = 0.5 * x; flash.Memory.setFloat(0,x); var i = flash.Memory.getI32(0); i = 0x5f3759df - (i>>1); flash.Memory.setI32(0,i); x = flash.Memory.getFloat(0); x = x * (1.5 - half*x*x); return x;}

Page 37: haXe for Flash Game Dev

flash.Memory

• classic invSqrt : 92.61

• « optimized » invSqrt : 56.71 (+62%)

• flash.Memory invSqrt : 11.72 (+686%)– ~8 times faster !– ~same time as a DIV !

Page 38: haXe for Flash Game Dev

flash.Memory

In Action !

Page 39: haXe for Flash Game Dev

Summary

In case you were sleeping...

Page 40: haXe for Flash Game Dev

Summary

• haxe != AS3– But both compiles to SWF

• Features DRY/KISS/INMS– Type inference, Generics, Iterators, Enums,

flash.Memory– ... and actually more

• Open Source

Page 41: haXe for Flash Game Dev

Summary

Ooops !

Page 42: haXe for Flash Game Dev

More targets

• haXe can target SWF9 and SWF10

• But also SWF 6-8

• But also...

Page 43: haXe for Flash Game Dev

More targets

Javascript :generates a single .js file

Page 44: haXe for Flash Game Dev

More targets

PHP :write your websites in haXe !

Page 45: haXe for Flash Game Dev

More targets

NekoVM :write your websites in haXe (faster) !

commandline and desktop appsextensible with C/C++

Page 46: haXe for Flash Game Dev

haXe

In Action !

http://mybrute.com

Page 47: haXe for Flash Game Dev

More targets

C++ :all that you can imagine !including haXe/iPhonecheck gamehaxe.com

Page 48: haXe for Flash Game Dev

More targets

The haXe philosophy

Page 49: haXe for Flash Game Dev

E.O.F.Check http://haxe.org

haXe@FGS