Program Flow
If (condition) Then (code to execute)
Executes the code on the line, if the condition is met.
Does not execute the code if the condition is false.
Print "Hello"
If Rand(1,3)==1 then Print "One in Three Chance"
If Rand(1,6)==1 then Print "One in Six Chance"
If Rand(1,12)<7 then Print "One in Two Chance"
If (condition) ... (code to execute) ... Endif
Executes the code inbetween the If and the Endif, if the condition is met.
Does not execute the code if the condition is false.
If/Endif sections may be nested for added complexity.
Print "Hello"
If Rand(1,3)==1
Print "One in Three Chance"
If Rand(1,2)==1
Print "You're having a lucky day!"
Endif
Endif
If (condition) ... (code to execute) ... Else ... (alternative code) ... Endif
Executes the code inbetween the If and the Else, if the condition is met.
If the condition is untrue, the code between Else and Endif is executed, instead.
If/Else/Endif sections may be nested for added complexity.
Print "Hello"
If Rand(1,3)==1
Print "One in Three Chance"
If Rand(1,2)==1
Print "You're having a lucky day!"
Else
Print "Is this luck?"
Endif
Else
Print "Sorry, it isn't your lucky day."
Endif
For variable=start To end [Step n] ... Next
Creates a loop between For and Next, which increases the variable named, starting at start and ending the loop once the end value has been reached.
By default the variable is increased by 1 at the end of each loop, however an additional Step size can be added to increase or decrease the variable at the given rate.
For n=2 To 8 Step 2
Print n
Next
Print "Who do we appreciate?"
Continue
Stops code execution for the rest of the current for-loop, and moves on to the next iteration of the loop.
For n=1 to 10
if n==5 then Print "Alive!":Continue
Print "Number "+n
Next
Exit [Number of exits=1]
Alternative Spellings : Break
Stops code execution for the rest of the current for-loop, and then exits the loop entirely.
You may additionally add a parameter to break out of multiple layers of loops.
For n=1 to 10
if n==5 then Exit
Print "Number "+n
Next
Print "Alive!"
Print
For n=1 to 10
For m=1 to 10
Write m+":"+n+" "
if m==5 and n==5 then Exit(2)
Next
Print
Next
Print "Exited at 5:5"
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
Until (condition!=0)
Causes the previously set Repeat point to loop until a condition is met.
m=0
Repeat
m=m+1
Print "Hello World "+m
Flip
Until m>9
Wait (seconds)
Freezes the program for the requested number of seconds.
You may use floating-point values for more precision, with the lowest value being around 0.016
Repeat
Print "Hello Second"
Flip
Wait 1
Forever
Goto Label
Jumps to the label given.
Labels can be defined using either a @, . or # at the start of a line.
In addition, for added retroness, you can type in line numbers and use those instead.
10 Print "Hello World"
20 Goto 10
Gosub Label
Jumps to the label given, with the option to "Return" at a later point.
Labels can be defined using either a @, . or # at the start of a line.
In addition, for added retroness, you can type in line numbers and use those instead.
5 Graphics 512,512,0
10 Print "Hello World"
11 a=Rand(1,10)
12 if a==1 then Gosub SmileBASICStyleLabel
13 if a==3 then Gosub BlitzStyleLabel
14 if a==5 then Gosub BMaxStyleLabel
15 if a==7 then Gosub 30
16 Wait 0.1
20 Goto 10
30 Print "Hello >> Line Thirty"; Return
@SmileBASICStyleLabel
Print "Hello >> SmileBASIC";Return
.BlitzStyleLabel
Print "Hello >> Blitz";Return
#BMaxStyleLabel
Print "Hello >> BlitzMax";Return
Return
Returns to the point of the previous Gosub command.
Print "Hello"
Gosub There
Print "Fin"
End
.There
Print "Oooh"
Return
End
Ends the program.
Repeat
CLS
Print Mills()
If MouseDown()>0 then End
Flip
Forever
Inkey
Returns the character of the last pressed key on the keyboard.
Note that using this command will flush the current keyboard buffer. (But that's ok, 'cos I currently haven't coded anything else to use it yet!!)
Graphics 512,512,1
LastKey=" "; Typed=""
Repeat
CLS 30,30,80,0.2
ThisKey=Inkey()
if ThisKey!="" then LastKey=ThisKey:Typed=Right$(Typed+LastKey,32)
if ThisKey=="" then ThisKey=" "
SetFontSize 32
Text 256,200,"Current Key "+ThisKey,2
Text 256,150,"Previous Key "+LastKey,2
SetFontSize 24
Text 256,100,Typed,2
Flip
Forever
KeyDown(Key value)
Returns whether the key is currently held or not.
Most scancodes are equivalent to a key's ASCII value, but .. not all keys work like that.
Also be aware that different keyboard layouts (eg AZERTY), as well as different System/Browser configurations, will likely mess these codes up quite a bit.
Additionally, some key results change when you hold shift, whilst others don't. It's all a bit of a mess, really.
Basically, this command shouldn't be relied upon.
Please try to use the Gamepad functions wherever possible.
// KeyDown Tester
// by Jayenkai
// Created 2021/7/1
Graphics 820,480,1
SetFontSize 12
Repeat
CLS
for x=0 to 15
for y=0 to 7
k=(y*16)+x
dx=(x+0.5)*51
dy=(y+0.5)*51
SetCol 255,255,255:Rect dx,dy,50,50,1
SetCol 0,0,0
if KeyDown(k) then SetCol 40,80,120
Rect dx,dy,46,46,1
SetCol 255,255,255
Text dx,dy-10,k,1
Text dx,dy+10,Chr$(k),1
next
next
if KeyDown(Asc("G")) then Text ScreenWidth()/2,ScreenHeight()-32,"HOLDING G!",1
Flip
Forever
WaitKey/WaitMouse/WaitGamepad/WaitAny
Waits for an event before moving on.
WaitMouse waits for a click.
WaitKey waits for a keypress.
WaitGamepad waits for a button (not dpad or thumbstick)
WaitAny waits for any of the above.
Note : To reduce the possibility of your program locking up on mobile devices, WaitKey and WaitGamepad will also register a touchscreen tap.
Print "Click the Mouse"
WaitMouse
Print "Woot!"
Print
Print "Hit a key"
WaitKey
Print "Woot!!"
Print
Print "Tap a gamepad button"
WaitGamePad
Print "Woot!!!"
Print
Print "Now do anything!"
WaitAny
Print "Woot!!!!!!"
MouseHit/KeyHit/GamepadHit
Returns true if the Mouse, Keyboard or a Gamepad Face Button have been hit since the last check.
The value will then instantly reset to 0, so be sure to store it in a variable if you're using it in a few places.
Note : To reduce the possibility of locking up on mobile devices, KeyHit and GamepadHit will also register a touchscreen tap.
Graphics 512,512,1
Repeat
CLS
If MouseHit() then sizea=96
sizea=sizea-10
If sizea<32 then sizea=32
Rect 85,256,sizea,sizea,1
Text 85,320,"MouseHit",1
If KeyHit() then sizeb=96
sizeb=sizeb-10
If sizeb<32 then sizeb=32
Rect 256,256,sizeb,sizeb,10
Text 256,320,"KeyHit",1
If GamepadHit() then sizec=96
sizec=sizec-10
If sizec<32 then sizec=32
Rect 425,256,sizec,sizec,1
Text 425,320,"GamepadHit",1
Flip
Forever
Mouse |
MouseX() | Returns a scaled Mouse's X co-ordinate. Add a 1 value to track the true co-ordinates. |
MouseY() | Returns a scaled Mouse's Y co-ordinate. Add a 1 value to track the true co-ordinates. |
MouseDown() | Returns whether the left mouse button is clicked. |
MDown() | An alternative to MouseDown() |
Touch |
TouchX(0-9) | Returns the scaled co-ordinates of a finger on the touchscreen. Use TouchDown(n) to tell if the finger's onscreen or not. |
TouchY(0-9) | Returns the scaled co-ordinates of a finger on the touchscreen. Use TouchDown(n) to tell if the finger's onscreen or not. |
TouchDown(0-9) | Returns whether the numbered finger is onscreen or not. |
Graphics 512,512,1
Repeat
CLS 60,60,60; ResetDraw
Print
Print "Scaled Mouse Co-Ordinates"
Print MouseX()+","+MouseY()
Print
Print "Real Mouse Co-Ordinates"
Print MouseX(1)+","+MouseY(1)
Print
Print "Mouse Button "+MouseDown()
SetFontSize(64)
Text MouseX(),MouseY(),MDown(),1
Flip
Forever
MouseIn(x,y,width,height,centered)
Alternative spellings : MouseInRectMouseIn_Rect
Returns 1 if the mouse (or a touch) is inside the rectangular area.
Graphics 512,512,1
Repeat
CLS
SetCol(30,30,80)
if MouseIn(256,256,150,200,1)==1
SetCol(80,80,180)
if MouseDown() then SetCol(180,80,80)
endif
Rect 256,256,150,200,1
Flip
Forever
MouseInCircle(x,y,diameter)
Alternative Spellings : MouseIn_Circle,MouseIn_Radius
Returns 1 if the mouse (or a touch) is inside the circular area.
Graphics 512,512,1
Repeat
CLS
SetCol(30,30,80)
if MouseInCircle(256,256,250)==1
SetCol(80,80,180)
if MouseDown() then SetCol(180,80,80)
endif
Oval 256,256,250,250,64
Flip
Forever
Gamepad(button,[ port])
Returns a value based on the requested Gamepad input.
Ports 0 to 3 are the four default gamepad ports. A player should tap the A-Button on a controller before it is available to the engine.
Port 4 is a quick and dirty keyboard input.
WASD or Cursors are available as directions,
Z or K as Button A,
J or X as Button B,
L or C as Button Y,
I or V as Button X.
Return works as the Start button, B as the Back/Select button, and U and O (or N and M) work as the left and right triggers.
Port 5 is for onscreen controls.
There's a thumbpad on the bottom left, which registers as both analogue and a DPad.
There are also (at the time of writing) two buttons on the right, for A and B.
Port -1 (Default) contains an amalgamation of all of the controllers, linked into a single one.
If you're making single player games, this is probably the best option.
Whatever control method the player's using, it should mostly all work with your controller code.
Please note, the layout of some of the buttons might be incorrect, depending on the browser's configuration and the type of controller being used.
Graphics 640,640,1
Repeat
CLS
ang=360/7
port=0-1
Repeat
desc=""
dx=320+(Sin((port+1)*ang)*200)
dy=320-(Cos((port+1)*ang)*200)
If port==(0-1) then desc="Everything Combined"
If port==4 then desc="Keyboard"
If port==5 then desc="Onscreen Controls"
Text dx,dy-48,"Port "+port,1
Text dx,dy-36,desc,1
// Combined DPad and Left Thumbstick
SetCol 255,255,128;Oval dx+((GamePad(ButtonRight,port)-GamePad(ButtonLeft,port))*16),dy+((GamePad(ButtonDown,port)-GamePad(ButtonUp,port))*16),20,20,8
// Just the DPad
SetCol 255,255,255;Oval dx+((GamePad(DPadRight,port)-GamePad(DpadLeft,port))*50),dy+((GamePad(DPadDown,port)-GamePad(DPadUp,port))*50),16,16,3
// Left Thumbstick
SetCol 255,128,255;Oval dx+(GamePad(StickLX,port)*16)-64,dy+(GamePad(StickLY,port)*16)+24,18,18,8
// Right Thumbstick
SetCol 128,255,255;Oval dx+(GamePad(StickRX,port)*16)+64,dy+(GamePad(StickRY,port)*16)+24,16,16,8
// Face Buttons
s=4+(GamePad(ButtonA,port)*8);SetCol 0,255,0;Oval dx-18,dy+16,s,s,8
s=4+(GamePad(ButtonB,port)*8);SetCol 255,0,0;Oval dx-6,dy+16,s,s,8
s=4+(GamePad(ButtonY,port)*8);SetCol 64,64,255;Oval dx+6,dy+16,s,s,8
s=4+(GamePad(ButtonX,port)*8);SetCol 255,255,0;Oval dx+18,dy+16,s,s,8
// Triggers
s=4+(GamePad(ButtonL1,port)*8);SetCol 255,255,255;Oval dx-18,dy-16,s,s,8
s=4+(GamePad(ButtonR1,port)*8);SetCol 255,255,255;Oval dx+18,dy-16,s,s,8
s=4+(GamePad(ButtonL2,port)*8);SetCol 255,255,255;Oval dx-24,dy-24,s,s,8
s=4+(GamePad(ButtonR2,port)*8);SetCol 255,255,255;Oval dx+24,dy-24,s,s,8
// Start and Select/Back
s=4+(GamePad(ButtonStart,port)*8);SetCol 255,255,255;Oval dx+32,dy,s,s,8
s=4+(GamePad(ButtonSelect,port)*8);SetCol 255,255,255;Oval dx-32,dy,s,s,8
port=port+1
Until port>5
Flip
Forever
GamepadDistance(input,[ port])
Alternative Spellings : GamepadDist
Returns a value for how far from the center, the dpad or thumbstick has been moved.
input=0 will return both the dpad and the left thumbstick.
input=1 will return the dpad.
input=2 will return the left thumbstick.
input=3 will return the right thumbstick.
Ports are the same as those found in the Gamepad Command.
GamepadAngle(input,[ port])
Alternative Spellings : GamepadAng
Returns a value for the current angle of the dpad or thumbstick.
input=0 will return both the dpad and the left thumbstick.
input=1 will return the dpad.
input=2 will return the left thumbstick.
input=3 will return the right thumbstick.
Ports are the same as those found in the Gamepad Command.
Graphics 512,512,1
Dim pos(3,2)
For x=0 to 3
pos(x,1)=256
pos(x,2)=256
Next
Repeat
CLS
For x=0 to 3
d=GamePadDist(x)
a=GamePadAng(x)
If d>0.25
pos(x,1)=pos(x,1)+Sin(a)*d*4
pos(x,2)=pos(x,2)-Cos(a)*d*4
Endif
Oval pos(x,1),pos(x,2),16,16,16
Next
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. |
!= or >< | Returns a 1 if the left value is not 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. |
% or Mod | Returns the remainder (Modulus), after the left value is divided by the right one. |
^ or Pow | Raises the left value to the power of the right one. |
<< or shl | Shifts the bits of the left value, left, by the number of the right one. |
>> or shr | Shifts the bits of the left value, right, by the number of the right one. |
Constants |
True | 1 |
False | 0 |
On | 1 |
Off | 0 |
Pi | The value of Pi to the number of decimal places that the player's system and browser configuration allows for. |
Variables
Swap(a,b)
Swaps the values of variables a and b.
a="World":b="Hello"
Swap(a,b)
Print a+" "+b
Arrays
Dim ArrayName(ArraySize[, 2nd Dimension, 3rd Dimension, 4th Dimension])
Defines up a variable name as an Array, and defines the number of elements within. You can additionally add limits for 2nd, 3rd and 4th dimensions of the array.
Dim Name(4)
Dim Age(4)
i=0
Name(i)="Jay"; Age(i)=DateYear-1980; i=i+1
Name(i)="Platdude"; Age(i)=DateYear-1998; i=i+1
Name(i)="Greenie"; Age(i)=DateYear-1908; i=i+1
Name(i)="Spike"; Age(i)=DateYear-2010; i=i+1
Print Left(Name(3)+(" "*8),8)+" : "+Age(3)
Print Left(Name(1)+(" "*8),8)+" : "+Age(1)
Print Left(Name(0)+(" "*8),8)+" : "+Age(0)
Print Left(Name(2)+(" "*8),8)+" : "+Age(2)
Explode(string, separator, array)
Splits a string into chunks, using the requested separator, and places the result into the array. The command will return the number of chunks that have been found.
Note : The array must have already been declared, or the command will fail.
Txt="This is a string that I want to be split into individual words."
Dim SplitArray(50)
Count=Explode(Txt," ",SplitArray);
For n=0 to Count
Print SplitArray(n)
Next
Join(Array[, JoinWith, start, finish])
Takes the values in Array, and joins them together into a single string.
JoinWith can be any string, used to join chunks together.
Dim MyArray(10)
MyArray(0)="This"
MyArray(1)="is"
MyArray(2)="a"
MyArray(3)="String"
MyArray(4)="Joining"
MyArray(5)="example."
Txt=Join(MyArray," ",0,5)
Print Txt
EmptyArray(Array[, Value ] )
Resets all values of an array to 0, or the value specified.
Dim MyArray(2)
MyArray(0)="Everything"
MyArray(1)="Goes"
MyArray(2)="Away"
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
EmptyArray(MyArray)
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
EmptyArray(MyArray,"Banana")
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
ReverseArray(Array)
Reverses the order of a single-dimensional array.
Dim MyArray(2)
MyArray(0)="backwards"
MyArray(1)="is"
MyArray(2)="Everything"
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
ReverseArray(MyArray,1)
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
SortArray(Array,Order)
Sorts a single-dimensional array.
Order can be 0 for low to high, or 1 for high to low.
Dim MyArray(2)
MyArray(0)="Sort"
MyArray(1)="Order"
MyArray(2)="Ascend"
SortArray(MyArray)
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
SortArray(MyArray,1)
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
ShuffleArray(Array)
Shuffles a single-dimensional array.
Dim MyArray(2)
MyArray(0)="Shuffle"
MyArray(1)="Swap"
MyArray(2)="Jumble"
for m=0 to 20
ShuffleArray(MyArray)
Print MyArray(0)+" "+MyArray(1)+" "+MyArray(2)
next
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,[places=0])
Alternative spellings : DecimalPlaces
,
ToDecimalPlaces
Returns the value of a number, rounded to the nearest whole number, or decimal places requested.
Print Round(123.4)
Print Round(123.5)
Print Round(123.6)
Print Round(123.455,1)
Print Round(123.456,2)
Print Round(123.456,3)
Sgn(value)
Returns 1 if a number is positive, -1 if the number is negative or otherwise 0.
Print Sgn(100)
Print Sgn(-100)
Print Sgn(0)
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)
Trunc(value)
Returns the value of a number, truncated to an integer, without any rounding whatsoever.
Print Trunc(123.4)
Print Trunc(123.5)
Print Trunc(123.6)
Limit(value,lowest,highest)
Ensures a value is between Lowest and Highest, making it equal to the limit when beyond it.
x=256
Repeat
CLS
x=x+(GamePad(ButtonRight)-Gamepad(ButtonLeft))*2.5
x=Limit(x,100,412)
Text x,256,"O",1
Text 32,32,Floor(x),0
Flip
Forever
Wrap(value,lowest,highest)
Ensures a value is between Lowest and Highest, wrapping the number around, when outside the limit.
x=256
Repeat
CLS
x=x+(GamePad(ButtonRight)-Gamepad(ButtonLeft))*2.5
x=Wrap(x,100,412)
Text x,256,"O",1
Text 32,32,Floor(x),0
Flip
Forever
Min(value 1, value 2, [value 3--8])
Returns the lowest value of the given numbers. Only works with 8 maximum values.
Graphics 512,512,1
Print Min(7,3,5,60,6,66,2,1)
Max(value 1, value 2, [value 3--8])
Returns the Highest value of the given numbers. Only works with 8 maximum values.
Graphics 512,512,1
Print Max(7,3,5,60,6,66,2,1)
AddThreshold(value,subvalue,amount,[lowest=-0.5,[highest=0.5]])
Adds amount to subvalue. If subvalue is above the highest threshold, removes the total from subvalue and adds it to value.
This sounds extremely odd, but is actually really handy for moving objects around a tilemap, so that the main value is always a grid reference.
Graphics 512,512,1
px=8;pox=0
py=8;poy=0
Repeat
CLS;ResetDraw
pxs=GamePad(ButtonRight)-GamePad(ButtonLeft)
pys=GamePad(ButtonDown)-GamePad(ButtonUp)
px=AddThreshold(px,pox,pxs*0.1)
py=AddThreshold(py,poy,pys*0.1)
SetCol(96,96,96)
Rect px*32,py*32,32,32,1
SetCol(255,255,255)
Print px+":"+DecimalPlaces(pox,2)+" "+py+":"+DecimalPlaces(poy,2)
Oval (px+pox)*32,(py+poy)*32,16,16,16
Flip
Forever
Between(value,lowest,highest)
Returns true (1) if the value is between or equal to the lowest and highest values, otherwise returns false (0)
x=256
Repeat
CLS
x=x+(GamePad(ButtonRight)-Gamepad(ButtonLeft))*2.5
Text x,256,"O",1
Text 32,32,Floor(x),0
If Between(x,100,412) then Text 32,64,"Between",0
Flip
Forever
WrapTo(Value, Target Value, Low, High)
Alternative spellings : WhichWayDoIGo
Determines the quickest way to get from A to B, whilst taking Wrapping into account.
eg, if two points are on the ground on a wrapping screen, is it quicker to move across the whole screen, or is it quicker to go the other way and wrap around the screen?!
// WrapTo Chase
// by Jayenkai
// Created 2021/6/10
Me=0
Baddy=180
Graphics 512,512,1
Repeat
CLS 30,30,80; ResetDraw
// Circle
For ang=0 to 35 // Circle of Dots
dx=256+Sin(ang*10)*200:dy=256-Cos(ang*10)*200
Rect dx,dy,8,8,1
If MouseIn(dx,dy,32,32) then Me=ang*10
Next
// Me
SetCol 255,128,0
Oval 256+Sin(Me)*200,256-Cos(Me)*200,32,32
// Baddy
SetCol 30,140,255
Oval 256+Sin(Baddy)*200,256-Cos(Baddy)*200,24,24
// Baddy Movement
Direction=WrapTo(Baddy,Me,0,360) // Find the shortest distance from Baddy to me, taking wrapping into account
// eg, whether it's shorter going clockwise or anticlockwise.
Direction=Limit(Direction,-4,4) // Limit the direction's speed.
Baddy=Wrap(Baddy+Direction,0,360) // Wrap the result.
Flip
Forever
SmoothTo(Value, Target Value[, Smooth Amount=8, Lock Amount=0.25])
Takes the value and divides the difference between Value and Target by Smooth.
If Value is close to Target (by Lock Amount) then Value will equal Target
x=256;y=256
Repeat
CLS 30,30,80,0.5
If MouseX()>-1 then x=SmoothTo(x,MouseX(),16,2);y=SmoothTo(y,MouseY(),16,2)
Oval x,y,16,16
Text x+16,y-16,Floor(x)+","+Floor(y)
Text MouseX()-16,MouseY()+16,Floor(MouseX())+","+Floor(MouseY()),2
Flip
Forever
Sqrt(value)
Alternative spellings : Sqr(value)
Returns the square root of a number.
Print Sqrt(16)
Print Sqrt(12345)
Power(Number, Power)
Returns the power of Number, to the power of the Power.
This can be replaced by using the "^" maths symbol.
Print Power(4,2)
Print Power(4,4)
Print 4^2
Exp(Number)
Returns the value of e to the power of Number, where e is Euler's Number.
Print Exp(0)
Print Exp(1)
Print Exp(2)
Log(Number)
Returns the returns the natural logarithm of Number.
Print Log(625)/Log(5)
Log10(Number)
Returns the base 10 logarithm of Number.
Print Log10(100000)
Powers(A,B)
Returns the number of powers of A that make up B.
eg, Powers(2,8) = 3, because 2x2x2 = 8
Powers(5,625) = 4, because 5x5x5x5 = 625
Print Powers(2,8)
Print Powers(5,625)
Perc(Number, Topmost Number [, Out of = 100 ])
Finds the percentage of Number, out of Topmost Number. For example Perc(30,60) would be 50%.
The third value allows you to scale the returned value to any target other than 100%.
FilesToLoad=237; FilesLoaded=0
Repeat
CLS 40,40,80
FilesLoaded=FilesLoaded+1
if FilesLoaded>FilesToLoad then FilesLoaded=0
Percentage=Perc(FilesLoaded,FilesToLoad)
PercentageOfScreen=Perc(FilesLoaded,FilesToLoad,ScreenWidth())
SetCol 255,255,255
Text ScreenWidth()*0.5,ScreenHeight()*0.5-32,"Always Loading",1
Text ScreenWidth()*0.5,ScreenHeight()*0.5,FilesLoaded+" / "+FilesToLoad+" : "+Floor(Percentage)+"%",1
SetCol 100,255,100
Rect 0,ScreenHeight()*0.5+32,PercentageOfScreen,16
Flip
Forever
Bin(integer[, length])
Returns the binary representation of a number, with a length specified.
Print Bin(1)
Print Bin(2)
Print Bin(138)
Print Bin(37171650)
BinToInt(binary value)
Converts a binary number into a decimal integer
Print BinToInt("00000000")
Print BinToInt("00000001")
Print BinToInt("00010000")
Print BinToInt("00010001")
Hex(integer[, length])
Returns the hexadecimal representation of a number, with a length specified.
Print Hex(15)
Print Hex(28)
Print Hex(4000)
Print Hex(37171650)
HexToInt(hexadecimal value)
Converts a hexadecimal number into a decimal integer
Print HexToInt("F")
Print HexToInt("0F")
Print HexToInt("16AA")
Print HexToInt("FACE")
Mills([since])
Alternative spellings : Millisec([since]) or Millisecs([since])
Returns the number of Milliseconds since either...
0 (default) - A default value, dependent on the Javascript implementation.
May be "since Jan 1970", "since this morning", "since the browser was loaded", or even "since the device was booted".
Honestly, could be anything!!
1 - Number of Milliseconds since the program was started.
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 "FrameNumber "+Frames()
Flip
Forever
Strings
String Operands
You can Add strings together, + to concatenate them, or alternatively multiply them * to repeat a string a number of times.
H="Hello "
W="World "
HW=H+W
Repeat
Print HW*3:Flip
Print:Flip
Print H*6:Flip
Print:Flip
Print W*6:Flip
Print:Flip
Forever
Chr(value)
Returns an ASCII character based on the value given.
Print Chr(74)+Chr(83)+Chr(69)
Asc(character or string)
Alternative spellings : Ord
Returns the ASCII value of the first character in the string.
Print Asc("J")+","+Asc("S")+","+Asc("E")
Len(string)
Returns the number of characters in the string.
Txt="JSE! "
Print Txt
Print Len(Txt)
Txt=Txt*4
Print Txt
Print Len(Txt)
TextWidth(string)
Returns the width that the text will use, when printed to the screen.
txt="This is some text"
y=12
For size=8 to 32 step 3
SetFontSize(size)
w=TextWidth(txt)
Text 0,y,txt,0
Rect 0,y+size/2,w,2
y=y+size*2
Next
TextHeight(string)
Returns the height that the text will use, when printed to the screen.
txt="This is some text"
y=12
scale=0.5
For size=8 to 32 step 3
SetFontSize(size)
SetSize(1,scale)
h=TextHeight(txt)
Text 32,y,txt,0
SetSize(1,1)
Rect 4,y,4,h,1
scale=scale+0.15
y=y+size*2
Next
Left(string, number of characters)
Returns the first characters from a string, up to the "number of characters"'th character.
Print Left("This is a really long string",9)
Right(string, number of characters)
Returns the rightmost characters from a string, of length "number of characters".
Print Right("This is a really long string",9)
Mid(string, start point, number of characters)
Returns characters from a string, starting at the start point, of length "number of characters".
Print Mid("This is a really long string",9,9)
Instr(string, search string[, start offset, case sensitive = 1 ])
If the search string is found within a string, returns it's position. If the search string is not found, returns -1.
A start offset can be specified to skip sections of the string.
You can additionally specify case sensitivity as a fourth parameter.
Print Instr("Friday","id")
Print Instr("Friday","if")
Print Instr("Friday is also a day","day")
Print Instr("Friday is also a day","day",10)
Print Instr("Giraffe","Raff",0,1)
Print Instr("Giraffe","Raff",0,0)
Lower(string)
returns the lowercase equivalent of the string.
Print Lower("HONEY, I SHRUNK THE TEXT!")
Upper(string)
RETURNS THE STRING, CAPITALISED.
Print Upper("Big me up, baby!")
Title(string)
Returns A String Where Every First Letter Is Capitalised.
Print Title("The great big pineapple ate my lovely cake.")
Trim(string)
Trims off the whitespace (spaces, tabs, etc) from a string.
Crikey=" Crikey! ";
Print "'"+Crikey+"'";
Print "'"+Trim(Crikey)+"'";
Replace(string, search, replace[, Case Insensitive])
Replaces the first occurrence of search within string with replace.
Print Replace("Duck duck duck Duck","duck","()<")
Print Replace("Duck duck duck Duck","duck","()<",1)
ReplaceAll(string, search, replace[, Case Insensitive])
Replaces all occurrences of search within string with replace.
Print ReplaceAll("Duck duck duck Duck","duck","()<")
Print ReplaceAll("Duck duck duck Duck","duck","()<",1)
ReplaceAt(string, replace, position)
Replaces part of string with replace, from position.
Print ReplaceAt("It is raining outside.","snowing",6)
InsertAt(string, insert, position)
Alternative Spellings : InsertString
Inserts a string within another string, at the given position.
Print InsertString("It is raining outside.","again ",14)
Shuffle(string)
Shuffles the characters in a string.
txt="Shuffled"
Repeat
Print Shuffle(txt)+" "+Shuffle(txt)+" "+Shuffle(txt)+" "+Shuffle(txt)+" "
Wait 0.1
Forever
Sort(string [, order])
Orders the characters in a string by their ASCII value, low to high.
Setting order to 1 will instead order them high to low.
txt="Shuffled"
Print Sort(txt)
Print Sort(txt,1)
Reverse(string)
Reverses a string.
txt="!sdrawkcab si txet sihT"
Print Reverse(txt)
SplitText(string, separator, nth)
Splits a string into chunks, then returns the nth chunk as a string.
Txt="This is a string that I want to be split into individual words."
// 1 2 3 4 5 6 7 8 9 10 11 12 13
Write SplitText(Txt," ",1)+" "
Write SplitText(Txt," ",2)+" "
Write SplitText(Txt," ",10)+" "
Write SplitText(Txt," ",11)+" "
Write SplitText(Txt," ",5)+" "
Write SplitText(Txt," ",4)+"."
Date and Time
Date |
DateString | Returns a handily formatted string with the current date. (dd-mm-yyyy) |
DateWeekday | Returns the number of the day of the week. (1-7) |
DateWeekdayName | Returns the name of the day of the week, based on the user's locale. |
DateDay | Returns the number of the day of the month. (1-xx) |
DateMonth | Returns the number of the month of the year. (1-12) |
DateMonthName | Returns the name of the current month, based on the user's locale. |
DateYear | Returns the current year. (yyyy) |
Time |
TimeString | Returns a handily formatted string with the current time. (hh:mm:ss) |
TimeHours | Returns the current time's hour. (0-23) |
TimeMinutes | Returns the current time's minutes. (0-59) |
TimeSeconds | Returns the current time's seconds. (0-59) |
Graphics 512,512,1
SetFont 27
Repeat
CLS 0,0,160
SetCol 0,180,0
SetFontSize 48
Text 256,460,TimeString(),1
SetCol 255,255,255
SetFontSize 16
Text 256,20,DateString(),1
Text 256,40,DateWeekdayName()+", "+DateDay()+" of "+DateMonthName()+", "+DateYear(),1
SetCol 255,255,0
SetThick 12
Line 256,256,256+(Sin((TimeHour()*30)+(TimeMinute()*0.5))*140),256-(Cos((TimeHour()*30)+(TimeMinute()*0.5))*140)
SetCol 255,128,0
SetThick 8
Line 256,256,256+(Sin(TimeMinute()*6)*220),256-(Cos(TimeMinute()*6)*220)
SetCol 0,128,255
SetThick 2
BoingTo=TimeSecond()*6
If BoingTo<(Boing-180) Then Boing=Boing-360
Boing=Boing-((Boing-BoingTo)*1.3)
Line 256+(Sin(Boing+180)*12),256-(Cos(Boing+180)*12),256+(Sin(Boing)*240),256-(Cos(Boing)*240)
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
DegToRad(Degrees)
Returns the Radians value of Degrees.
Print DegToRad(180)
RadToDeg(Degrees)
Returns the Degrees value of Radians.
Print RadToDeg(Pi)
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
ASin(-1.0 to 1.0)
Returns the Arc Sine value.
Print ASin(-1)
Print ASin(1)
Print ASin(0.37171650)
ACos(-1.0 to 1.0)
Returns the Arc Cos value.
Print ACos(-1)
Print ACos(1)
Print ACos(0.37171650)
ATan(angle)
Returns the Arc Tangent value of the given angle.
Repeat
Print ATan(Mills())
Forever
ATan2(X,Y)
Returns the angle of a given tangent.
Graphics 512,512,1
f=0
repeat
f=f+10
dx=Sin(f)*240
dy=0-(Cos(f)*240)
Text(255+dx,255+dy,Floor(ATan2(dx,0-dy)),1)
until f>360
Random Numbers
Rand( [ min [, max ] ] )
Alternative spellings : jRand( min [, max ] ] )
Generates a random integer between (and including) either 0 and 1, 0 and Min, or Min and Max, depending on whether you include a Min and Max value.
Print Rand()
Print Rand(100)
Print Rand(0,100)
Print Rand(50,100)
Print Rand(75,100)
Print Rand(99,100)
Rnd( min [, max ] ] )
Alternative spellings : jRnd( min [, max ] ] )
Generates a random floating point number between (and including) either 0 and 1, 0 and Min, or Min and Max, depending on whether you include a Min and Max value.
Print Rnd()
Print Rnd(10)
Print Rnd(0,100)
Print Rnd(50,100)
Print Rnd(75,100)
Print Rnd(99,100)
RandP( [ min [, max ] ] )
Alternative spellings : jRandP( min [, max ] ] )
Generates a random integer between (and including) either 0 and 1, 0 and Min, or Min and Max, depending on whether you include a Min and Max value, but also randomly polarises the value from postive to negative or vice-versa.
Print RandP()
Print RandP(100)
Print RandP(0,100)
Print RandP(50,100)
Print RandP(75,100)
Print RandP(99,100)
RndP( min [, max ] ] )
Alternative spellings : jRndP( min [, max ] ] )
Generates a random floating point number between (and including) either 0 and 1, 0 and Min, or Min and Max, depending on whether you include a Min and Max value, but also randomly polarises the value from postive to negative or vice-versa
Print RndP()
Print RndP(10)
Print RndP(0,100)
Print RndP(50,100)
Print RndP(75,100)
Print RndP(99,100)
SeedRnd [Seed]
Alternative spellings : jRandSeed [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, a unique number based on 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.
3 = Scaled as large as it can be, centered on the screen, but more true-to-life pixel-to-pixel based rather than scaled maths.
* - Will likely not be 1 to 1. Depends on hundreds of browser/system settings. Bah, humbug!!
Graphics 320,240,0
sc=0
Repeat
CLS 40,80,128
Text ScreenWidth()/2,ScreenHeight()/2,"Scale Mode "+sc,1
Line 0,0,ScreenWidth(),ScreenHeight()
Line ScreenWidth(),0,0,ScreenHeight()
Rect 0,0,32,32,1
Rect ScreenWidth(),0,32,32,1
Rect ScreenWidth(),ScreenHeight(),32,32,1
Rect 0,ScreenHeight(),32,32,1
If MouseHit()==1 or KeyHit()==1 or GamepadHit()==1
sc=sc+1
if sc<0 or sc>2 then sc=0
Graphics 320,240,sc
Endif
Flip
Forever
Mode n,["System", ScaleMode ]
Changes the virtual Graphics resolution to one of a number of preset modes. You can add "System" to set the resolution to a classic retro system's size.
The ScaleMode is the same as that used in the Graphics command.
Mode | "HiRes" | "CPC" | "C64" | "ZX" | "BBC" |
0 | 512x512 | 160x240 | 320x200 | 256x192 | 640x256 |
1 | 640x480 | 320x240 | 160x200 | . | 320x256 |
2 | 1024x768 | 640x240 | 96x200 | . | 160x256 |
3 | 1280x720 | . | . | . | . |
4 | 1920x1080 | . | . | . | . |
Mode 1,"CPC"
Print " Amstrad 128K Microcomputer (v3)"
Print
Print " "+Chr$(164)+"1985 Amstrad Consumer Electronics plc"
Print " and Locomotive Software Ltd."
Print
Print " Basic 1.1"
Print
Print "Ready"
SetBuffer BG/FG
Moves all drawing to the buffer specified.
Standard drawing works on the FG buffer, and is drawn and then displayed to the player.
If, however, you draw to the BG buffer, the result is not displayed to the user.
Instead, switch back to the FG buffer, you can DrawBG (or WrapBG) to draw the buffer's contents onto the screen.
You can use this to, for example, draw a looping background for your game.
Similarly if you SetBuffer Lighting, you can draw certain lighting effects to that buffer. At the end of your loop, just before you flip, use the DrawLighting command to add the lighting to your scene.
Note that the BG buffer is ALWAYS 1024x1024 pixels in size, and the Lighting buffer is always the size of the screen.
Graphics 640,480,1
AntiAlias Off
// Write Hello World once to the BG
SetBuffer BG
CLS;ResetDraw;SetFontSize 8
Text 512,512,"Hello World",1
// Redraw a hundred of the BG to the FG
SetBuffer FG
CLS;ResetDraw
For m=0 to 100
SetSize Rand(0.5,4)
SetRot Rand(0,360)
DrawBG Rand(0,640),Rand(0,480)
Next
Graphics 512,512,1
Repeat
CLS 128,128,128;ResetDraw
d=128+Sin(Mills()*0.1)*128
AmbientLight d,d,d
SetCol 255,0,0;SetFontSize 64
Text 256,256,"Hello",1
SetBuffer Lighting
SetCol 255,255,255
Light MouseX(),MouseY(),128
SetBuffer FG
Light 512-MouseX(),512-MouseY(),128
DrawLighting
Flip
Forever
UsePalette PaletteOption
Forces all colour commands to limit themselves to those of the colour palette of the requested system.
Although the palette is (hopefully) as accurate as can be, there's no limit on how many of the colours you can use. It isn't like a real classic system, where you can only draw with 4 colours at a time. It's just for fun, really.
Also be aware that any Alpha values will mess this illusion up, as will the anti-aliasing that Javascript has a habit of doing.
Available palettes are 32Bit, CPC, C64, ZX (spectrum) and BBC (micro), as well as NES, SMS (Sega Master System) and Atari (VCS/2600)
Graphics 512,480,3
CLS
for y=0 to 7
if y==0 then Name$="32bit"
if y==1 then Name$="CPC"
if y==2 then Name$="C64"
if y==3 then Name$="ZX"
if y==4 then Name$="BBC"
if y==5 then Name$="NES"
if y==6 then Name$="SMS"
if y==7 then Name$="Atari"
UsePalette Name$
for x=0 to 360
for br=0 to 10
InkRot x,1,br/10
Rect x+b*2,y*50+br*2,2,2
Next
for br=0 to 10
InkRot x,1-br/10,1
Rect x+b*2,y*50+20+br*2,2,2
Next
Next
Text 370,y*50+20,Name$,0
Flip
Next
AmbientLight
Also Use : DrawLighting
When you use these two commands in combination, you can end up creating some nice lighting effects for your game.
Set the AmbientLight at the start of your frame after your CLS, and then DrawLighting at the end before your Flip, and anything drawn onto SetBuffer Lighting will be overlaid afterwards, creating a nice set of lighting features.
However, do be aware that some browsers can struggle with some of these sorts of features, so if you do use them, do so sparingly.
Graphics 512,512,1
Repeat
CLS 128,128,128;ResetDraw
d=128+Sin(Mills()*0.1)*128
AmbientLight d,d,d
SetCol 255,0,0;SetFontSize 64
Text 256,256,"Hello",1
SetBuffer Lighting
SetCol 255,255,255
Light MouseX(),MouseY(),128
SetBuffer FG
Light 512-MouseX(),512-MouseY(),128
DrawLighting
Flip
Forever
ScreenEffect("Effect List",Amount 0.0-1.0)
Turns on one of a few effects.
Available effects are..
Noise Adds noise.
Scanlines Adds scanlines.
VLine Adds a white line that flickers up the screen.
Soft Adds an overall blur to the screen.
Glitch Jumps things around a bit.
Graphics 512,512,2
a=0
txt="Click to Test"
Repeat
CLS 255,255,255:SetCol 64,64,64:Rect 0,0,ScreenWidth()/2,ScreenHeight()
ResetDraw()
SetFontSizeFit(txt,ScreenWidth()*0.75,ScreenHeight())
SetCol 255,0,0:Text ScreenWidth()/2,ScreenHeight()*0.25,txt,1
SetCol 0,255,0:Text ScreenWidth()/2,ScreenHeight()*0.5,txt,1
SetCol 0,0,255:Text ScreenWidth()/2,ScreenHeight()*0.75,txt,1
if MouseHit()
a=(a+1) mod 11
if a==0 then txt="Click to Test"
if a==1 then txt="Noise"
if a==2 then txt="Scanlines"
if a==3 then txt="Noise+Scanlines"
if a==4 then txt="VLines"
if a==5 then txt="Noise+VLines"
if a==6 then txt="Noise+Scanlines+VLines"
if a==7 then txt="Glitch"
if a==8 then txt="Glitch+Noise"
if a==9 then txt="Glitch+Noise+Scanlines+VLines"
if a==10 then txt="Soft"
ScreenEffect(txt,1)
Endif
Flip
Forever
Antialias On/Off
Alternative spellings : AA On/Off/Fast
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.
The Fast option should use a mix of both, depending on which is faster to draw.
Symbol 0,"0__0_0@404040204040,204,040,4040402";
Graphics 512,512,1
SetScale 8,8
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.
Note : If you've SetBuffer BG, using the CLS command will also clear the alpha channel, making the BG buffer entirely transparent.
Graphics 512,512
SetFontSize 16
Print "This will get erased"
Wait 1
CLS
Print "Bang"
Print "And the text is gone"
SetCLSColour Red/255, Green/255, Blue/255
Alternative spellings : SetCLSColor, SetCLSCol, SetCLSRGB, SetCLSRGBA
Sets the colour that future CLS commands will use.
Graphics 512,512
SetCLSColor 30,30,80
SetFontSize 16
Print "This will get erased"
Wait 1
CLS
Print "Bang"
Print "And the text is gone"
SetCLSHue Hue/360,Saturation/1.0,Light/1.0
Alternative spellings : CLSInkRot, SetCLSHSV, SetCLSHSVA
Sets the colour that future CLS commands will use, based on Hue, Saturation and Light, rather than Red, Green and Blue.
Graphics 512,512
Repeat
CLS
Text ScreenWidth()/2,ScreenHeight()/2,"Click for Hues!",1
If MouseHit() then SetCLSHue Rand(0,360),0.8,0.3
Flip
Forever
Paper colour
Sets the CLS Colour to one of the current palette's colours. See the Pen command for a list of all available colours.
Mode 1,"CPC"
Repeat
n=Floor(Mills(1)/500) mod 27
Paper n
CLS
Text 160,120,"Paper "+n,1
Flip
Forever
Border [ Red/255, Green/255, Blue/255 ]
Sets the colour of the overlaid border which fits snuggly around the display area, during scale modes 0 and 1.
Graphics 512,512,0
Border 255,200,160
CLS 160,200,255
SetCol 0,0,0
Print "Colourful!"
Border colour
Sets the Border Colour to one of the current palette's colours. See the Pen command for a list of all available colours.
Mode 1,"CPC"
Repeat
n=Floor(Mills(1)/500) mod 27
Border n
CLS
Text 160,120,"Border "+n,1
Flip
Forever
Flip
Alternative spellings : Frame, WaitVbl
Draws the current frame to the screen, then waits for the next Vbl before carrying on.
Use this at the end of every frame to keep things as smooth as they can be.
Graphics 512,512
Repeat
Print "Hello World"
Flip
Until CursorY>400
ScreenWidth()
Alternative spellings : jscrw
Returns the currently available drawing width.
This will usually be the width set using the Graphic command.
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()
Alternative spellings : jscrh
Returns the currently available drawing height.
This will usually be the height set using the Graphic command.
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 will usually be the ratio of the width and height set using the Graphic command.
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.
It's best to use this command after a CLS, or the start of a new frame, so that each repeat of the script starts with the same values.
SetColor 255,0,0
SetFontSize 50;SetRotation 12
Print "Test"
ResetDraw
Print "Test"
SetColor Red/255,Green/255,Blue/255 [, Alpha/1.0 ]
Alternative spellings : SetColour, SetCol, SetRGB, SetRGBA, or just plain Color
Sets the drawing color, using RGB(A) values, for future drawing commands.
Alternatively, you can SetColor RGB(r,g,b), store RGB(r,g,b) into a variable and use SetColor MyColour, or even SetColor #rrggbb.
SetColor 255,0,0
Print "Hello World"
SetColour 0,255,0
Print "Hello World"
SetCol 0,0,255
Print "Hello World"
RGB(Red/255,Green/255,Blue/255)
Returns an integer value (#RRGGBB) for the given RGB colour
Graphics 512,512,1
c=RGB(255,0,255)
SetCol c,1
Print Hex$(c)
HSL(Hue/360,Saturation/1.0,Light/1.0)
Alternative spellings : HSV,
Returns an integer value (#RRGGBB) for the given HSL colour
Graphics 512,512,1
cyan=HSL(180,0.5,1)
SetCol cyan,1
Print Hex$(cyan)
Pen colour
Alternative spellings : Ink
Sets the drawing color, using a palette colour, for future drawing commands.
The palette can be changed with UsePalette to one of the available system palettes, or by default uses the Amstrad CPC's set of colours.
Ink | CPC | C64 | ZX | BBC |
0 | | | | |
1 | | | | |
2 | | | | |
3 | | | | |
4 | | | | |
5 | | | | |
6 | | | | |
7 | | | | |
8 | | | |
9 | | | |
10 | | | |
11 | | | |
12 | | | |
13 | | | |
14 | | | |
15 | | | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
Mode 1,"CPC"
Repeat
n=Floor(Mills(1)/500) mod 27
CLS
Pen 24:Write "Hello "
Pen 26:Write "World"
Pen n:Write "!!!"
Flip
Forever
GetRed
Gets the value of the current Red colour.
SetCol 182,96,64
Print GetRed()+","+GetGreen()+","+GetBlue()
GetGreen
Gets the value of the current Green colour.
SetCol 182,96,64
Print GetRed()+","+GetGreen()+","+GetBlue()
GetBlue
Gets the value of the current Blue colour.
SetCol 182,96,64
Print GetRed()+","+GetGreen()+","+GetBlue()
GetAlpha
Gets the value of the current Alpha colour.
SetCol 182,96,64
SetAlpha 0.5
Print GetAlpha()
SetHue Hue/360,Saturation/1.0,Light/1.0 [, Alpha/1.0 ]
Alternative spellings : InkRot, SetHSV, SetHSVA
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"
SetGradient Red/255,Green/255,Blue/255 [,Alpha/1.0] ,Red2/255,Green2/255,Blue2/255 [,Alpha2/1.0] [,Angle]
Alternative spellings : SetGrad
Sets a gradient for a few of the drawing commands. This isn't a universal command, but does at least work with Rectangles, Ovals, Triangles and Text commands, giving you the ability to quickly draw a few gradients in your game, like sky backgrounds and the like.
Try not to overuse this command, though, as it's terrible for the engine's speed!
Graphics 512,512,1
ang=0
Repeat
CLS
ang=ang+4
SetGradient 0,0,0,20,40,80
Rect 0,0,jscrw,jscrh
SetGradient 180,220,255,0,0,255,180
SetFontSizeFit "[More Colour]"
Text jscrw/2,100,"[More Colour]",1
SetGradient 255,0,0,0,0,255,ang
Rect jscrw/2,jscrh/2,100,100,1
SetGradient 255,0,0,0,0,255,ang+180
Oval jscrw/2,jscrh/2,100,100,32
Flip
Forever
SetShadow OffsetX,OffsetY,[ Alpha]
Sets the position and alpha of shadows, when using the ShadowImage command.
Symbol 0,"0__40!404044040,40040,404404004044040,40040,404404040!4";
Graphics 512,512,1
CLS 96,80,64;AA False;SetSize 4
ShadowImg 128,128,0
ShadowImg 128,384,0,0,1
SetShadow 8,8,1
ShadowImg 384,128,0
ShadowImg 384,384,0,0,1
SetGlow Alpha,[Scale]
Sets the alpha amount, and additionally the scale size, of glows when using the GlowImage command.
Symbol 0,"0__40!404044040,40040,404404004044040,40040,404404040!4";
Graphics 512,512,1
CLS 96,80,64;AA False;SetSize 4
SetGlow 0.5
GlowImg 128,128,0
SetGlow 1
GlowImg 384,128,0
SetGlow 0.5,2
GlowImg 128,384,0
SetGlow 1,2
GlowImg 384,384,0
SetBlend BlendMode
The available blend modes are..
Mouse |
0 - "Normal" | Standard blending. |
1 - "Light" | Adds brightness. |
2 - "Multiply" | Removes darkness. |
3 - "Overlay" | Dark colours get darker, light colours lighter. |
4 - "Soft" | A much more subtle variation of the Light effect. |
5 - "Difference" | Reverses colours, subtracting new colours from old. |
6 - "Screen" | Inverted Multiply, to significantly increase brightness. |
7 - "Dodge" | Makes things brighter, when the image is bright. |
8 - "Burn" | Makes things darker when the image is dark. |
9 - "Hue" | Changes the hue to that being drawn. |
10 - "Sat" | Changes the saturation to that being drawn. |
11 - "Lum" | Changes the luminance to that being drawn. |
You can retrieve the name of a blend mode using the BlendName command.
Symbol 0,"0__aaMMccOOaaMMccOO11FF33HH11FF33HHggSSeeQQggSSeeQQ77LL55JJ77LL55JJ";
Symbol 1,"0__;.v.;.v.;.v.;.v@;.v.;.v.;.v.;.";
Blend=0
Graphics 512,512,1
AntiAlias Off
Repeat
Cls
ResetDraw()
// Blend Toggle
If MouseHit() then Blend=Blend+1
If Blend>11 then Blend=0
Gosub Background
dx=MouseX();dy=MouseY();
a=(dy-140)/200;
SetCol(0,128,255); SetAlpha(a); SetBlend(Blend);
SetSize(4);
DrawImg(dx-128,dy,1);DrawImg(dx,dy,0);DrawImg(dx+128,dy,1)
Flip
Forever
// Background
@Background
g=ScreenWidth()/8
n=0
sx=Sin(Mills()*0.05)*g
sy=0-Cos(Mills()*0.03)*g
// Grid
For x=0-g to ScreenWidth()+g step g
For y=0-g to ScreenHeight()+g step g
n=(n+1) mod 2
if n==0 then SetCol 255,255,255
if n==1 then SetCol 0,0,0
Rect x+sx,y+sy,g+1,g+1
Next
Next
SetAlpha 0.9
// Blue Box
SetCol(0,128,255);
Rect(256,256,420,420,1)
// Orange Box
SetCol(255,128,0);
Rect(256,256,256,256,1)
SetAlpha 1
// Text at the Top
SetFontSize(16)
SetCol(0,0,0);
Text ScreenWidth()/2+2,18,"Blend Mode : "+BlendName(Blend),1
SetCol(150,128,90);
Text ScreenWidth()/2,16,"Blend Mode : "+BlendName(Blend),1
Return
SetScale XScale/1.0 [,YScale/1.0]
Alternative spellings : SetSize
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
Alternative spellings : SetRot
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
SetSkew XSkew,YSkew
Sets the Skew for future drawing commands.
Symbol 0,"0__I_d!IIdI.dIIdIddIdIIdIddIdIIdI.dIId!I_";
Graphics 512,512,1
AntiAlias Off
Repeat
CLS
sx=Sin(Mills()*0.1);sy=0;txt="X Skew"
if Mills() mod 4000<2000 then sx=0;sy=0-Cos(Mills()*0.1);txt="Y Skew"
SetSize 8
SetSkew sx,sy
DrawImg 256,256,0
ResetDraw
Text 256,480,txt,1
Flip
Forever
SetThick Thickness
Alternative spellings : SetLineThickness, SetWidth, SetLineWidth
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
SetFont FontNumber or "FontName"
Sets the font for future text commands.
You can choose a font from 0 to 33.
Graphics 1280,900,1
Border 128,128,128;CLS 160,160,160;SetCol 0,0,0
SetFontSize 40
x=16;y=16
For n=0 to 33
SetFont n
Text x,y+20,Right$("00"+n,2)+" "+FontName(),0
y=y+52
If n==16 then y=16:x=x+640
Next
SetFontSize Size
Sets the font size for future text commands.
SetFontSize 16
Print "Hello World"
SetFontSize 32
Print "Hello World"
SetFontSize 64
Print "Hello World"
SetFontSizeFit String,Width,Height
Alternative Spellings : SetFontSize_Fit
Finds, sets, and returns the best font size to fit the text within the space requested, taking the current Scale X and Y into account.
Graphics 800,600,1
CLS 30,30,80
txt="This is some text"
SetFontSizeFit(txt,ScreenWidth(),ScreenHeight())
Text ScreenWidth()/2,ScreenHeight()/2,txt,1
FontName()
Returns the name of the current font.
Graphics 1280,900,1
Border 128,128,128;CLS 160,160,160;SetCol 0,0,0
SetFontSize 40
x=16;y=16
For n=0 to 33
SetFont n
Text x,y+20,Right$("00"+n,2)+" "+FontName(),0
y=y+52
If n==16 then y=16:x=x+640
Next
Symbol Number, Image Data
Draws the compressed image data onto the Spritesheet, at the given slot number.
Symbols can be drawn using the inbuilt Symbol Editor.
Symbol 0,"0__0I!0II0.I,0!II0!II0!II0!I,0.II0I!";
Symbol 1,"0__0_0_0BB0?B.0.B.0?BB";
Graphics 512,512,0
SetAntiAlias False
Repeat
CLS
SetScale 14,14
DrawImage 256,256,0
DrawImage 256+(64*Sin(Mills()/4)),256-(64*Cos(Mills()/3)),1
Flip
Forever
Attempts to scroll the display by the given offset.
Note that whether this works, and how well it works, depends on a number of factors, like the browser, the browser's settings, the operating system, the device and more.
It can also cause a fair amount of slowdown, too!
Symbol 0,"0__0I!0II0.I,0!II0!II0!II0!I,0.II0I!";
Symbol 1,"0__0_0_0BB0?B.0.B.0?BB";
Graphics 512,512,0
SetAntiAlias False
Repeat
CLS 0,0,0,0.05
SetScale 14,14
DrawImage 256,256,0
DrawImage 256+(64*Sin(Mills()/4)),256-(64*Cos(Mills()/3)),1
Flip
Scroll 0-2,0-2
Forever
Drawing Commands
Print String
Prints the requested string to the screen at the current CursorX and CursorY position, then moves the cursor down to the next line afterwards.
Print "Hello World!"
Print "Hello again!"
Write String
Writes the requested string to the screen at the current CursorX and CursorY position, without moving the cursor down to the next line afterwards.
Write "Hello World!"
Write "Hello again!"
Locate X,Y
Sets the cursor's position, for the next Print command.
Note that, unlike retro systems, this is a pixel-based value, not a grid-based one.
Print "Hello World!"
Locate 100,100
Print "Hello Again!"
CursorX
Returns the current X position of the text cursor.
Locate 50,100
Print CursorX()
CursorY
Returns the current Y position of the text cursor.
Locate 50,100
Print
Print CursorY()
Text x,y,String [, Alignment=0]
Alternative Spellings : DrawText, FillText
Draws text to the screen using the current drawing settings.
The Alignment shifts the text vertically. When 0, the X co-ordinate will be the left of the text, with the text flowing from that point. 1 will center the text at the given co-ordinate. 2 will align the text so the end of the string meets the co-ordinate.
Line 200,160,200,240
SetCol 255,0,0
Text 200,180,"Red",0
SetCol 0,255,0
Text 200,200,"Green",1
SetCol 0,0,255
Text 200,220,"Blue",2
OutlineText x,y,String [, Alignment=0]
Draws an outline of text to the screen using the current drawing settings.
The Alignment shifts the text vertically. When 0, the X co-ordinate will be the left of the text, with the text flowing from that point. 1 will center the text at the given co-ordinate. 2 will align the text so the end of the string meets the co-ordinate.
Line 200,160,200,240
SetCol 255,0,0
OutlineText 200,180,"Red",0
SetCol 0,255,0
OutlineText 200,200,"Green",1
SetCol 0,0,255
OutlineText 200,220,"Blue",2
ScrollerText Y, X Speed
Alternative Spellings : ScrollText
Use this to scroll the current scroll-message on the screen at the given Y position.
Graphics 512,512,1
SetScrollText "<<<---Hello World--->>>"
Repeat
CLS;ResetDraw
ScrollText 256,-2
Flip
Forever
Emoji x,y,Emoji "U+1Fnnn" code
Draws the requested Emoji onscreen. Emoji codes can be found here.
Please be aware that not all emoji will display on all browser/system combinations. Try to use the emoji on the site that are listed for as many setups as possible.
Every emoji should have a "U+1Fnnn" code associated with it, on the left of the table. These are the codes to use.
If the Emoji doesn't have a "U+1Fnnn" code, then it will not work.
This limitation has been added for security reasons.
If you find a code that you'd like to use, please let me know which it is, and I'll add a special clause for it.
Size wise, Emoji should be "roughly" the size of the current font, but .. In the world of Emoji's.. Expect chaos, and frequent misalignments!
In addition, colour and alpha settings should not be expected to work. Sometimes they do, but not in all browsers.
Graphics 320,240,2
// Sky
CLS 80,150,255;SetFontSize 32
// Grass
SetCol 0,120,0;Rect 0,ScreenHeight()-48,ScreenWidth(),48
// Sun
Emoji(ScreenWidth()*0.7,ScreenHeight()*0.2,"U+1F31E")
// Flowers
For x=0 to ScreenWidth() step 32
Emoji(x,ScreenHeight()-64,"1F33B")
Next
TextScore x,y[, Alignment=1]
Writes the current score to the screen at the specified position.
This function assumes the score is stored in a variable named Score, and will tick the display upwards, towards the value.
The function uses the variable ShowScore to store the currently displayed value
The Alignment shifts the text horizontally. When 0, the X co-ordinate will be the left of the text, with the text flowing from that point. 1 will center the text at the given co-ordinate. 2 will align the text so the end of the string meets the co-ordinate.
Score=0
Repeat
Cls
TextScore ScreenWidth()/2,ScreenHeight()/2
Text ScreenWidth()/2,ScreenHeight()/2+40,Score,1
If MouseHit then Score=Score+75
Flip
Forever
DrawImage X,Y,Symbol Number [,Recolour Setting]
Alternative spellings : DrawImg, DrawSprite, DrawSymbol
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
These recolourings can be seen in the Symbol Editor.
Symbol 0,"0__20!203044030,30030,404404004044040,30030,304403020!2";
Graphics 512,512,1
AntiAlias off // Switch on 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
ShadowImage X,Y,Symbol Number [,Recolour Setting]
Alternative spellings : ShadowImg, ShadowSprite, ShadowSymbol
Draws the requested image frame, with a shadow underneath it. See DrawImage for all the parameters.
Symbol 0,"0__40!404044040,40040,404404004044040,40040,404404040!4";
Graphics 512,512,1
CLS 96,80,64;AA False;SetSize 4
ShadowImg 128,128,0
ShadowImg 128,384,0,0,1
SetShadow 8,8,1
ShadowImg 384,128,0
ShadowImg 384,384,0,0,1
GlowImage X,Y,Symbol Number [, Recolour Setting] [, Glow Behind]
Alternative spellings : GlowImg, GlowSprite, GlowSymbol
Draws the requested image frame, with a lit glow underneath it. See DrawImage for all the parameters.
Setting the additional Glow Behind value to 1 will move the glow behind the drawn image, rather than in front, for a slightly different look.
Symbol 0,"0__4BIPWdkrBBIPWdkrI,PWdkrP.WdkrW?dkrd!krk/r_";
Graphics 512,512,1
CLS 96,80,64;AA False;SetSize 4
SetGlow 0.5
GlowImg 128,128,0
SetGlow 1
GlowImg 384,128,0
SetGlow 0.5,2
GlowImg 128,384,0
SetGlow 1,1
GlowImg 384,268,0
GlowImg 384,408,0,0,1
BlurImage X,Y,Symbol Number [,Recolour Setting]
Alternative spellings : BlurImg, BlurSprite, BlurSymbol
Draws a blurry version of an image. See DrawImage for all the parameters.
Symbol 0,"0__40!404044040,40040,404404004044040,40040,404404040!4";
Graphics 512,512,1
CLS 96,80,64;AA False;SetSize 4
DrawImg 128,256,0
BlurImg 384,256,0
DrawBG X,Y
Draws the contents of the BG layer (See SetBuffer) onto the current buffer.
You can use this to, for example, draw a generic background without having to repeat all the draw commands every frame.
Graphics 1920,1080,2
// Draw a repeating texture onto the BG Buffer
SetBuffer BG
CLS;ResetDraw;SetFontSize 8;SetRot 0-30
For x=0-1024 to 1024 step 64
For y=0-1024 to 1024 step 64
Text x,y,"Hello World",1
Next
Next
// Redraw the BG to the FG at the Mouse Co-Ords
SetBuffer FG
Repeat
CLS;ResetDraw
DrawBG MouseX(),MouseY()
Flip
Forever
WrapBG X,Y
Draws the contents of the BG layer (See SetBuffer) onto the current buffer, and attempts to wrap the contents in an endlessly repeating pattern.
Please note, however, that a few instances can break the illusion.
Wrapped BG's don't currently rotate very well (I'm currently trying to figure out the maths for this! Aargh, Mafffs!)
In addition, if you have too small of a BG (eg SetSize 0.5) against too big of a screen (Graphics 1920,1080,2), it probably won't draw enough of the BG to cover the entire screen.
Graphics 1920,1080,2
// Draw a repeating texture onto the BG Buffer
SetBuffer BG
CLS;ResetDraw;SetFontSize 8;SetRot 0-30
For x=0-1024 to 1024 step 64
For y=0-1024 to 1024 step 64
Text x,y,"Hello World",1
Next
Next
// Redraw the BG to the FG at the Mouse Co-Ords
SetBuffer FG
Repeat
CLS;ResetDraw
DrawBG MouseX(),MouseY()
Flip
Forever
Move X,Y
Moves the Graphics Pointer to the specified co-ordinates
Move 100,100
DrawTo 200,200
MoveR X,Y
Moves the Graphics Pointer to the specified co-ordinates, relative to the current co-ordinates
Move 100,100
PlotR 10,10
MoveR 50,10
DrawTo 200,200
Plot X,Y
Plots a point on the screen at the given co-ordinates.
Plot 100,100
PlotR Direction X, Direction Y
Moves the graphic pointer in the direction given, then plots a point.
Graphics 128,128,1
CLS 40,40,80
Move 64,64
Repeat
if GamePad(ButtonRight)>0 then PlotR 1,0
if GamePad(ButtonLeft)>0 then PlotR Neg(-1),0
if GamePad(ButtonUp)>0 then PlotR 0,Neg(1)
if GamePad(ButtonDown)>0 then PlotR 0,1
Flip
Forever
ReadPixel X,Y,ReadType
Alternative Spellings : GetPixel
Attempts to read the pixel colour at the current co-ordinates.
Please be aware that various Browser Incompatibilities may cause this command to fail in any number of situations!
ReadTypes are ..
0. For the Red value
1. For the Green value
2. For the Blue value
-1/default. For the complete ARGB value.
Please note that Alpha values are frequently messed up on the canvas, so shouldn't ever be trusted!
Repeat
CLS
SetCol 255,180,100
Rect 100,100,200,200
Print "Red "+ReadPixel(MouseX(),MouseY(),0)
Print "Green "+ReadPixel(MouseX(),MouseY(),1)
Print "Blue "+ReadPixel(MouseX(),MouseY(),2)
Print "Hex "+Right("00000000"+Hex$(ReadPixel(MouseX(),MouseY() )),8)
Flip
Forever
Line X1,Y1, X2,Y2
Alternative spellings : DrawLine
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
LineTo X,Y
Alternative spellings : DrawTo
Draws a line from the current Graphics Position, to the requested one.
Graphics 512,512,1
CLS 40,40,80
Move 256,256
Repeat
If MouseDown() then LineTo MouseX(),MouseY()
Flip
Forever
LineR Direction X, Direction Y
Alternative spellings : DrawR
Draws a line from the current Graphics Position, in the requested direction.
Graphics 128,128,1
CLS 40,40,80
Move 64,64
Repeat
DirectionX=Gamepad(ButtonRight)-Gamepad(ButtonLeft)
DirectionY=Gamepad(ButtonDown)-Gamepad(ButtonUp)
LineR DirectionX,DirectionY
Flip
Forever
Rect X,Y,Width,Height [,Centered=0]
Alternative spellings : FillRect, DrawRect
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 [,Sides=24]
Alternative spellings : FillOval, DrawOval, Circle, FillCircle, DrawCircle
Draws an Oval using the current drawing settings.
You can alternatively use DrawOval to draw the outline of the Oval.
Adding a Sides parameter will allow you to draw pentagons, hexagons, octagons and the like.
SetCol 255,0,0
Oval 200,60,100,100
Oval 400,60,100,100,8
SetCol 255,128,0
DrawOval 200,180,100,100
DrawOval 400,180,100,100,8
SetCol 0,255,0
Oval 200,300,100,100
Oval 400,300,100,100,8
Star X,Y,Outer Radius[, Inner Radius, Points=5]
Alternative spellings : FillStar, DrawStar
Draws a Star using the current drawing settings.
You can use the Inner Radius parameter to make the star appear fatter.
You can alternatively use DrawStar to draw the outline of the star.
SetCol 255,0,0
Star 200,60,100,50
Star 400,60,100,70,8
SetCol 255,128,0
DrawStar 200,180,100,70
DrawStar 400,180,100,50,8
SetCol 0,255,0
Star 200,300,100,20
Star 400,300,100,80,8
Triangle X,Y,Width,Height
Alternative spellings : FillTriangle, DrawTriangle
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
Light X,Y, Radius, Strength (0.0-1.0)
Draws a gradiented circle, fading to full transparency, using the current drawing settings.
Works best with SetBlend "Light"
Repeat
CLS
SetBlend "Light"
SetCol 0,255,0
Light MouseX(),MouseY(),128,0.8
SetCol 255,0,0
Light 320,240,128,0.8
Flip
Forever
Starfield ScrollX,ScrollY [, Symbol=0 ,Colourful On/Off]
Draws a starfield that can be scrolled around the screen.
Once stars are offscreen, they'll be given a new random placement, so the starfield is constantly random.
Select a Symbol (defaults to Symbol 0) for the starfield, and the stars can either all use Colour 0, or rotate between all of the available colours
Symbol 0,"0__0,220!220,2@02!0,2.0.2.0,2200220020.2";
Graphics 1280,720,2
Repeat
CLS
ResetDraw
y=0
Repeat
SetCol 0,y*0.05,y*0.2
Rect 0,y,ScreenWidth(),17
y=y+16
Until y>ScreenHeight()
SetSize 0.5
Starfield 2,0,0,1;ResetDraw;
Flip
Forever
LoadingBar Percentage,"Message","Style"
Draws a Loading Bar onto the screen. You can choose from the following styles.
"Normal" : Just a loading bar.
"Twirl" : Spinning text with a criss-cross loading bar.
"Arc" : Text spins in a circle, around a circular loading bar.
"Triangular" : Text is repeated in a triangle, with a rotating triangle forming the loading bar.
"Slinky" : Multicoloured text, scaling up and down in a sine-wave, that dims to represent the loading.
"Ribbon" : A spiral ribbon of text, changing to green to represent the loading.
If you'd prefer not to figure out the percentage of your loading, just use 0 and it'll still draw a nice pattern.
Graphics 1024,768,1
loaded=0
Repeat
CLS
Show=loaded mod 100
if loaded<100 then LoadingBar Show
if loaded>=100 and loaded<200 then LoadingBar Show,"Loading...","Twirl"
if loaded>=200 and loaded<300 then LoadingBar Show,"Loading (still)","Arc"
if loaded>=300 and loaded<400 then LoadingBar Show,"Loading (Weeee!)","Triangular"
if loaded>=400 and loaded<500 then LoadingBar Show,"Loading Forever","Slinky"
if loaded>=500 and loaded<600 then LoadingBar Show,"Endless Loading","Ribbon"
if loaded>=600 then loaded=0
loaded=loaded+0.4
Flip
Forever
Tilemap
DrawTilemap Top Left x,y
Draws the current tilemap with the top left tile being centered at the given co-ordinates.
Current Scale and Alpha settings are respected, but not Rotate, because ...Maths!!!
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(0,0,0)
SetTile(1,0,0);SetTile(2,0,0)
SetTile(0,1,0);SetTile(0,2,0)
SetTile(63,63,1)
SetTile(62,63,1);SetTile(61,63,1)
SetTile(63,62,1);SetTile(63,61,1)
Repeat
CLS
x=MouseX() ; y=MouseY()
if x<0 then x=0
if y<0 then y=0
if x>ScreenWidth() then x=ScreenWidth()
if y>ScreenHeight() then y=ScreenHeight()
DrawTilemap x,y
Flip
Forever
WrapTilemap Top Left x,y
Draws the current tilemap with the top left tile being centered at the given co-ordinates.
The tilemap will wrap around the screen's limits, though each tile will only be drawn once.
Current Scale and Alpha settings are respected, but not Rotate, because ...Maths!!!
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(0,0,0)
SetTile(1,0,0);SetTile(2,0,0)
SetTile(0,1,0);SetTile(0,2,0)
SetTile(63,63,1)
SetTile(62,63,1);SetTile(61,63,1)
SetTile(63,62,1);SetTile(63,61,1)
Repeat
CLS
x=MouseX() ; y=MouseY()
if x<0 then x=0
if y<0 then y=0
if x>ScreenWidth() then x=ScreenWidth()
if y>ScreenHeight() then y=ScreenHeight()
WrapTilemap x,y
Flip
Forever
SetTilemapSize w,h
Sets up a Tilemap with the given size.
Currently the maximum size is 256*256 tiles. (Although this may be in any orientation, eg 1024*64 works.)
I'll add more space at a later date, but the drawing needs to be optimised, first!
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
DrawTilemap 0,0
TilemapWidth()/TilemapHeight()
Returns the current tilemap's width or height
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,32
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
DrawTilemap 0,0
Print TilemapWidth()+":"+TilemapHeight()
SetTile w,h,Symbol Number
Sets the chosen tile to be the number specified. Tiles set between 0 and 99 will display the Symbol selected.
Anything below 0 or above 99 will not display anything.
Use GetTile(x,y) to retrieve the value of a tile.
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
DrawTilemap 0,0
SetTileColour w,h,Symbol Colour
Alternative spellings : SetTileColor or SetTileCol
Sets the chosen tile's colour, between 0 and 9. See DrawImage for further information on how the recolouring works.
Use GetTileColour(x,y) to retrieve the colour setting for a tile.
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
Repeat
CLS
DrawTilemap 0,0
SetTileColour(7,7,(Mills()/200)%10)
Flip
Forever
SetTileOffset x,y, OffsetX, OffsetY (0.0+)
Each tile in the grid can be misaligned by a floating point number. An offset of -1 or 1 will move the tile a whole space across.
Use GetTileOffsetX(x,y) and GetTileOffsetY(x,y) to retrieve the current offset settings for a tile.
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
Repeat
CLS
DrawTilemap 0,0
SetTileOffset(7,7,Sin(Mills()),0-Cos(Mills()))
Flip
Forever
SetTileScale x,y, ScaleX, ScaleY (0.0+)
Alternative spellings : SetTileSize
Each tile in the grid can be scaled by a floating point number, in either direction.
2 is double the size, -1 is inverted, 0 will be infinitely teensy tiny!
Use the commands GetTileScaleX(x,y) or GetTileScaleY(x,y) to retrieve the scaling values for a tile.
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
Repeat
CLS
DrawTilemap 0,0
SetTileScale(7,7,Sin(Mills())+1,0-Cos(Mills())+1)
Flip
Forever
SetTileRotation x,y, Rotation (degrees)
Alternative spellings : SetTileRotate or SetTileRot
Each tile in the grid can be rotated.
Use GetTileRotation(x,y) to retrieve the rotation for a tile.
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
Repeat
CLS
DrawTilemap 0,0
SetTileRot(7,7,Sin(Mills()/10)*90)
Flip
Forever
SetTileAlpha x,y, Alpha
Each tile in the grid can be given its own amount of Alpha transparency.
Use GetTileAlpha(x,y) to retrieve the alpha setting for a tile.
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0)
SetTile(9,5,0)
SetTile(7,7,1)
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
Repeat
CLS
DrawTilemap 0,0
SetTileAlpha(7,7,Abs(Sin(Mills()/5)))
Flip
Forever
SetTileData x,y, Data
Each tile in the grid has a free slot for popping data into. Use this for whatever comes to mind.
Use GetTileData(x,y) to retrieve the data.
Symbol 0,"0__1_5!115!115!115!115!115!1_";
Symbol 1,"0__006.0,64.6064!664!664!664!6064.60,6.";
SetTilemapSize 64,64
SetTile(5,5,0); SetTileData(5,5,"This is an eye")
SetTile(9,5,0); SetTileData(9,5,"This is another eye!")
SetTile(7,7,1); SetTileData(7,7,"This is the nose!")
SetTile(5,8,0);SetTile(6,9,0);SetTile(7,9,0);SetTile(8,9,0);SetTile(9,8,0);
Repeat
CLS
DrawTilemap 0,0
x=Floor((MouseX()+16)/32)
y=Floor((MouseY()+16)/32)
Text MouseX()+32,MouseY()+32,GetTileData(x,y),0
Flip
Forever
Collisions
Simpler Collisions
CollideCircleToCircle(X1, Y1, Diameter1, X2, Y2, Diameter2)
Returns true if the two circles are colliding.
Graphics 512,512,1
Repeat
CLS
SetCol 255,128,0
Oval(256,256,96,96,64)
SetCol 60,180,255
If CollideCircleToCircle(256,256,96,MouseX(),MouseY(),128) then Text 100,100,"Collision";SetCol 255,0,0
Oval(MouseX(),MouseY(),128,128,64)
Flip
Forever
CollidePointToCircle(PointX, PointY, CircleX, CircleY, Diameter)
Returns true if the Point is inside the Circle.
Graphics 512,512,1
Repeat
CLS
SetCol 255,128,0
Line(100,200,400,300)
SetCol 60,180,255
If CollideLineToLine(100,200,400,300,MouseX(),MouseY(),0,0) then
SetCol 255,255,255
DrawOval(LineCollidePointX,LineCollidePointY,16,16);
Text 100,100,"Collision";SetCol 255,0,0
endif
Line(MouseX(),MouseY(),0,0)
Flip
Forever
CollideRectToRect(X1, Y1, Width1, Height1, X2, Y2, Width2, Height2)
Returns true if the two rectangles are colliding
Graphics 512,512,1
Repeat
CLS
SetCol 255,128,0
Rect(256,256,96,96,1)
SetCol 60,180,255
If CollideRectToRect(256,256,96,96,MouseX(),MouseY(),128,128) then Text 100,100,"Collision";SetCol 255,0,0
Rect(MouseX(),MouseY(),128,128,1)
Flip
Forever
CollidePointToRect(PointX, PointY, X1, Y1, Width1, Height1)
Returns true if the Point is inside the Rectangle.
Graphics 512,512,1
Repeat
CLS
SetCol 255,128,0
Rect(256,256,96,96,1)
SetCol 60,180,255
If CollidePointToRect(MouseX(),MouseY(),256,256,96,96) then
SetCol 255,255,255
Text 100,100,"Collision";SetCol 255,0,0
Endif
Flip
Forever
CollideRectToCircle(X1, Y1, Width1, Height1, X2, Y2, Diameter2)
Returns true if the rectangle collides with the circle
Graphics 512,512,1
Repeat
CLS
SetCol 255,128,0
Oval(256,256,96,96,64)
SetCol 60,180,255
If CollideRectToCircle(MouseX(),MouseY(),128,128,256,256,96) then
SetCol 255,255,255
Text 100,100,"Collision";SetCol 255,0,0
Endif
Rect(MouseX(),MouseY(),128,128,1)
Flip
Forever
CollideCrossToCircle(X1, Y1, Width1, Height1, X2, Y2, Diameter2)
Returns true if the cross ( X ) collides with the circle.
Please Note : This might be a rather specific collision type for a rather specific game!!
Graphics 512,512,1
Repeat
CLS
SetCol 255,128,0
Oval(256,256,128,128,64)
SetCol 60,180,255
If CollideCrossToCircle(MouseX(),MouseY(),128,128,256,256,128) then
SetCol 255,255,255
Text 100,100,"Collision";SetCol 255,0,0
Endif
Line(MouseX()-64,MouseY()-64,MouseX()+64,MouseY()+64)
Line(MouseX()+64,MouseY()-64,MouseX()-64,MouseY()+64)
Flip
Forever
CollideLineToLine(X1,Y1, X2,Y2, X3,Y3, X4,Y4)
Returns true if the two lines are colliding.
Please Note : The exact co-ordinates of the collision will be placed in the variables LineCollidePointX and LineCollidePointY.
The other collision types don't do this, because maths!!!
Graphics 512,512,1
Repeat
CLS
SetCol 255,128,0
Line(100,200,400,300)
SetCol 60,180,255
If CollideLineToLine(100,200,400,300,MouseX(),MouseY(),0,0) then
SetCol 255,255,255
DrawOval(LineCollidePointX,LineCollidePointY,16,16);
Text 100,100,"Collision";SetCol 255,0,0
endif
Line(MouseX(),MouseY(),0,0)
Flip
Forever
Particles
ThrowParticle( SourceX, SourceY,
[ Type ], [ Direction ], [ Speed ], [ Symbol ] , [ Colour ], [ Blend Mode ] )
Throws a particle.
Particle Types are
1 - Standard particle
2 - Falls
3 - Falls, but also bounces when it reaches a point just below it's source Y co-ordinate.
4 - Slows down
5 - Speeds up
6 - Falls upwards
7 - Rises like smoke
8 - Swirls around Source X/Y
9 - Minty, only goes up, down, left or right, and never rotates.
Colours are based upon Symbol colours
Blend modes are as seen in SetBlend
This is a rather complex looking command, sorry!
Symbol 0,"0__0,440!440!440,4_4/0,440!440!44";
Symbol 1,"0__0_0_0440?4.0.4.0?44";
Graphics 800,600,1
Repeat
CLS 70,70,120
ThrowParticle MouseX(),MouseY(),4
ThrowParticle MouseX(),MouseY(),2,Rnd(-15,15),2,1,0,8
Flip
Forever
Gimme Points, x, y
Adds a numerical particle at the current co-ordinates, and adds the Points value to the Score variable.
Graphics 512,512,2
Score=0
Repeat
CLS:ResetDraw
If MouseHit() then Gimme 10,MouseX,MouseY
TextScore ScreenWidth()/2,16,1
Flip
Forever
SetParticleGravity gravity/1.0
Changes the gravity amount for Particle types 2,3,6 and 7.
Symbol 0,"0__0,440!440!440,4_4/0,440!440!44";
Graphics 800,600,1
Repeat
CLS 70,70,120
ThrowParticle 200,200,2,Rnd(-13,13),1
ThrowParticle 400,500,3,Rnd(-13,13),1
ThrowParticle 600,400,6,180+Rnd(-13,13),1
ThrowParticle MouseX(),MouseY(),7,Rnd(-8,8),0
g=MouseY()/(ScreenHeight()/1.5)
SetParticleGravity g
Text 400,300,"Gravity "+left$(""+g+"00000000",8),1
Flip
Forever
SetParticleLife lifespan
Changes the lifespan for particles, where 0.2 is short, and 3.0 is long, etc.
Symbol 0,"1__0!;.0_0,;.0_0044;;440_044;;440_00;.0_0,;.0!;;0.;.0.;.0.;.0.;_;_;_;/0!;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.";
Graphics 512,512,1
t=0;x=0
Repeat
CLS;ResetDraw;
t=t+1
if t>4
t=0
x=Wrap(x+16,0,jscrw)
SetParticleLife x/400
ThrowParticle x,160,2,0,2,0,0
endif
Flip
Forever
SetParticleRotation RotationSpeed
Alternative spellings : SetParticleRotate, SetParticleRot
Changes the lifespan for particles, where 0 is the particles don't rotate at all, 10.0 they spin crazily.
Symbol 0,"1__0!;.0_0,;.0_0044;;440_044;;440_00;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.0_0,;.";
Graphics 512,512,1
t=0;x=0
Repeat
CLS;ResetDraw;
t=t+1
if t>4
t=0
x=Wrap(x+16,0,jscrw)
n=0
if x>256 then n=1
SetParticleRot n
ThrowParticle x,160,2,0,2,0,0
endif
Flip
Forever
SetParticleSize SymbolSize
Sets the size that Particles should be drawn at.
Symbol 0,"0__0,440!440!440,4_4/0,440!440!44";
Graphics 800,600,1
Repeat
CLS 70,70,120
ThrowParticle 400,500,3,Rnd(-13,13),Rnd(2,3)
g=MouseY()/(ScreenHeight()/60)
SetParticleSize g
Text 400,300,"Size "+left$(""+g+"00000000",8),1
Flip
Forever
ScrollParticles ScrollX,ScrollY
Moves all particles by the requested amount. Useful when you're scrolling the screen.
Symbol 0,"0__0,40/40/40/40/40/40/40/4";
Repeat
CLS
x=(GamePad(ButtonRight)-GamePad(ButtonLeft))*10
y=(GamePad(ButtonDown)-GamePad(ButtonUp))*10
Starfield x,y,0
ScrollParticles x,y
ThrowParticle MouseX(),MouseY(),4,Rnd(0,360),0.5,0
ResetDraw
Print "Particles spawn at Mouse co-ordinates"
Print "Use directions to scroll"
Flip
Forever
KillParticles
Immediately kills all particles currently particling.
Symbol 0,"0__0,40/40/40/40/40/40/40/4";
Graphics 512,512,1
Repeat
CLS
ThrowParticle 256,512,2,Rand(-40,40),Rand(1,4),0,0
If MouseDown then KillParticles
Text 256,32,"Hold the mouse",1
Text 256,48,"to kill the particles",1
Flip
Forever
Load and Save
Due to the limitations of Javascript and Browsers and the like, we can't read and write "real" files.
Instead, you're given a single "file" array per project, which you can read or write to and from.
Each "file" has up to 256 values and a maximum size of 32kb.
FileExists
Returns a 1 if the save file exists for this project, or 0 if it doesn't.
Print FileExists()
LoadFile
Loads the previously saved file into memory.
LoadFile
Print ReadFile(0)
ReadFile(slot)
Alternative spellings : ReadString(slot)
Returns the information currently stored in the slot given.
Your "file" is basically an array of 256 elements. Use them wisely!
LoadFile
Print ReadFile(0)
ReadInt(slot)
Returns the information currently stored in the slot given, as an int.
Your "file" is basically an array of 256 elements. Use them wisely!
ReadFloat(slot)
Returns the information currently stored in the slot given, as a float.
Your "file" is basically an array of 256 elements. Use them wisely!
WriteFile(slot,Value)
Stores the value given into the slot.
Your "file" is basically an array of 256 elements. Use them wisely!
Highscore=56
WriteFile(0,Highscore)
SaveFile
SaveFile
Saves the data stored in your file for future reuse.
Highscore=56
WriteFile(0,Highscore)
SaveFile
EmptyFile
Clears out the data within the file, resetting everything to zero.
LoadFile
EmptyFile
SaveFile
File Example
// File Access Example
if FileExists==0
LastScore=37
HighScore=128
BestWord="Giraffe"
// Save Values
WriteFile 0,LastScore
WriteFile 1,HighScore
WriteFile 2,BestWord
SaveFile
Print "Saved!"
// Clear Values
LastScore=0
HighScore=0
BestWord=0
Print:Print "Reset"
Print "Last Score "+LastScore
Print "High Score "+HighScore
Print "Best Word "+BestWord
Endif
// Load Values
LoadFile
LastScore=ReadFile(0)
HighScore=ReadFile(1)
BestWord=ReadFile(2)
Print:Print "Loaded"
Print "Last Score "+LastScore
Print "High Score "+HighScore
Print "Best Word "+BestWord
Audio Commands
PlaySFX "Name of Sound"[ ,Pitch 0.5-3.0, Volume 0-2, Panning -1-1 ]
Plays one of the internal sound effects. You can choose from the library of sounds as heard by clicking the Sounds icon on the main GUI.
Graphics 512,512,0
Repeat
CLS 40,70,100
Volume=1-(MouseY()/512)
Pitch=(MouseX()/256)+0.5
If MouseDown() then PlaySFX("Beeper_Classic",Pitch,Volume)
Flip
Forever
SetEcho "echo mode"
Switches the echo to one of a set of available modes.
Available modes are
Off - No echo
Short - A short echo
Medium - A long echo
Long - A much longer echo
Church - An empty church
Factory - A large empty factory
Can - A tin can
Car - A car
Flowerpot - A flowerpot
Hose - A long hosepipe
Intercom - A retro styled intercom
SmallSpeakers - Some classic desktop speakers
Walkman - Someone elses walkman
Impulse sounds by Fokke van Saane
// Echo Styles
// by Jayenkai
// Created 2021/6/29
e=0
SetEcho e
JMTrackr 140,"<C4r8>A+16G4r16A+4<C4r8>A+16G2r16|C4r8D8D+4D4C4r8D8D+2|C8C8C8C8C8C8C8C8D+8D+8D+8D+8>A+8A+8A+8A+8|C8C8C8C4C8C8C8D+8D+8D+8D+4>A+8A+8A+8|C16r8C16r8C16r8C16r8C16r16C16r16D+16r8D+16r8D+16r8>A+16r8A+16r16A+16r16|C16D+16C16<C8C8C16>C16D+16C16<C8C8C16>C16D+16C16<C8C8C16>C16D+16C16<C8r16C16C16|r1|[d]|r8G+4G+4G+4G+4G+4G+4G+4G+16G+16|C8G+16C16D8G+8C8G+16C16D8G+8C8G+16C16D8G+8C8D8D8G+8|r1|"
Graphics 512,512,1
Repeat
CLS 30,30,80
ResetDraw;SetFontSize 16
hit=MouseHit()
If MouseIn(256,64,256,32,1) and hit
e=e+1
SetEcho e
if GetEcho()=="Off" then e=0
Endif
SetCol 255,255,255
Text 256,64,"Echo '"+GetEcho()+"'",1
SetFontSize 6
y=160
x=96;nm="Beep_1"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=256;nm="Beeper_Fruit_Bonus"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=416;nm="Beeper_Rise"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
y=y+48
x=96;nm="Drum_Low"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=256;nm="Animal_Quack"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=416;nm="Error_2"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
y=y+48
x=96;nm="Explode_High_2"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=256;nm="Explode_Low_5"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=416;nm="Explode_Low_7"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
y=y+48
x=96;nm="Hurt_3"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=256;nm="Jump_3"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=416;nm="Lazer_3"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
y=y+48
x=96;nm="Noise_Crunch"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=256;nm="Noise_Spray_2"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=416;nm="Noise_Stomp"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
y=y+48
x=96;nm="Sonniss_Rock_2"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=256;nm="Sonniss_Plasmagun"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
x=416;nm="Sonniss_Swish_2"; SetCol(255,255,255);Rect(x,y,128,32,1);SetCol(0,0,0);Text(x,y,nm,1);if MouseIn(x,y,128,32,1) and hit then PlaySFX(nm)
Flip
Forever
GetEcho()
Returns the name of the current Echo mode.
SetEcho 5
Print GetEcho()
Say "Text to say",Voice 0-n,Volume 0-1,Speed 0.5-3
Makes the browser say something. Please note that all manner of things will cause this to break, and the voices are all different based on browser, os and system. Don't expect it to be an exact science!
You can generate a list of available voice names using the VoiceCount and VoiceName functions.
Please note that on some systems, the speech will only play after a mouse/touch event, and occasionally might not work at all.
Really, this is incredibly broken!!
Repeat
If MouseHit() then Say "Hello",Rand(0,VoiceCount())
Forever
VoiceCount()
Returns the number of different voices available for speaking with.
If the number is -1, then either the user hasn't yet tapped the screen on an iOS device, or the browser doesn't support speech.
Print "Voices Available"
For n=0 to VoiceCount()
Print " "+VoiceName(n)
Next
VoiceName( Voice 0-n )
Returns the name of the given voice.
// Talky Tester
Graphics 1024,768,1
Repeat
CLS;ResetDraw();SetFontSize 16
mh=MouseHit(); c=VoiceCount()
if c==-1
Print "Speech currently unavailable"
Print "Try clicking the screen"
endif
If c>-1
For n=0 to c
nm$=VoiceName$(n)
y=(n+1)*22
If MouseIn(512,y,1024,20,1)>0 then SetCol 40,80,120:Rect 512,y,1024,20,1:SetCol 255,255,255
Text 512,y,"["+n+"] - "+nm$,1
If MouseIn(512,y,1024,20,1)>0 and mh>0
Say "Hello! My name is "+nm$+", and I am a computer voice. Question?",n
endif
Next
Endif
Flip
Forever
JMTrackr Tempo,Style,MelodyCode[,Seed]
The JMTrackr music tool can be used to create strings of melody, which are then randomly played to create a unique soundscape.
It's a little lacklustre at the minute, but I aim to bulk it up over time, for example, the Style parameter can be either of three values.
"Retro" is a set of light instruments.
"Classic" is basier heavy instruments, with louder drums.
"Hedgehog" tries (but usually fails) to sound like a Megadrive.
Graphics 512,512,0
mdis=1
MelodyString="[1][L][D1z1F1z1H1z1I1z1K1z1H1z1K3z1M1z1I1z1M3z1K1z1H1z1K3z1D1z1F1z1H1z1I1z1K1z1H1z1K3z1M1z1I1z1M3z1K6z2][D1z1D1D1K1z1K1z1I1z1H1z1I1z1F1z1D1z1D1D1K1z1K1z1I1D1H1z1I3z1D1z1D1D1K1z1K1z1I1z1H1z1I1z1F1z1D1z1D1D1K1z1K1z1I1D1H1z1D3z1][D1z1F1z1H1z1I1z1K2z4D1z3F1z1H1z1I1z1K2z2H2z2D1z1F1z1H1z1I1z1K2z4M2z2K1z1I1z1F1z1D2z6][H][KCz4PCz4KCz4DCz4][D4z2F4z2H3z1K4z2I4z2H3z1D8zO][B][D1z3K1z381z3K1z3D1z381z3A1z3C1z3D1z3K1z381z3K1z3D1z781z7][D1z1D1z381z1D1z1D1z381z1D1z1D1z381z1D1z1D1z181z1A1z1D1z1D1z381z1D1z1D1z381z1D1z1D1z381z1D1z1D1z1H1z1F1z1][D][11z131z121z131z161z111z121z131z111z131z121z131z161z111z121z161z111z131z121z131z161z111z121z131z111z131z121z131z161z1611121z161z1][11z511z511z511z511z321z311z511z511z511z511z321z121z1]"
Repeat
CLS 40,70,100
SetFontSize 16
Text ScreenWidth()/2,ScreenHeight()/2,"Click for New Music",1
If MouseHit() then JMTrackr((jRand(1,4)*5)+110,"Classic",MelodyString);mdis=1
Flip
Forever
JMStop
Alternative spellings : MusicStop
Stops any music that is currently playing.
Graphics 512,512,0
mdis=1
MelodyString="G16E32F32G16E16G32G32G32A32G16E32F32G16E32F32G16E16D32D32D32E32D16C16|G8G8F8F8E8E8F8E16F16|C8r16C16E16r16G16r16A16A+16A16F16G8r8|r1|[d]|C16G+16D16G+16C16G+16D16D16C16G+16D16G+16G+16C16D16C32D32|C16G+16C16G+16C16G+16C16G+16C16G+16C16G+16C16G+16C16C16|r8A4A4A4A8|r1|"
OffOn=0
Repeat
CLS 40,70,100
SetFontSize 16
if OffOn==0 then Text ScreenWidth()/2,ScreenHeight()/2,"Click for New Music",1
if OffOn==1 then Text ScreenWidth()/2,ScreenHeight()/2,"Click to Stop",1
If MouseHit() then
OffOn=1-OffOn
if OffOn==1 then JMTrackr((jRand(1,4)*5)+90,0,MelodyString);mdis=1
If OffOn==0 then JMStop
endif
Flip
Forever
System Commands
SetControllerMethod Gamepad/Mouse/Keys
Alternative spellings : SetControlMethod
You can toggle the onscreen gamepad using this function. Set it to GamePad, and if the user taps the screen or clicks with a mouse, the onscreen controls will pop up automagically.
If you set it to Keys or Mouse, then the onscreen controller popup will go away.
Graphics 512,512,1
SetControlMethod Gamepad
Repeat
CLS
Flip
Forever
Notify String, Colour Hue (0-360), Type (0-3)
Creates an onscreen notification, which lasts for exactly 240 frames.
The (currently 4) types of Type are.
0 (default) - A standard popup on the bottom left of the screen. Posting more of these will bump the notification up the screen.
1 - Full screen width, around the 40% height of the screen. Posting more of these will bump the notification down the screen.
2 - Full screen width, around the 40% height of the screen, jumping, bouncing, happy and multicoloured. Posting more of these will bump the notification down the screen.
3 - Full screen width, Scrolls in from the bottom, hangs around the middle, then fades out to the top of the screen. Posting more of these will make a mess in the middle of the screen.
Graphics 512,512,2
Repeat
Cls
v=Rand(1,3)
c=Rand(0,360)
launch=-1
if MouseHit then launch=0
if KeyHit then launch=1
if GamePadHit then launch=2
if GamePad(ButtonDown) then launch=3
// Bottom Notification
If launch==0 then Notify(" Mouse Hit "*v,c,0)
// Centered Notification
If launch==1 then Notify(" Key Hit "*v,c,1)
// Jumping Notification
If launch==2 then Notify(" GamePad Hit "*v,c,2)
// Zoom to Center Notification
If launch==3 then Notify(" Held Down ",c,3)
Flip
Forever
DebugMode On/Off
Switches Debug mode on or off. Anything sent using the command Debug will then end up in the browser's Console log.'
DebugMode On
Debug "Hello World!"
Debug String
Alternative spellings : DebugLog
Sends the requested string to the browser's console log.
DebugMode On
Debug "Hello World!"
GameHandler
GameHandler("Game|Title", "Difficulty|Settings")
The GameHandler is a special command that creates a generic looking menu screen for basic games.
It handles highscores, along with loading and saving, and even has a pause menu with a quit/restart option.
You'll need to incude an .Ingame subroutine which will be called every frame, which is where your game will run. Within this subroutine, try to run exactly one frame's worth of your game.
In order for it to do everything it needs, you should probably also include a .StartGame subroutine to reset all your variables, prepare levels, and other such things at the start of the game.
You can place as many difficulty settings as you'd like into the second string, separated by |'s. Be aware though, that it currently doesn't scroll, so you're probably better off limiting it to a small number of options.
You can use these for difficulty levels, modes or anything else you can imagine.
The variable GameType allows you to refer back to whichever option has been selected on the menu, with the first option being GameType=1, and so on.
Calling EndGame "The reason the game ended" will trigger the GameOver cycle, after which the current Score is added to the high score/last score tables, and the GameHandler returns to the main menu.
If you've defined a Symbol 0, it will be used as the icon displayed on the titlescreen.
You can additionally set the font used in the menu, using the SetHandlerFont command.
// GameHandler Example
// Mouse Clicker
Symbol 0,"0__4?0,4.0.4.0.4?0,4004,0!4,0!4,0!44";
Graphics 512,512,1
SetHandlerFont "Labyrinth"
GameHandler("Mouse|Clicker|2000","5 seconds|10 seconds|15 seconds")
.StartGame
Score=0
// Change the time limit based on the menu option selected.
If GameType==1 then TimeLimit=Mills(1)+(5*1000)+999
If GameType==2 then TimeLimit=Mills(1)+(10*1000)+999
If GameType==3 then TimeLimit=Mills(1)+(15*1000)+999
Return
.Ingame
CLS;ResetDraw()
TimeLeft=Floor((TimeLimit-Mills(1))/1000)
If TimeLeft<0 then
TimeLeft=0
If GameOver==0 then PlaySFX("Beeper_Fruit_Win")
EndGame "Time's Up"
Endif
Text ScreenWidth()/2,ScreenHeight()/2-64,TimeLeft,1
// A Click
If MouseHit() and GameOver==0
// GameOver increases once EndGame has been called
Score=Score+1
// Score is used by the Highscore system
PlaySFX("Beeper_Coin")
ThrowParticle MouseX(),MouseY(),2,Rand(-45,45),Rand(2,5)
Endif
TextScore ScreenWidth()/2,ScreenHeight()/2
Text ScreenWidth()-16,16,"Score to beat "+Highscore,2
// Highscore is the topmost score on the current leaderboard
Flip
Return
GameHandler("Game|Title", "Calendar")
For more information, see the standard form of the GameHandler command.
This special version of the GameHandler will create a calendar based tube of dates for every day this year, with each day having its own highscore, and win parameter.
The ThisLevel variable will contain the number (0-365) of the day of the year selected.
Use the WinLevel command to set the win value for a level. A win of 1 gives a yellow 5 pointed star on the calendar tube. A win of 2 gives a blue 8 pointed star.
// GameHandler/Calendar Example
// Mouse Clicker
Symbol 0,"0__4?0,4.0.4.0.4?0,4004,0!4,0!4,0!44";
Graphics 512,512,2
SetHandlerFont "Labyrinth"
GameHandler("Mouse|Clicker|2000","Calendar")
.StartGame
Score=0
// Change the time limit based on the menu option selected.
TimeLimit=Mills(1)+(10*1000)+999
Return
.Ingame
CLS;ResetDraw()
TimeLeft=Floor((TimeLimit-Mills(1))/1000)
If TimeLeft<0 then
TimeLeft=0
If GameOver==0 then PlaySFX("Beeper_Fruit_Win")
EndGame "Time's Up"
Endif
Text ScreenWidth()/2,ScreenHeight()/2-64,TimeLeft,1
// A Click
If MouseHit() and GameOver==0
// GameOver increases once EndGame has been called
Score=Score+1
// Score is used by the Highscore system
PlaySFX("Beeper_Coin")
ThrowParticle MouseX(),MouseY(),2,Rand(-45,45),Rand(2,5)
Endif
TextScore ScreenWidth()/2,ScreenHeight()/2
Text ScreenWidth()-16,16,"Score to beat "+Highscore,2
if Score>=25 then WinLevel
if Score>=50 then WinLevel 2
Flip
Return
SetHandlerIcon Layer (0-3),Symbol ,x (1.0),y (1.0),width (1.0), height (1.0)
If you're using the default GameHandler style, you can change the images that are drawn in the background, as well as scaling and position.
Symbol 0,"2__I0_0.I0II0_0?II0@II0II0I?0_0.I0?I/0I,0II0I0_0II0,I0I!0I.0II0I0_0I00I0I!0I_II0_0II0I_I!0I.0_I_I_I!0/I0I_I_I!0?I0I_I_I/0?I@6,I/6,I/0,I@6?I?6?I.0II00I/6/I,6/I.0I0,I!6/I,6/I!00I/6/I,6/I!0I_6?I?6?I.00II0.I!6,I/6,I/00I_I_I_I_I_I_I_I00I/VI_I_I0.I_V,I_I_00I_I,VVI_I/0,I_I.VVI_I,0?I_I!V,I@0I0.I_I_VI!0II0?I_I_V,II0II0/I_I_IVI.0_I_I_I?0II0!I_I_II0I0,I0/I.0I_I!0.II0_I?0I,0II0II0II0.I0_0I0II0II0I.0.II00II0_0!II0I0@I.";
Symbol 1,"2__I0_0.I0II0_0?II0@II0II0I?0_0.I0?I/0I,0II0I0_0II0,I0I!0I.0II0I0_0I00I0I!0I_II0_0II0I_I!0I.0_I_I_I!0/I0I_I_I!0?I0I_I_I/0?I@6,I/6,I/0,I@6?I?6?I.0II00I/6/I,6/I.0I0,I!6/I,6/I!00I/6/I,6/I!0I_6?I?6?I.00II0.I!6,I/6,I/00I_I_I_I_I_I.V@I/00I_I.V.I_I0.I_I.VVI_I!00I_I.VVI_I!0,I_IV,I_I?0?I_IVI_I!0I0.I_IVI_I?0II0?I_VI_I.0II0/I_I_I!0_I_I_I?0II0!I_I_II0I0,I0/I.0I_I!0.II0_I?0I,0II0II0II0.I0_0I0II0II0I.0.II00II0_0!II0I0@I.";
Graphics 800,600,2
for n=0 to 3
image=Rand(0,1)
x=Rnd(0.1,0.9)
y=Rnd(0.1,0.9)
width=Rnd(0.2,0.4)
height=Rnd(0.2,0.4)
SetHandlerIcon n,image,x,y,width,height
next
GameHandler("Test")
.StartGame
Return
.InGame
CLS;EndGame
Return
SetHandlerColour Red(/255), Green(/255), Blue(/255)
Alternative spellings : SetHandlerColor, SetHandlerCol
If you're using the default GameHandler style, you can change the background colour used in the main menu.
Graphics 800,600,2
SetHandlerCol Rand(255),Rand(255),Rand(255)
GameHandler("Test")
.StartGame
Return
.InGame
CLS;EndGame
Return
EndGame "Reason"
The EndGame command is used by the GameHandler, to trigger the GameOver routine.
It ends the game, prints "Reason" across the screen, and returns to the main menu.
See the GameHandler command for the complete example of how to use this.
SetControllerText "Controller instructions"
Alternative spellings : SetControlText
When using the GameHandler function, you can set the "Controls : ... message" to whatever you'd like, here.
You only get one line, so use it wisely!
Graphics 800,600,2
SetControlMethod GamePad
SetControllerText "Controls : Left/Right, Fire"
GameHandler "Oh hey,|Let's test"
.StartGame
return
.Ingame
CLS
return
SetScrollerText "Game scrolling message"
Alternative Spellings : SetScrollText
The Scroller Messages text can be set here.
This will be displayed on the GameHandler's title screen, but can also be displayed using the ScrollText command.
Graphics 800,600,2
SetControlMethod GamePad
SetControllerText "Controls : Up/Down, Squeak"
SetScrollerText ">>>-- This is a scrolling message. Look at it scroll. Scrolling away like a pancake. Does a pancake scroll? Hmmm.. Curious. --<<<"
GameHandler "Oh hey|Let's test"
.StartGame
return
.Ingame
CLS
return
WinLevel 0/1/2
The WinLevel command is used by the calendar version of GameHandler, to add stars to the calendar.
See the GameHandler Calendar command for the complete example of how to use this.
SetHandlerFont FontName
Alternative Spellings :
Sets the font to be used within the GameHandler's menu system.
See the GameHandler command for the complete example of how to use this.
Variables used by GameHandler |
Score | Set this value to have it show up in the main menu's highscores. |
Highscore | This is the value of the highest score on the currently selected difficulty level. |
GameType | Which of the menu's options has been chosen. 1 = First option, and so on. |
GameOver | Is 0, until EndGame is called. Once EndGame has been called, increases from 1 to 60. |
Variables used by GameHandler - Calendar Mode |
ThisLevel | When using the Calendar Level Select method, this will contain the number of the chosen date, 0-365. |
ThisYear | The year of the chosen date. (Should always be the same as the current year) |
ThisMonth | The number of the month of the chosen date. (1-12) |
ThisMonthName | The name of the month of the chosen date. (January-December) |
ThisDate | The date of the chosen date. (1-31) |
ThisWeekday | The numerical representation of the chosen day. (0-6) |
ThisWeekdayName | The name of the chosen day. (Monday-Sunday) |
PreProcessors
#CONST VariableName=Value
Defines a constant for PreProcessor usage.
Every instance of $VariableName will be replaced with Value.
#DEFINE VariableName=Value
Defines a variable for PreProcessor usage.
#IF VariableName==/<>/<=/>=Value .. #ENDIF
Checks whether the comparison is true, then either removes or leaves-in the section of code.
#REM .. #ENDREM
Removes all code between #REM and #ENDREM
Notes about PreProcessors.
PreProcessors are more strict than regular script syntax.
Each PreProcessor MUST be at the start of a line, only one single space between commands and variables/values/etc.
You don't "NEED" to work in All Caps, but it helps distinguish things a bit.
These functions work before the main parser, and are primarily used to remove chunks of code from the script.
You could, for example, make use of a "TEST" variable, and have the TEST sections be automagically removed by stripping away the variable later.
You can further make use of these PreProcessor variables within the rest of the script, using $VariableName, reading or writing to the variables as you would any other variable.
Be aware, though, that changing the value of a PreProcessor mid-script, using the regular scripting language, won't be able to alter what the PreProcessor does, since by the point it's been reached by the interpreter, the PreProcessor things will have already been PreProcessed!
// PreProcessor Example
#CONST $SWEET="Gummy Bears"
#DEFINE FRUIT="Banana"
FRUIT="Apple"
#REM
FRUIT="Pear"
#ENDREM
Graphics 512,512,1
#IF FRUIT=="Banana"
Print $SWEET
#ENDIF
Print $FRUIT
Print FRUIT
Reserved Keywords
Running Stats |
Stat_FPS | The current framerate. Updates every second. |
Stat_Perc | How stressed the engine is. Try not to go over 100! |
Constants |
ButtonUp = 0
ButtonRight = 1
ButtonDown = 2
ButtonLeft = 3
ButtonA = 10
ButtonB = 11
ButtonY = 12
ButtonX = 13
ButtonL1 = 14
ButtonR1 = 15
ButtonL2 = 16
ButtonR2 = 17
ButtonL3 = 18
ButtonR3 = 19
ButtonStart = 20
ButtonSelect = 21
ButtonBack = 21
StickLX = 30
StickLY = 31
StickRX = 32
StickRY = 33
DPadUp = 34
DPadRight = 35
DPadDown = 36
DPadLeft = 37 | These are the values used by the Gamepad functionality. |
Internal Values |
Let | Traditionally used to tell the language to set a value, here the keyword simply disappears. It's used internally to perform its original task, but it never gets seen. |
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.
Purpose
The intention of this scripting language is to allow easily accessible tests and 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 is capable enough to write a minimal 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, however, 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, or use the Export feature, if you are!
No cookies, No evils, Just coding.
Discussion, Forum, Showcase, etc
There isn't yet a dedicated forum for JSE, but there may be in the future.
The website SoCoder.net is currently the forum home for the language, and will likely remain so until the people at SoCoder get sick of hearing about it!
To be fair, the language was mostly coded with that forum in mind, so all's good, I hope.
SoCoder has basic Forum functionality, (with sidebars!) but also has spaces for personal blogs, as well as posting Showcases, Code Snippets, Articles and more.
Head on over to SoCoder.net, and get yourself an account.
Welcome aboard.
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.
To be on the safe side, please export your projects as often as you can, just in case your browser decides it's going to be a goit!
The exported file is simply a text file, renamed with a .jse extension, so it should be incredibly easy to move it between places.
Email it to yourself, grab it on your other system.
Use DropBox, iCloud, an NAS drive, or more.
Anything goes, really.
As long as you can grab the .jse file on the other end, you'll be fine.
Additionally, the more of your code you post to forums and the like, the less you're likely to lose.
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 and downloads going on.
Bah, humbug!
.. But I have Javascript disabled
Then you can't use the site. Sorry.
What's going on with the FPS display?
In order, the stats are..
Number of "Tokens" parsed in the frame.
-=-=-
Spaghetti Stats : If these get too high, you'll have a bad time, and are probably missing an Endif, Return, or similar.
Gosubs - Repeats - Ifs
-=-=-
Drawing Stats : If these get too high, you'll get slowdown.
Sprites - Polygons - Text
-=-=-
Framerate (fps)
-=-=-
Browser Time Usage % : Try to aim below 100%. Going about 100 will slow down the framerate.
If this stat reaches 250%, it'll cause the parser to stop, have a little frame's worth of a rest, then carry on.
-=-=-
Running/Stopped, with the current frame number.
Credits
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.
Jayenkai was also helped by Michael Fernie, who offered more than a few helpful tips and pointers, along the way.
The language uses absolute barebones Javascript and Canvas functions, so "should" function correctly in any decent browser, as of 2021.
Fonts
Font 1 is from the Amstrad CPC.
Font 2 is from the Commodore 64.
Font 3 is from the ZX Spectrum.
Font 4 is from the BBC Micro Computer.
Font 5 is the Amiga's default "Topaz" font.
Font 6 is the default font for Amos on the Amiga, and is known as "2001"
All the above fonts are used without permission, and may be replaced at any point if anyone important shows up and starts complaining that I've stolen their fonts.
Fonts 7 through 33 are from DamienG's ZX Origins collection.
A fantastic selection of 8-bit fonts.
Sounds
Most of the sound effects have been created/gathered over the years by Jayenkai.
The Sonniss sounds are all from their [url=https://sonniss.com/gameaudiogdc]GameAudioGDC packs[/url].
Many thanks to them for creating, and uploading them for free use.
Impulse
The Impulse sounds, for the Echo functionality, were gathered from Impulse sounds by Fokke van Saane's website.
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."
Patreon
Patreon Supporters
My Patreon page is somewhat lacklustre, as far as Patreon Specific content goes.
I'm constantly apologising for this lack of extra juicy content, but it's mostly because I instantly give everything away for free on my site.
I'm just not organised enough to have anything pre-prepared, that I can have available as a Patreon Sneak Peek for even a short while.
Even so, the following wonderful people are still helping fund the crazy amount of content that I create, and that's awesome!
Many, many, many thanks to the following people.
Rajasekaran Senthil Kumaran
Otakupunk
Seth A. Robinson
James Wallis
Fardin Fahim
Kiranteja Mannem
If you'd like to help feed me buckets of Ramen, you can find the Patreon page here