Class: World

World(canvas)

Represents the game world.

Constructor

new World(canvas)

Creates an instance of World.
Parameters:
Name Type Description
canvas HTMLCanvasElement The canvas element to render the game.
Source:

Members

camera_x :number

The x-coordinate of the camera.
Type:
  • number
Source:

ctx :CanvasRenderingContext2D

The canvas rendering context.
Type:
  • CanvasRenderingContext2D
Source:

Methods

addObjectToMap(objects)

Adds an array of objects to the map.
Parameters:
Name Type Description
objects Array The objects to add to the map.
Source:

addToMap(mo)

Adds a single object to the map.
Parameters:
Name Type Description
mo Object The object to add to the map.
Source:

checkBottleObject()

Checks for collisions between the character and bottles.
Source:

checkCharacterEnemyCollision()

Checks for collisions between the character and enemies.
Source:

checkCharacterJumpingCollision()

Checks for collisions between the character and enemies when jumping.
Source:

checkCoinObject()

Checks for collisions between the character and coins.
Source:

checkCollision()

Checks for various types of collisions in the game.
Source:

checkThrowObject()

Checks if the character throws a bottle. The character can only throw a bottle if they are not hurt and have bottles available. The bottle is thrown only once per key press.
Source:

checkThrowableObjectCollision()

Checks for collisions between throwable objects and enemies.
Source:

draw()

Draws the game world on the canvas.
Source:

flipImage(mo)

Flips an image horizontally.
Parameters:
Name Type Description
mo Object The object to flip.
Source:

flipImageBack(mo)

Flips an image back to its original orientation.
Parameters:
Name Type Description
mo Object The object to flip back.
Source:

run()

Runs the game loop, checking for collisions and other game logic.
Source:

setWorld()

Sets the world reference for the character.
Source:

updateCharacterStatusBar()

Updates the character's status bar based on collisions with enemies.
Source: