vurlG
Jump to navigation
Jump to search
vurlG is a (work in progress) extension of vurl that provides graphical output as well as mouse/keyboard user interaction, created using LÖVE.
environment
vurlG runs from either a single file containing vurl code, or a directory containing a file named "main.vurl" from which code is executed, as well as various media files (images, sounds) that are used. vurlG outputs to an 800x600 screen that may be drawn to with various commands.
note that commands that import files (image
, sound
, etc.) should not be called repeatedly. instead, call it once, store that in a variable, and then just reuse the variable. for example, avoid this code:
while 1 clear # do NOT do this, as repeatedly importing files will be very slow. draw (image image.png) end
instead, do this:
# import the image only once set image (image image.png) while 1 clear # reuse the variable draw [image] end
commands
vurlG is the same as vurl, except with the following commands.
command | description |
---|---|
frame |
defines a code block that is run every frame. this is equivalent to while 1 , except after each iteration the code will yield so that the screen may be drawn.
|
clear |
clears the screen. |
line [x1] [y1] [x2] [y2] |
draws a line between two points. |
rect [x] [y] [width] [height] |
draws a rectangle with its top-left corner at the given position and with the given width and height. |
circle [x] [y] [radius] |
draws a circle with its center at the given position and with the given radius. |
ellipse [x] [y] [width] [height] |
draws an ellipse with its center at the given position and with the given width and height. |
text [text] [x] [y] |
draws text at the given position. |
color [r] [g] [b] |
sets the current color to draw things with. each RGB value is a number from 0-255. |
translate [x] [y] |
translates all further drawing operations by the given coordinates. |
rotate [angle] |
rotates all further drawing operations by the given angle in radians. |
scale [x] [y] |
scales all further drawing operations by the given coordinates. |
origin |
resets all transformations. this happens automatically before each frame. |
image [path] |
returns an image from the given path (relative to the source directory). |
draw [image] [x] [y] |
draws an image at the given position. |
sound [path] |
returns a sound from the given path (relative to the source directory). note that this command imports the whole file into memory all at once, so it's best to use this for short sounds. |
music [path] |
returns a sound from the given path (relative to the source directory). note that this command should be used for longer audio files (such as music) instead of sound , to avoid using up a lot of memory at once.
|
play [sound] |
plays a sound. |
stop [sound] |
stops a sound. if no argument is given, stops all sounds. |
mousex |
returns the X position of the mouse. |
mousey |
returns the Y position of the mouse. |
mousedown [button] |
returns whether a given mouse button is currently pressed. 1 is left click, 2 is right click, and 3 is middle click. [button] defaults to 1 if unspecified. |
keydown [key] |
returns whether a given key is currently pressed. the key codes are the same as the key constants used in LÖVE. |
timer |
returns the amount of time that has passed since the start of the program, in seconds. |
random [min] [max] |
returns a random number in the given range. |