Bullet support
This commit is contained in:
@@ -14,6 +14,7 @@ type ObjectType int
|
||||
const (
|
||||
Hero ObjectType = 1 << iota
|
||||
Zombie
|
||||
Bullet
|
||||
)
|
||||
|
||||
type Collidable interface {
|
||||
|
||||
@@ -18,7 +18,10 @@ func (w *World) RemoveEntity(e Collidable) {
|
||||
|
||||
func (w *World) NotifyAboutCollisions() {
|
||||
for i, entity := range w.Entities {
|
||||
for _, other := range w.Entities[i+1:] {
|
||||
for j, other := range w.Entities {
|
||||
if i == j {
|
||||
continue
|
||||
}
|
||||
if entity.CollisionShape().Overlaps(other.CollisionShape()) {
|
||||
entity.HandleCollisionEvent(other)
|
||||
other.HandleCollisionEvent(entity)
|
||||
|
||||
Reference in New Issue
Block a user