Mercurial > touhou
annotate pytouhou/game/bullet.pxd @ 524:7f016dfbdfb1
Make vector a struct, allocate it directly on the stack, and thus pass it by copy, which is much less expensive than a python allocation.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 18 Dec 2013 18:15:40 +0100 |
parents | 887de1309491 |
children | 3c2f96f1d715 |
rev | line source |
---|---|
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 from pytouhou.game.element cimport Element |
447
78e1c3864e73
Make pytouhou.game.game an extension type.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
442
diff
changeset
|
2 from pytouhou.game.game cimport Game |
472
8038f1957b71
Type bullettype, itemtype and lasertype a bit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
468
diff
changeset
|
3 from pytouhou.game.bullettype cimport BulletType |
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 from pytouhou.utils.interpolator cimport Interpolator |
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 |
448
3bc37791f0a2
Make Bullet.state an enum.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
447
diff
changeset
|
6 |
3bc37791f0a2
Make Bullet.state an enum.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
447
diff
changeset
|
7 cdef enum State: |
3bc37791f0a2
Make Bullet.state an enum.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
447
diff
changeset
|
8 LAUNCHING, LAUNCHED, CANCELLED |
3bc37791f0a2
Make Bullet.state an enum.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
447
diff
changeset
|
9 |
3bc37791f0a2
Make Bullet.state an enum.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
447
diff
changeset
|
10 |
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 cdef class Bullet(Element): |
448
3bc37791f0a2
Make Bullet.state an enum.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
447
diff
changeset
|
12 cdef public State state |
3bc37791f0a2
Make Bullet.state an enum.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
447
diff
changeset
|
13 cdef public unsigned long flags, frame, sprite_idx_offset, damage |
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 cdef public double dx, dy, angle, speed |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
472
diff
changeset
|
15 cdef public bint was_visible, grazed |
472
8038f1957b71
Type bullettype, itemtype and lasertype a bit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
468
diff
changeset
|
16 cdef public Element target |
8038f1957b71
Type bullettype, itemtype and lasertype a bit.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
468
diff
changeset
|
17 cdef public BulletType _bullet_type |
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 cdef public list attributes |
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 |
468
feecdb4a8928
Add “except *” to cdef void functions, and type some more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
448
diff
changeset
|
20 cdef double hitbox[2] |
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 cdef Interpolator speed_interpolator |
447
78e1c3864e73
Make pytouhou.game.game an extension type.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
442
diff
changeset
|
22 cdef Game _game |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
472
diff
changeset
|
23 cdef long player |
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 |
468
feecdb4a8928
Add “except *” to cdef void functions, and type some more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
448
diff
changeset
|
25 cdef bint is_visible(self, unsigned int screen_width, unsigned int screen_height) except? False |
442
6b4c3e250bd6
Type Bullet more, to improve performances.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 cpdef set_anim(self, sprite_idx_offset=*) |
468
feecdb4a8928
Add “except *” to cdef void functions, and type some more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
448
diff
changeset
|
27 cdef void launch(self) except * |
feecdb4a8928
Add “except *” to cdef void functions, and type some more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
448
diff
changeset
|
28 cdef void collide(self) except * |
feecdb4a8928
Add “except *” to cdef void functions, and type some more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
448
diff
changeset
|
29 cdef void cancel(self) except * |
feecdb4a8928
Add “except *” to cdef void functions, and type some more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
448
diff
changeset
|
30 cdef void update(self) except * |