| 1 | #coding:utf-8 |
|---|
| 2 | |
|---|
| 3 | importˆàvector |
|---|
| 4 | importˆàmath |
|---|
| 5 | |
|---|
| 6 | classˆàBody(object): |
|---|
| 7 | ˆà ˆà ˆà ˆà defˆà__init__(self,ˆàposition,ˆàvelocity =ˆàvector.Vector.null): |
|---|
| 8 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.position =ˆàposition |
|---|
| 9 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity =ˆàvelocity |
|---|
| 10 | |
|---|
| 11 | classˆàTank(Body): |
|---|
| 12 | ˆà ˆà ˆà ˆà radius =ˆà1 |
|---|
| 13 | ˆà ˆà ˆà ˆà model =ˆà"tank" |
|---|
| 14 | |
|---|
| 15 | ˆà ˆà ˆà ˆà defˆà__init__(self,ˆàposition,ˆàcontroller): |
|---|
| 16 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà Body.__init__(self,ˆàposition) |
|---|
| 17 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.controller =ˆàcontroller |
|---|
| 18 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.turret =ˆàvector.Vector() |
|---|
| 19 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.strength =ˆà0 |
|---|
| 20 | |
|---|
| 21 | ˆà ˆà ˆà ˆà defˆàrotate_base(tank,ˆàangle):ˆà |
|---|
| 22 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity.phi +=ˆàangle |
|---|
| 23 | |
|---|
| 24 | ˆà ˆà ˆà ˆà defˆàrotate_turret(self,ˆàangle): |
|---|
| 25 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.turret.phi +=ˆàangle |
|---|
| 26 | |
|---|
| 27 | ˆà ˆà ˆà ˆà defˆàaccelerate(self,ˆàspeed_delta): |
|---|
| 28 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity.rho +=ˆàspeed_delta *ˆàdelta_t |
|---|
| 29 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ifˆàself.velocity.rho >ˆàmax_velocity : |
|---|
| 30 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà self.velocity.rho =ˆàmax_velocity |
|---|
| 31 | |
|---|
| 32 | ˆà ˆà ˆà ˆà defˆàfire(self): |
|---|
| 33 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà pass |
|---|
| 34 | |
|---|
| 35 | classˆàBullet(Body): |
|---|
| 36 | ˆà ˆà ˆà ˆà radius =ˆà0.1 |
|---|
| 37 | ˆà ˆà ˆà ˆà model =ˆà"bullet" |
|---|
| 38 | |
|---|
| 39 | ˆà ˆà ˆà ˆà pass |
|---|