|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.golden.gamedev.object.SpriteGroup | +--com.golden.gamedev.genre.platform.PlatformGroup
SpriteGroup designed to fit platform game.
In standard sprite group, all registered sprites in the group is updated and rendered every game loop, collision check also checked with all sprites in the group.
In platform game, there are so many sprites,
for example: tile blocks, enemies, projectiles, etc.
If there are 10000 tile blocks in a platform game, for one player sprite,
we must check for 1 x 10000 = 10000 collision check.
If there are many projectiles fired by the player,
and many enemies standing in his way, the collision check
will be more than one million!
That's only for collision check, the sprites still have to be updated and
rendered every game loop.
Therefore PlatformGroup
is specially designed to hold
many sprites in platform game.
The mainly operation of this group is storing only a sprite that's
visible on screen.
All registered sprites is backed up, and only
on screen sprites
is updated, rendered, and check for it's collision.
Constructor Summary | |
PlatformGroup(String name)
|
|
PlatformGroup(String name,
int screenOffset)
|
|
PlatformGroup(String name,
int leftOffset,
int topOffset,
int rightOffset,
int bottomOffset)
|
Method Summary | |
int |
getAllSize()
|
Sprite[] |
getAllSprites()
Returns all registered sprite in this group, same as SpriteGroup.getSprites() . |
SpriteGroup |
getOnScreenGroup()
|
int |
getSize()
Returns total on screen sprites |
Sprite[] |
getSprites()
Returns on screen sprites |
void |
render(Graphics2D g)
Renders all sprites in this group. |
void |
setBackground(Background backgr)
|
void |
setComparator(Comparator c)
|
void |
setOnScreenGroup(SpriteGroup group)
|
void |
update()
Updates all sprites in this group. |
Methods inherited from class com.golden.gamedev.object.SpriteGroup |
add, add, clear, getActiveMember, getBackground, getComparator, getExpandFactor, getName, getScanFrequence, getShrinkFactor, remove, remove, reset, scanSprites, scheduleToScan, setExpandFactor, setName, setScanFrequence, setShrinkFactor, sort, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public PlatformGroup(String name, int leftOffset, int topOffset, int rightOffset, int bottomOffset)
public PlatformGroup(String name, int screenOffset)
public PlatformGroup(String name)
Method Detail |
public void update()
SpriteGroup
update
in class SpriteGroup
public void render(Graphics2D g)
SpriteGroup
render
in class SpriteGroup
public void setBackground(Background backgr)
setBackground
in class SpriteGroup
public void setComparator(Comparator c)
setComparator
in class SpriteGroup
public SpriteGroup getOnScreenGroup()
public void setOnScreenGroup(SpriteGroup group)
public Sprite[] getSprites()
getSprites
in class SpriteGroup
SpriteGroup.getSize()
public int getSize()
getSize
in class SpriteGroup
public Sprite[] getAllSprites()
SpriteGroup.getSprites()
.
public int getAllSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |