Skip to content

Sazix1337/CherryEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

CherryEngine

The 2D Game Engine written in JavaScript.

NEW UPDATE

Version 1.2
Added: TypeObjectError.js Changed: static methods are not static now, you should call method from class object

Documentation

First of all, you should import ../engine/Engine.js file.
In Engine.js you should fill APPLICATION_INFORMATION array required information.(not working yet)

Constructor

constuctor accepts only 1 parameter, thats the debug mode, value can be false or true

Functions

Create_$Object(SceneID, GameObjectID, type, textContent, x = 0, y = 0, sourceURL, color = "#000000") - Creates an object
SceneID - id of scene
GameObjectID - id of object
type - object type. Now engine has only three object types Text, Sprite and Image.
textContent - this var stores text that will be diplayed in text object type.
x - x position. (default 0)
y - y position. (default 0)
sourceURL - picture URL.
color - HEX color of object.

Set_$Border(GameObjectID, borderSize, borderColor, borderType, borderRadius) - Sets border

GameObjectID - id of object
borderSize - border size
borderColor - color of border
borderType - border type
borderRadius - border radius

Set_$BackGround(GameObjectID, bg) - Sets background
GameObjectID - id of object
bg - background color

Set_$Color(GameObjectID, color) - Sets text color
GameObjectID - id of object
color - color in hex

MoveX(GameObjectID, x = 0) - Move to X position
GameObjectID - id of object
x - x position. (default 0)

MoveY(GameObjectID, y = 0) - Move to Y position
GameObjectID - id of object
y - y position. (default 0)

Create_$Rect(SceneID, GameObjectID, x = 0, y = 0, height = '100px', width = '100px', borderSize = 1, borderColor = "#000000", borderType = 'solid', background = '#000000') - draw a rect

SceneID - id of scene
GameObjectID - id of object
x - x position. (default 0)
y - y position. (default 0)
height - height of rect. (default 100px)
width - width of rect. (default 100px)
borderSize - the size of border in px
borderColor - the color of border
borderType - the type of border(css)
background - the color of background

Create_$Circle(SceneID, GameObjectID, x = 0, y = 0, height = '100px', width = '100px', borderSize = 1, borderColor = "#000000", borderType = 'solid', background = '#000000') - draw a circle
SceneID - id of scene
GameObjectID - id of object
x - x position. (default 0)
y - y position. (default 0)
height - height of circle. (default 100px)
width - width of circle. (default 100px)
borderSize - the size of border in px
borderColor - the color of border
borderType - the type of border(css)
background - the color of background


Move(GameObjectID, x = 0, y = 0) - Moves *GameObject to x, and y position
GameObjectID - id of object
x - x position. (default 0)
y - y position. (default 0)

getByStaticId(staticID) - Gets *GameObject by static id(data-fixedid attr.)
staticID - The static id of *GameObject

Delete_$Object(GameObjectID) - Delete the *GameObject
GameObjectID - id of object

Object_$Rotate(GameObjectID, deg) - Rotates object
GameObjectID - id of object
deg - Degrees of rotation

Object_$RotateY(GameObjectID, deg) - Rotates object to Y
GameObjectID - id of object
deg - Degrees of rotation

Object_$RotateX(GameObjectID, deg) - Rotates object to X
GameObjectID - id of object
deg - Degrees of rotation

Object_$RotateZ(GameObjectID, deg) - Rotates object to Z
GameObjectID - id of object
deg - Degrees of rotation

Object_$Scale(GameObjectID, size) - Scales the *GameObject
GameObjectID - id of object
size - the size of scale(default: 1)

Object_$SetTransTime(GameObjectID, ms) - Sets the transition time to *GameObject
GameObjectID - id of object
ms - the time in ms

Object_$Layer(GameObjectID, ObjectLayer) - Change layer position for *GameObject
GameObjectID - id of object
ObjectLayer - the layer for *GameObject(default: 0)

Events.js

OnObjectClick(GameObjectID, callback) - Sets the listener for clicking the *GameObject
GameObjectID - The id of *GameObject
callback - function of event

OnMouseObjectHover(GameObjectID, callback) - Sets the listener for mouse hover on *GameObject
GameObjectID - The id of *GameObject
callback - function of event

OnMouseObjectExit(GameObjectID, callback) - Sets the listener for mouse leave from *GameObject
GameObjectID - The id of *GameObject
callback - function of event

Scene.js

Scene_$Create(SceneID, width, height, x, y) - Creates an new Scene for game
SceneID - the id of scene(string)
width - the width of scene
height - the height of scene
x - x position of scene
y - y position of scene

Scene_$Delete(SceneID) - Deletes the scene
SceneID - the id of scene(string)

Scene_$Layer(SceneID, SceneLayer) - Sets the layer of scene
SceneID - the id of scene(string)
SceneLayer - The layer of scene(default: 0)

Requests.js

$Post(url, data = {}) - Making post request
url - the url for request
data - the data of request(default: {})

$Get(url) - Making get request
url - the url for request

Co-Authored by: Kolyah35

About

The 2D Game Engine written on JavaScript.

Resources

Stars

Watchers

Forks

Packages

No packages published