Bullet (技能类)

class Bullet(data_list)

基类:Sprite

机器人的技能属性。 使用 opt.BULLET 调用实例。

x

x 坐标

Type

float

y

y 坐标

Type

float

vx

x 方向速度

Type

float

vy

y 方向速度

Type

float

r

朝向的弧度信息,东方向为 0 度,南方向是 -π/2,西方向是 π,北方向为 π/2

Type

Radian

vr

角速度,弧度/秒

Type

Radian

Attributes Summary

angle

技能朝向角度,东方向为 0 度,南方向是 -90 度,西方向是 180 度,北方向为 90 度

radian

技能朝向弧度,东方向为 0 度,南方向是 -π/2,西方向是 π,北方向为 π/2

radian_velocity

技能角速度,单位为弧度/秒

Methods Summary

angle_to(x, y)

获取技能与某坐标 (x, y) 的角度

distance_to(x, y)

获取技能与某坐标 (x, y) 距离

radian_to(x, y)

获取技能与某坐标 (x, y) 的弧度

Attributes Documentation

angle

技能朝向角度,东方向为 0 度,南方向是 -90 度,西方向是 180 度,北方向为 90 度

返回

角度

返回类型

Angle

../_images/sprite_angle.png

实际案例

>>> import opt
>>> if len(opt.BULLET) > 0:
>>>     bullet = opt.BULLET[0]
>>>     bullet.r = 1.5707963267948966
>>>     print(bullet.angle)
90.0
radian

技能朝向弧度,东方向为 0 度,南方向是 -π/2,西方向是 π,北方向为 π/2

返回

弧度

返回类型

Radian

../_images/sprite_radian.png

实际案例

>>> import opt
>>> if len(opt.BULLET) > 0:
>>>     bullet = opt.BULLET[0]
>>>     bullet.r = 1.5707963267948966
>>>     print(bullet.radian)
1.5707963267948966
radian_velocity

技能角速度,单位为弧度/秒

返回

角速度

返回类型

Radian

../_images/sprite_radian_velocity.png

实际案例

>>> import opt
>>> if len(opt.BULLET) > 0:
>>>     bullet = opt.BULLET[0]
>>>     bullet.vr = 1.5
>>>     print(bullet.radian_velocity)
1.5

Methods Documentation

angle_to(x, y)

获取技能与某坐标 (x, y) 的角度

参数
  • x (float) – 目标 x 坐标

  • y (float) – 目标 y 坐标

返回

角度

返回类型

Angle

../_images/sprite_angle_to.png

实际案例

>>> import opt
>>> if len(opt.BULLET) > 0:
>>>     bullet = opt.BULLET[0]
>>>     bullet.x, bullet.y, bullet.r = 0, 0, 0
>>>     print(bullet.angle_to(-1, 0))
180.0
distance_to(x, y)

获取技能与某坐标 (x, y) 距离

参数
  • x (float) – 目标 x 坐标

  • y (float) – 目标 y 坐标

返回

距离

返回类型

float

../_images/sprite_distance_to.png

实际案例

>>> import opt
>>> if len(opt.BULLET) > 0:
>>>     bullet = opt.BULLET[0]
>>>     bullet.x, bullet.y, bullet.r = 0, 0, 0
>>>     print(bullet.distance_to(2, 0))
2.0
radian_to(x, y)

获取技能与某坐标 (x, y) 的弧度

参数
  • x (float) – 目标 x 坐标

  • y (float) – 目标 y 坐标

返回

弧度

返回类型

Radian

../_images/sprite_radian_to.png

实际案例

>>> import opt
>>> if len(opt.BULLET) > 0:
>>>     bullet = opt.BULLET[0]
>>>     bullet.x, bullet.y, bullet.r = 0, 0, 0
>>>     print(bullet.radian_to(-1, 0))
3.141592653589793