How to

The canvas will loop when (run) is encountered. On each loop it will run (update) then run (draw). As such, you need to overwrite the existing, empty, update and draw procedures in the global scope of your slope code. Do note that after you execute your code (that includes (run) in it) you will need to click on the canvas (outlined with dashed lines) to focus it and then your key-presses will register.

Procedures

There are a number of basic drawing primitives and similar things set up for the canvas development system:

Colors

The above procedures take a color which is a number. The colors are as follows:

This is a mimicking of the gameboy pallate, but in blue and with a few minor changes.

Other values

You can get the screen height and width (the bounds) with the values (not a procedure): screen-width and screen-height. So, to draw a circle in the center of the canvas: (circle (/ screen-width 2) (/ screen-height 2) 4 4). Note that the coordinate system is top-down. As such 0,0 is the top left and screen-width,screen-height is the bottom right.

Debugging

This is rough right now (as is this system in general). At present, the best option is to use the browser console and output text to it: (write (usage) console-out). That will output an array of all of the known procedures for you to reference. You can, of course, also use it to get other sorts of messages for your code. Sadly the slope-js system is not as solid for live debugging as the desktop (go) system.

Future

I intend to expand the drawing options, though not too much. I also intend to allow for basic bleep and bloop style sounds. Some niceties will likely be added to make certain common tasks easier. The math lib, imported automatically, has already been filled out significantly from where it was to support calculating rotations, arcs, etc. I plan to change from an input box to a file load eventually, but right now the text input box is easier for testing. I believe there is technically enough here to make a pong or breakout clone. You could probably even make a simplistic pacman-like game. A scrolling or stationary shooter should also be pretty doable. My vision for this as a system is to use very basic building blocks to make simple games. This is not intented to be a nintendo or pico-8. Heck, it will barely be an atari... maybe a Magnavox Odyssey-like system might be closest to the vision.

Loadable/Runable Example Code

The following buttons will replace any code that is in the code input area of this website with the given exammple code. You can then edit and/or run the code. When you click on one of the buttons this dialog will be closed and the code input area will be focused for text entry.