Added JS engine.

This commit is contained in:
2021-09-18 00:39:00 -07:00
parent 9dd9ce7cbd
commit ef9137fabb
52 changed files with 547 additions and 35712 deletions

View File

@ -7,48 +7,48 @@
#include "sandboxscene.h"
framedtextmenu_t ftm;
scripter_t scripter;
bool sandboxSceneInit(sandboxscene_t *game) {
bool sandboxSceneInit(sandboxscene_t *game, engine_t *engine) {
assetFontLoad(&game->font, "fonts/opensans/OpenSans-Regular.ttf");
assetTextureLoad(&game->texture, "test_texture.png");
assetShaderLoad(&game->shader,
"shaders/textured.vert", "shaders/textured.frag"
);
menuitem_t *item;
framedTextMenuInit(&ftm, &game->font, &game->texture);
ftm.menu.grid.rows = 3;
item = textMenuAdd(&ftm.menu, "Option 1");
item->y = 0;
item = textMenuAdd(&ftm.menu, "Option 2");
item->y = 1;
item = textMenuAdd(&ftm.menu, "Option 3");
item->y = 2;
scripterInit(&scripter, engine);
assetScripterAppend(&scripter, "scripts/main.js");
scripterInvokeMethodSimple(&scripter, "init");
return true;
}
void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
cameraLookAt(&game->camera,
0, 0, 10,
0, 0, 0
);
cameraLookAt(&game->camera, 3,3,3, 0,0,0);
cameraOrtho(&game->camera,
0, engine->render.width,
engine->render.height, 0,
cameraPerspective(&game->camera, 45,
engine->render.width/engine->render.height,
0.01f, 1000.0f
);
// cameraLookAt(&game->camera,
// 0, 0, 10,
// 0, 0, 0
// );
// cameraOrtho(&game->camera,
// 0, engine->render.width,
// engine->render.height, 0,
// 0.01f, 1000.0f
// );
shaderUse(&game->shader);
shaderUseCamera(&game->shader, &game->camera);
framedTextMenuResize(&ftm, 400, 400);
framedTextMenuUpdate(&ftm, engine);
framedTextMenuRender(&ftm, &game->shader, 0, 0);
shaderUsePosition(&game->shader, 0,0,0, 0,0,0);
shaderUseTexture(&game->shader, &game->texture);
scripterInvokeMethodSimple(&scripter, "update");
}
void sandboxSceneDispose(sandboxscene_t *game) {
// scripterInvokeMethodSimple(&scripter, "dispose");
scripterDispose(&scripter);
}

View File

@ -18,7 +18,8 @@
#include "../../file/asset.h"
#include "../../file/xml.h"
#include "../../file/asset.h"
#include "../../script/scripter.h"
#include "../../ui/grid.h"
#include "../../ui/menu.h"
#include "../../ui/textmenu.h"
@ -29,9 +30,10 @@
* Initialize the sandbox scene test game.
*
* @param game Game to initialize.
* @param engine Engine to use during init.
* @return True if successful, otherwise false.
*/
bool sandboxSceneInit(sandboxscene_t *game);
bool sandboxSceneInit(sandboxscene_t *game, engine_t *engine);
/**
* Update a sandbox scene.