Skip to content

Commit

Permalink
feat: revision 0.0.15 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles authored Nov 27, 2024
1 parent df4275c commit 981b4b8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"funding": "https://github.com/sponsors/RodrigoDornelles",
"bugs": "https://github.com/gamelly/gly-ide/issues",
"devDependencies": {
"@gamely/core-native-html5": "^0.0.10",
"@gamely/gly-engine": "^0.0.10",
"@gamely/core-native-html5": "^0.0.15",
"@gamely/gly-engine-lite": "^0.0.15",
"copy-webpack-plugin": "11.0.0",
"css-loader": "6.7.3",
"html-webpack-plugin": "5.5.0",
Expand Down
4 changes: 2 additions & 2 deletions src/default.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
std.draw.clear(std.color.blue)
std.draw.color(std.color.white)
std.draw.font(48)
std.draw.text(8 , 8, 'Hello world!')
std.text.font_size(std.app.width/8)
std.text.print(8 , 8, 'Hello world!')
6 changes: 4 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="UTF-8" />
<meta name="description" content="Tente Lua online" />
<link rel="icon" type="image/png" href="./assets/logo.png" />
<title>IDE - Gly Game Engine</title>
<link rel="icon" type="image/png" href="./assets/logo-gly.png" />
<title>Gly Image Generator</title>
<link rel="preload" href="/assets/CascadiaMono.ttf" as="font" type="font/ttf" crossorigin />
<style>
@font-face {
Expand All @@ -30,8 +30,10 @@ <h1>tool-img-gen</h1>
<div id="buttons">
<form>
<select id="resolution" name="resolution">
<option value="48x48">32x32</option>
<option value="48x48">48x48</option>
<option value="80x80">80x80</option>
<option value="128x128">128x48</option>
<option value="128x128">128x128</option>
<option value="256x256">256x256</option>
<option value="512x512" selected>512x512</option>
Expand Down
30 changes: 18 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import wasmFile from 'wasmoon/dist/glue.wasm';
import { LuaFactory, LuaMultiReturn } from 'wasmoon'
import { editor } from 'monaco-editor'
import gly from '@gamely/core-native-html5'
import gly_engine from '@gamely/gly-engine/dist/main.lua'
import gly_engine from '@gamely/gly-engine-lite/dist/main.lua'
import defaultScript from './default.lua'

let monacoTimeout;
Expand Down Expand Up @@ -30,11 +30,6 @@ document.addEventListener('DOMContentLoaded', async () => {
const lua = await factory.createEngine()
await lua.doString(gly_engine)

gly.global.set('native_callback_init', lua.global.get('native_callback_init'))
gly.global.set('native_callback_loop', lua.global.get('native_callback_loop'))
gly.global.set('native_callback_draw', lua.global.get('native_callback_draw'))
gly.global.set('native_callback_resize', lua.global.get('native_callback_resize'))
gly.global.set('native_callback_keyboard', lua.global.get('native_callback_keyboard'))
lua.global.set('native_draw_start', gly.global.get('native_draw_start'))
lua.global.set('native_draw_flush', gly.global.get('native_draw_flush'))
lua.global.set('native_draw_clear', gly.global.get('native_draw_clear'))
Expand All @@ -46,19 +41,30 @@ document.addEventListener('DOMContentLoaded', async () => {
lua.global.set('native_dict_http', gly.global.get('native_dict_http'))
lua.global.set('native_dict_json', gly.global.get('native_dict_json'))
lua.global.set('native_dict_poly', gly.global.get('native_dict_poly'))
lua.global.set('native_draw_text', (x, y, text) => {
const native_draw_text = gly.global.get('native_draw_text')
lua.global.set('native_text_print', gly.global.get('native_text_print'))
lua.global.set('native_text_font_size', gly.global.get('native_text_font_size'))
lua.global.set('native_text_font_name', gly.global.get('native_text_font_name'))
lua.global.set('native_text_font_default', gly.global.get('native_text_font_default'))
lua.global.set('native_text_font_previous', gly.global.get('native_text_font_previous'))
lua.global.set('native_text_mensure', (x, y, text) => {
const native_draw_text = gly.global.get('native_text_mensure')
return LuaMultiReturn.from(native_draw_text(x, y, text))
})

await lua.doString(gly_engine)

gly.global.set('native_callback_init', lua.global.get('native_callback_init'))
gly.global.set('native_callback_loop', lua.global.get('native_callback_loop'))
gly.global.set('native_callback_draw', lua.global.get('native_callback_draw'))
gly.global.set('native_callback_resize', lua.global.get('native_callback_resize'))

gly.error('canvas')
gly.init('#gameCanvas')
gly.init(elCanvas)

const apply = () => {
const code = monacoEditor.getValue()
gly.load(`return {draw=function(std)\nprint('oi')\n${code}\nend}`)
elCanvas.width = elInpWidth.value;
elCanvas.height= elInpHeight.value;
gly.load(`return {init=function()end,loop=function()end,draw=function(std)\n${code}\nend}`)
gly.resize(elInpWidth.value, elInpHeight.value)
window.requestAnimationFrame(gly.update)
}

Expand Down

0 comments on commit 981b4b8

Please sign in to comment.