Program Flow

Repeat

Sets the start point of a repeating loop

Repeat Print "Hello World" Flip Forever

Forever

Causes the previously set Repeat point to loop forever.

Repeat Print "Hello World" Flip Forever


Operands

Comparison
<Returns a 1 if the left value is less than the right one, otherwise returns 0.
<=Returns a 1 if the left value is less or equal to the right one, otherwise returns 0.
>Returns a 1 if the left value is greater than the right one, otherwise returns 0.
>=Returns a 1 if the left value is greater or equal to the right one, otherwise returns 0.
==Returns a 1 if the left value is equal to the right one, otherwise returns 0.
Basic Maths
+Adds the left value to the right one.
-Subtracts the right value from the left one.
*Multiples the left and right values together.
/Divides the left value by the right one.
%Returns the remainder, after the left value is divided by the right one.
^Raises the left value to the power of the right one.
Constants
True1
False0
On1
Off0

Numbers

Int(value)

Returns the integer value of a string or float.

Print Int("17.6")

Float(value)

Returns the float value of a string.

Print Float("17.6")

Abs(value)

Returns the positive value of a number.

Print Abs(-123)

Neg(value)

Returns the negative value of a number.

Print Neg(123)

Round(value)

Returns the value of a number, rounded to the nearest whole number.

Print Round(123.4) Print Round(123.5) Print Round(123.6)

Floor(value)

Returns the value of a number, rounded down to the nearest whole number.

Print Floor(123.4) Print Floor(123.5) Print Floor(123.6)

Ceil(value)

Returns the value of a number, rounded up to the nearest whole number.

Print Ceil(123.4) Print Ceil(123.5) Print Ceil(123.6)

Sqrt(value)

Returns the square root of a number.

Print Sqrt(16) Print Sqrt(12345)

Pow(Number, Power)

Returns the power of Number, to the power of the Power. This can be replaced by using the "^" symbol.

Print Pow(4,2) Print Pow(4,4) Print 4^2 Print 4^4

Mills([since])

Returns the number of Milliseconds since either... 0 (default) - A default value, dependent on the Javascript implementation. May be "since Jan 1970", may be "since this morning", could be "since the browser was loaded", or even "since the device was booted". Honestly, could be anything!! 1 - Number of Milliseconds since that the program has been running.

Repeat CLS Print "Mills "+Mills() Print "Mills since Run "+Mills(1) Flip Forever

Frames()

Returns the number of frames that have been drawn since the program started.

Repeat CLS Print "Mills "+Mills() Print "Mills since Run "+Mills(1) Flip Forever


Trigonometry

Sin(angle in degrees)

Returns the Sine value of the given angle.

Repeat Print Sin(Mills()) Forever

Cos(angle in degrees)

Returns the Cosine value of the given angle.

Repeat Print Cos(Mills()) Forever

Tan(angle in degrees)

Returns the Tangent value of the given angle.

Repeat Print Tan(Mills()) Forever

Pyth(a,b)

Returns the Pythagoras result of the two numbers. Square Root of ((a*a)+(b*b))

Print Pyth(100,100) Print Pyth(200,100)

Distance(x1,y1, x2,y2)

Returns the Distance between the two points.

Text 100,100,"A",1 Text 200,200,"B",1 Text 400,300,"C",1 Text 150,140,"A to B",1 Text 150,160,Distance(100,100, 200,200),1 Text 300,240,"B to C",1 Text 300,260,Distance(200,200, 400,300),1


Random Numbers

Rand( min [,max] )

Generates a random integer between (and including) either 0 and Min, or Min and Max, depending on whether you include a Max value.

Print Rand(0,100) Print Rand(0,100) Print Rand(0,100) Print Rand(0,100)

Rnd( min [,max] )

Generates a random floating point number between (and including) either 0 and Min, or Min and Max, depending on whether you include a Max value.

Print Rnd(0,100) Print Rnd(0,100) Print Rnd(0,100) Print Rnd(0,100)

SeedRnd [Seed]

Seeds the random number generator with the given number. Using the same seed will produce the same set of pseudo-random numbers in the same order. If no number is given, Milliseconds is used as the seed, to give as random selection as possible.

SeedRnd Print "Random" Print Rand(0,100) Print Rand(0,100) Print Rand(0,100) SeedRnd Print "Random" Print Rand(0,100) Print Rand(0,100) Print Rand(0,100) SeedRnd 100 Print "Seeded" Print Rand(0,100) Print Rand(0,100) Print Rand(0,100)


Screen

Graphics Width,Height [,ScaleMode]

Sets the virtual resolution to the width and height requested. ScaleMode alters how the resolution is drawn to the screen. 0 = Direct, 1 to 1, and centered on the screen. 1 = Scaled to as large as it can be, and centered on the screen. 2 = Scaled, but also rejigged to fill the current browser's viewport. Use ScreenWidth() and ScreenHeight() to find out the actual size of the screen, based upon the current scale.

Graphics 512,512,1 Print "Hello World"

Antialias On/Off

Enables or Disables Antialiasing for future draw commands. Note that this is a per-draw command, not per-frame, so, for example, you could draw blurry antialiased backgrounds with crisp aliased sprites on top.

Graphics 512,512,1 SetScale 4,4 Antialias On DrawImage 128,256,0 AntiAlias Off DrawImage 384,256,0

CLS [ Red,Green,Blue[ ,Alpha]]

Clears the screen. You can additionally set Red, Green, Blue and Alpha values to clear the screen in a specific color.

Graphics 512,512 Print "Hello World" CLS

Flip

Draws the current frame to the screen. Use this at the end of every frame.

Graphics 512,512 Print "Hello World" Flip CLS Flip

ScreenWidth()

Returns the currently available drawing width. This should be the width set using the Graphic command, but when using Scale Mode 2, it will depend on the player's browser, its dimensions and its ratio.

Graphics 512,512,2 Print ScreenWidth()+","+ScreenHeight() Flip

ScreenHeight()

Returns the currently available drawing height. This should be the height set using the Graphic command, but when using Scale Mode 2, it will depend on the player's browser, its dimensions and its ratio.

Graphics 512,512,2 Print ScreenWidth()+","+ScreenHeight() Flip

ScreenRatio()

Returns the ratio of the currently available drawing area. This should be the ratio of the width and height set using the Graphic command, but when using Scale Mode 2, it will depend on the player's browser, its dimensions and its ratio.

Graphics 512,512,2 Print ScreenWidth()+","+ScreenHeight() Print ScreenRatio() Flip


Drawing Settings

ResetDraw

Resets all drawing settings to White, Full Alpha, 1 Scale, Font Size 12, and 0 Rotation.

SetColor 255,0,0 SetFontSize 50 Print "Test" ResetDraw Print "Test"

SetColor Red/255,Green/255,Blue/255 [,Alpha/1.0]

Sets the drawing color, using RGB values, for future drawing commands.

SetColor 255,0,0 Print "Hello World" SetColour 0,255,0 Print "Hello World" SetCol 0,0,255 Print "Hello World"

SetHue Hue/360,Saturation/1.0,Light/1.0 [,Alpha/1.0]

Sets the drawing color, using HSV values, for future drawing commands.

SetHue 0,1,1 Print "Hello World" SetHSV 120,1,1 Print "Hello World" InkRot 240,1,1 Print "Hello World"

SetAlpha Alpha/1.0

Sets the Alpha Transparency for future drawing commands.

SetAlpha 1 Print "Hello World" SetAlpha 0.6 Print "Hello World" SetAlpha 0.3 Print "Hello World"

SetScale XScale/1.0 [,YScale/1.0]

Sets the scale factor for future drawing commands. If the Y value is left out, the X value will be used to scale, squared.

SetScale 0.5 Text 250,80,"Scaled",1 Rect 100,40,20,20 SetScale 2.0 Text 250,180,"Scaled",1 Rect 100,140,20,20 SetScale 4,0.5 Text 250,280,"Stretched",1 Rect 100,240,20,20

SetRotation Rotation/360.0

Sets the Rotation for future drawing commands.

SetRot 0 Text 100,100,"Rot 0",100 SetRot 45 Text 300,100,"Rot 45",100 SetRot 90 Text 500,100,"Rot 90",100

SetThick Thickness

Sets the thickness for future drawing commands. Note that this thickness depends on the screen resolution, scaling and more, so probably shouldn't be assumed as being a specific number of pixels.

SetCol 255,255,0;SetThick 4 Line 100,100,400,120 SetCol 255,128,0; SetThick 8 Line 100,200,450,220 SetCol 0,128,255; SetThick 16 Line 100,300,500,320

SetFontSize Size

Sets the font size for future text commands. Note that this size depends on the screen resolution, scaling and more, so probably shouldn't be assumed as being a specific number of pixels.

SetFontSize 16 Print "Hello World" SetFontSize 32 Print "Hello World" SetFontSize 64 Print "Hello World"


Drawing Commands

Print String

Prints the requested string to the screen.

Print "Hello World!"

Text x,y,String [,Justification=0]

Draws text to the screen using the current drawing settings. The Justification shifts the text vertically. When 0, the X co-ordinate will be the left of the text. 1 will center the text. 2 will Right Justify the text.

SetCol 255,0,0 Text 200,100,"Red",0 SetCol 0,255,0 Text 200,200,"Green",1 SetCol 0,0,255 Text 200,300,"Blue",2

DrawImage X,Y,Sprite Number [,Recolour Setting]

