Skip to content

v0.0.7

Choose a tag to compare

@GappleCider GappleCider released this 11 Mar 01:34
· 93 commits to main since this release
47fe198

SunDrop V0.0.7

New Features:

Mapping

Use:

const map = new SUN.BasicMap([
 ['xxxxxxxxxxxx'],
 ['x          x'],
 ['x          x'],
 ['xxxxxxxxxxxx'],
],
{
  x: {
    color: 'green',
    drawStyle: 'fill',
    type: 'box',
    visible: true
},
'10x10'
)

Mapping is an easier way to mass create levels.

Parameters

SUN.BasicMap(Map, Dictionary/Key, ObjectSize)
Map

The map object is an array of arrays that contain a single string

Dictionary/Key

The Key object is a dictionary that contains a definition for each character in the map object

The values inside the key can include:

  • Color rgba, hex, hsl, etc. If no color is specified the color is automatically black.
    Draw Style (this tells the renderer if it should fill or stroke).

    • If the Draw Style is stroke, a value called stroke must put added.

      • The stroke value is a dictionary that can have two child values:

        • Color rgba, hex, hsl, etc. If no color is specified the color is automatically black.
          Width determines how wide the lineWidth should be. If no width is specified the width is automatically 1.

The value for type is a string that can be either:

  • Box or...
    Circle.

Visible is a boolean
Functions

  • There are only two functions for keys

    • moveX and moveY. They take in a single parameter: self. self contains the x, y, width, height, polygon. and props of the object. moveX and moveY must return the changed x and y position.

    x {
     /*Other Values*/
     moveX: (self) => {
       self.pos.x += 1
       return self.pos.x
      }
     moveX: (self) => {
       self.pos.y -= 1
       return self.pos.y
      }
    }

Camera

The Renderer translates the screen relative to the camera's position

const camera = new Camera()

camera.pos = {
  x: 70, 
  y: 70,
}

renderer.render(camera)

license
Copyright 2023 @GappleCider
MIT