1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-09-19 20:14:58 +00:00

added beep keyword

This commit is contained in:
boxgaming 2022-04-28 10:14:53 -05:00
parent c05c17b09e
commit b62c49fbc3
4 changed files with 19 additions and 7 deletions

View file

@ -35,19 +35,17 @@ CodeMirror.defineMode("qbjs", function(conf, parserConf) {
// TODO: adjust for QB
var atomWords = ['true', 'false', 'nothing', 'empty', 'null'];
var builtinFuncsWords = ['_alpha', '_alpha32', '_atan2', '_autodisplay', '_blue', '_blue32', '_continue', '_copyimage', '_cosh', '_d2r', '_delay', '_dest', '_dest',
var builtinFuncsWords = ['_alpha', '_alpha32', '_atan2', '_autodisplay', '_blue', '_blue32', '_continue', '_copyimage', '_cosh', '_d2r', '_delay', '_dest',
'_display', '_fontwidth', '_freeimage', '_green', '_green32', '_height', '_instrrev', '_limit', '_keyclear', '_keydown',
'_keyhit', '_loadimage', '_mousebutton', '_mouseinput', '_mousex', '_mousey', '_newimage', '_pi', '_printstring', '_printwidth',
'_putimage', '_r2d', '_red', '_red32', '_resize', '_resizewidth', '_resizeheight', '_rgb', '_rgba', '_rgb32', '_rgba32', '_round',
'_screenexists', '_sinh', '_sndclose', '_sndopen', '_sndplay', '_sndloop', '_sndpause', '_sndstop', '_sndvol',
'_title', '_trim', '_width', 'abs', 'asc', 'atn', 'chr', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'exp',
'_title', '_trim', '_width', 'abs', 'asc', 'atn', 'beep', 'chr', 'circle', 'cls', 'color', 'command', 'cos', 'cvi', 'cvl', 'exp',
'fix', 'hex', 'input', 'inkey', 'instr', 'int', 'lbound', 'left', 'lcase', 'len', 'line', 'locate', 'log', 'ltrim', 'mid', 'mki', 'mkl',
'oct', 'paint', 'point', 'preset', 'print', 'pset', 'right', 'rtrim', 'rnd', 'screen', 'shared', 'sgn', 'sin', 'sleep', 'space', 'sqr', 'str', 'swap', 'tan',
'timer', 'ubound', 'ucase', 'val',
'oct', 'paint', 'point', 'preset', 'print', 'pset', 'right', 'rtrim', 'rnd', 'screen', 'shared', 'sgn', 'sin', 'sleep', 'space', 'sqr',
'str', 'swap', 'tan', 'timer', 'ubound', 'ucase', 'val',
// QBJS-specific
'export', 'import']
//'alert', 'confirm', 'domadd', 'domcontainer', 'domcreate', 'domevent','domget', 'domgetimage', 'domremove', 'export',
//'from', 'prompt', 'import', 'storageclear', 'storageget', 'storagekey', 'storagelength', 'storageset', 'storageremove'];
'export', 'from', 'import']
var builtinConsts = ['gx_true', 'gx_false', 'gxevent_init', 'gxevent_update', 'gxevent_drawbg', 'gxevent_drawmap', 'gxevent_drawscreen',
'gxevent_mouseinput', 'gxevent_paintbefore', 'gxevent_paintafter', 'gxevent_collision_tile', 'gxevent_collision_entity',

12
qb.js
View file

@ -549,6 +549,18 @@ var QB = new function() {
return Math.atan(value);
};
this.sub_Beep = function() {
var context = new AudioContext();
var oscillator = context.createOscillator();
oscillator.type = "square";
oscillator.frequency.value = 780;
oscillator.connect(context.destination);
oscillator.start();
setTimeout(function () {
oscillator.stop();
}, 200);
};
this.func_Chr = function(charCode) {
return String.fromCharCode(charCode);
};

View file

@ -2553,6 +2553,7 @@ if (QB.halted()) { return; }
await sub_AddQBMethod( "FUNCTION", "Abs", False);
await sub_AddQBMethod( "FUNCTION", "Asc", False);
await sub_AddQBMethod( "FUNCTION", "Atn", False);
await sub_AddQBMethod( "SUB", "Beep", False);
await sub_AddQBMethod( "FUNCTION", "Chr$", False);
await sub_AddQBMethod( "SUB", "Circle", False);
await sub_AddQBMethod( "SUB", "Cls", False);

View file

@ -2714,6 +2714,7 @@ Sub InitQBMethods
AddQBMethod "FUNCTION", "Abs", False
AddQBMethod "FUNCTION", "Asc", False
AddQBMethod "FUNCTION", "Atn", False
addqbmethod "SUB", "Beep", False
AddQBMethod "FUNCTION", "Chr$", False
AddQBMethod "SUB", "Circle", False
AddQBMethod "SUB", "Cls", False