Draws the requested image frame, centered at the specified co-ordinates. Alpha, Rotation and Scaling are accounted for, but due to Javascript being a bit rubbish at recolouring, any SetCol setting is ignored. Instead, the recolour value allows for 9 different recolourings of your sprite. 0 = Original (Red pixels in the sprite will be Red.) 1 = Hues offset by 30 degrees (Red = Orange) 2 = Hues offset by 60 degrees (Red = Yellow) 3 = Hues offset by 120 degrees (Red = Green) 4 = Hues offset by 210 degrees (Red = Cyan) 5 = Hues offset by 240 degrees (Red = Blue) 6 = Hues offset by 270 degrees (Red = Indigo) 7 = Hues offset by 330 degrees (Red = Purple) 8 = Light Grayscale 9 = Inverted Grayscale

Graphics 512,512,1 Antialias False // Switch to True for a blurry mess!! DrawImage 100,100,0 DrawImage 150,150,0 SetRot 45 DrawImage 200,200,0 SetScale 4,4 DrawImage 300,300,0

Line X1,Y1, X2,Y2

Draws a line between two points, using the current drawing settings.

SetCol 255,255,0;SetThick 4 Line 100,100,400,120 SetCol 255,128,0; SetThick 8 Line 100,200,450,220 SetCol 0,128,255; SetThick 16 Line 100,300,500,320

Rect X,Y,Width,Height [,Centered=0]

Draws a rectangle using the current drawing settings. You can alternatively use DrawRect to draw the outline of the rectangle.

SetCol 255,180,180 Rect 100,100,100,100 SetCol 180,255,180 DrawRect 300,100,100,100 SetCol 180,180,255 Rect 500,100,100,100,1

Oval X,Y,Width,Height

Draws an Oval using the current drawing settings. You can alternatively use DrawOval to draw the outline of the Oval.

SetCol 255,0,0 Oval 200,60,100,100 SetCol 255,128,0 DrawOval 200,180,100,100 SetCol 0,255,0 Oval 200,300,100,100

Triangle X,Y,Width,Height

Draws a Triangle using the current drawing settings. You can alternatively use DrawTriangle to draw the outline of the Triangle.

SetCol 255,255,0 Triangle 100,60,100,100 SetCol 255,128,0 DrawTriangle 200,180,100,100 SetCol 0,128,255 Triangle 300,300,100,100


System Commands

Debug String

Sends the requested string to the browser's console log.

Debug "Hello World!"


About JSE/FAQ's

JSE?

Jayenkai is the author of this scripting language, so he called it "Jay's Scripting Engine". If you prefer not to think of Jayenkai, you can think of it as being short for "Javascript Scripting Engine" or something like that.

License

Although I don't have a particular name for the license, we'll call it something like "This is here to be used. Feel free to use it. That's what it's here for."

Credits

JSE was started in February 2021 by Jayenkai : AGameAWeek.com He was helped in part by the members of the Socoder.net community, who assisted with a few RPN issues and general testing. The language uses absolute barebones Javascript and Canvas functions, which "should" function correctly in any decent browser, as of 2021.

Purpose

The intention of this scripting language is to allow easily accessible test or examples. The language was coded for the forum SoCoder.net, where we used to easily be able to use Blitz2D, Blitz3D, BlitzMax and Monkey as example languages. However, the world of wildly varied systems, OSes and "rules", as well as the fact that Blitz3D is now over 20 years old, have all made these things much more difficult to keep working. Simple examples just aren't simple, anymore. The purpose of JSE is to be easily copy and pasteable into forums, and back again, allowing users to code quick examples to show each other how to achieve certain techniques. Though the language "should" be capable enough to write a whole game in, please be aware that since Jayenkai wrote it, it'll likely fail in unexpected and seemingly random ways! Please don't rely on it to do amazing things!

Bugs/Errors

If you find something is broken, let Jayenkai know. You can email him, or post something over on SoCoder.net. Thanks for reporting any bugs!

Registration

There is no registration on the site. The site is here to be used. Though there are no cookies, in the traditional sense, there is a large set of "Local Storage" saves, one for each of your projects. If you're using a "Private Mode" browser, your code will be lost when the page is refreshed, so be aware that that'll happen. Be sure to copy+paste your code somewhere safe, if you are! No cookies, No evils, Just coding.

Load/Save

Loading and saving, symbols, projects and more, are all handled internally by your browser. If you change your browser, switch between systems, or more, your code will be stuck exactly where it was. You'll need to export it from the previous place, and import it back to the new one. (I'm writing this in the past, and haven't coded this yet, but hopefully I make it as painless as possible!!) To be on the safe side, please export your projects as often as you can, just incase your browser decides it's going to be a goit!

Could you not set up a Cloud based Load/Save system?

Quite possibly, but I'd need to add Registration, sign-ins, and all those ugly sorts of things. I'm also not 100% convinced that I can safely load/save to/from the cloud without inadvertently breaking things along the way. There are also all manner of security concerns, with all the uploads/downloads going on. Bah, humbug!

.. But I have Javascript disabled

Then you can't use the site. Sorry.