MCPcopy
hub / github.com/feichao93/battle-city / getCollisionRect

Method getCollisionRect

app/utils/bullet-utils.ts:42–61  ·  view source on GitHub ↗
(collision: Collision)

Source from the content-addressed store, hash-verified

40 // 获取一个Collision对象中 碰撞物体的Rect对象
41 // 例如输入参数collision记录了一个子弹碰到了一个Brick对象, 那么该函数将返回Brick的Rect
42 static getCollisionRect(collision: Collision) {
43 const borderCollisionRect: Rect = {
44 x: FIELD_SIZE,
45 y: FIELD_SIZE,
46 width: -FIELD_SIZE,
47 height: -FIELD_SIZE,
48 }
49 if (collision.type === 'brick' || collision.type === 'steel') {
50 return IndexHelper.getRect(collision.type, collision.t)
51 } else if (collision.type === 'border') {
52 return borderCollisionRect
53 } else if (collision.type === 'tank') {
54 return asRect(collision.tank)
55 } else if (collision.type === 'eagle') {
56 return asRect(collision.eagle)
57 } else {
58 // c.type === 'bullet'
59 return { x: collision.x, y: collision.y, width: 0, height: 0 }
60 }
61 }
62
63 // 判断一颗子弹是否发生爆炸
64 static shouldExplode(collisions: Collision[]) {

Callers

nothing calls this directly

Calls 2

asRectFunction · 0.90
getRectMethod · 0.80

Tested by

no test coverage detected