Removed Add() method from System interface, added 2D culling.

This commit is contained in:
Marvin Blum
2016-05-07 11:28:42 +02:00
parent 11cf7a9251
commit 80e5cb20f8
4 changed files with 123 additions and 41 deletions

View File

@@ -87,27 +87,23 @@ func (s *SpriteRenderer) Cleanup() {
}
// Adds sprite to the renderer.
func (s *SpriteRenderer) Add(actor interface{}) bool {
sprite, ok := actor.(*Sprite)
func (s *SpriteRenderer) Add(actor *Actor, pos *Pos2D, tex *Tex) bool {
id := actor.GetId()
if !ok {
return false
for _, sprite := range s.sprites {
if id == sprite.Actor.GetId() {
return false
}
}
s.sprites = append(s.sprites, *sprite)
s.sprites = append(s.sprites, Sprite{actor, pos, tex})
return true
}
// Removes sprite from renderer.
func (s *SpriteRenderer) Remove(actor interface{}) bool {
sprite, ok := actor.(*Sprite)
if !ok {
return false
}
return s.RemoveById(sprite.Actor.GetId())
func (s *SpriteRenderer) Remove(actor *Actor) bool {
return s.RemoveById(actor.GetId())
}
// Removes sprite from renderer by ID.