Class World
java.lang.Object
Screen
World
- Direct Known Subclasses:
Grid
World Class - Used to describe the screen of a pixel-based game
Subclass of a Screen, includes an ArrayList of Sprite objects
-
Constructor Summary
ConstructorsConstructorDescriptionWorld
(processing.core.PApplet p) World Constructor #3: Creates a default WorldWorld Constructor #2: Creates a World with no background imageWorld
(processing.core.PApplet p, String screenName, String movingBgFile, float scale, float x, float y) World Constructor #4 for Moveable Backgrounds Image can be scaled to be bigger so the background doesn't run out too quicklyWorld Constructor #1: Creates a World with the specificed background image -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a Sprite to the Worldvoid
addSpriteCopy
(Sprite sprite) Adds a copy of a Sprite to the Worldvoid
addSpriteCopyTo
(Sprite sprite, float x, float y) Adds a copy of a Sprite to a specific coordinate in the Worldvoid
addSpriteCopyTo
(Sprite sprite, float x, float y, float aSpeed) Adds a copy of an Animated Sprite to a specific coordinate in the Worldvoid
Removes all current Sprites from World (useful for restarting a level)getColliders
(Sprite checkSprite) Checks all Sprites for collisions with one specific Spriteint
getSprite
(int index) Gets a specific Sprite based on its indexvoid
Deprecated.void
Prints out list of SpritesremoveSprite
(int index) Removes a sprite from the World based on its index in the ArrayListvoid
removeSprite
(Sprite sprite) Removes a Sprite from the worldvoid
show()
Displays all World + Screen visualsvoid
Deprecated.void
Displays all the Sprites on the screenvoid
update()
Updates all Sprites in the World each cycleMethods inherited from class Screen
distToRightEdge, getBgImage, getIsMoveable, getLeftX, getName, getScreenTime, getScreenTimeSeconds, getTimeSince, getTopY, getTotalTime, moveBgXY, pause, resetTime, setBg, setLeftX, setName, setTopY, showBg, toString
-
Constructor Details
-
World
World Constructor #1: Creates a World with the specificed background image- Parameters:
p
- Processing appletscreenName
- String to track ScreensbgImg
- stationary background image
-
World
World Constructor #2: Creates a World with no background image- Parameters:
p
- Processing appletscreenName
- String to track Screens
-
World
public World(processing.core.PApplet p) World Constructor #3: Creates a default World- Parameters:
p
- Processing applet
-
World
public World(processing.core.PApplet p, String screenName, String movingBgFile, float scale, float x, float y) World Constructor #4 for Moveable Backgrounds Image can be scaled to be bigger so the background doesn't run out too quickly- Parameters:
p
- Processing appletscreenName
- String to track ScreensmovingBgFile
- filename for the background image to movescale
- float that multiplies the size of the image to displayx
- sets the initial left edge of the backgroundy
- sets the intial top edge of the background
-
-
Method Details
-
getSprites
- Returns:
- ArrayList
all Sprites added to the World
-
addSprite
Adds a Sprite to the World- Parameters:
sprite
-
-
addSpriteCopy
Adds a copy of a Sprite to the World- Parameters:
sprite
-
-
addSpriteCopyTo
Adds a copy of a Sprite to a specific coordinate in the World- Parameters:
sprite
-x
-y
-
-
addSpriteCopyTo
Adds a copy of an Animated Sprite to a specific coordinate in the World- Parameters:
sprite
-x
-y
-aSpeed
-
-
getNumSprites
public int getNumSprites()- Returns:
- int number of Sprites in a World
-
getSprite
Gets a specific Sprite based on its index- Parameters:
index
- order that a Sprite was added to the World- Returns:
- Sprite
-
removeSprite
Removes a Sprite from the world- Parameters:
sprite
-
-
removeSprite
Removes a sprite from the World based on its index in the ArrayList- Parameters:
index
- order that a Sprite was added to the World- Returns:
- Sprite
-
clearAllSprites
public void clearAllSprites()Removes all current Sprites from World (useful for restarting a level) -
showWorldSprites
public void showWorldSprites()Displays all the Sprites on the screen -
showSprites
Deprecated. -
show
public void show()Displays all World + Screen visuals -
printWorldSprites
public void printWorldSprites()Prints out list of Sprites -
printSprites
Deprecated. -
getColliders
Checks all Sprites for collisions with one specific Sprite- Parameters:
checkSprite
- Sprite to compare all others to- Returns:
- ArrayList
all the Sprites that are currently colliding with a specific Sprite
-
update
public void update()Updates all Sprites in the World each cycle
-