Animations

spriteanimation (image,lines,rows,timer,direction)
spriteframe (animation)
framenumber (animation)

 

Collsion Detection

boxcoll (x1,y1,w1,h1,x2,y2,w2,h2)
pixelcoll (image1,ax,ay,image2,bx,by,skip)
circlecoll (x1,y1,r1,x2,y2,r2,offset)
imagecoll (image1,ax,ay,image2,bx,by)

 

File Management

open (file,"r/w/a")
close (file)
fprint (file, string)
finput (file)
eof (file)
eoln (file)
fileexists (file)
directoryexists (directory)
makedir (directory)
removedir (directory)
changedir (directory)
deletefile (file)
system (program)

 

Graphic

line (x1,y1,x2,y2)

Draws a line from the first coordinates x1,y1 to x2,y2 where the upper left corner of the window is (0,0). Colour has to be set with colour (r,g,b,).

Example

openwindow (640,480,32,"Line Test")
colour (0,255,0)
line (10,10,250,400)
redraw()
wait (5000)
closewindow()


dot (x,y)

Draws a dot at given coordinates.

dot (200,150)
circle (x,y,radius)

Draws a circle at x,y position at screen with given radius (in pixels).

Example
openwindow (640,480,32,"Circles")
cls()
circle (320,240,200)
end
redraw()
key=inkey()
closewindow()
fillcircle (x,y,radius)

Draws a filled circle at x,y position at screen with given radius (in pixels).

Example
-- ported from an example of SDL_Basic
-- from Dave Ashley (http://www.linuxmotors.com/SDL_basic/)
-- to EGSL by Markus Mangold

openwindow (640,480,32,"Circles")
cls()
for i=1,1000 do
w = int(rnd()*50)+1
s=3
x=int(rnd()*640)+1
y=int(rnd()*480)+1
colour (0,0,0)
fillcircle (x,y,w)
colour (int(rnd()*128+1+100),0,0)
fillcircle (x-s,y-s,w)
end
redraw()
key=inkey()
closewindow()
box (x1,y1,x2,y2)

Draws a box from coordinates x1,y1 (upper left corner) to x2,y2 (lower right corner).

Example
box (100,100,320,200)
fillbox (x1,y1,x2,y2)

Draws a filled box from coordinates x1,y1 (upper left corner) to x2,y2 (lower right corner).

Example
fillbox (10,50,75,250)
ellipse (x,y,xradius,yradius)

Draws an ellipse at x,y with x-radius and y-radius. If x-radius and y-radius are equal, a circle is drawn.

Example
ellipse (320,240,200,50)
fillellipse (x,y,xradius,yradius)

Draws a filled ellipse at x,y with x-radius and y-radius.

Example
fillellipse (100,100,50,35)
triangle (x1,y1,x2,y2,x3,y3)

Draws a triangle at x1,y1,x2,y2 and x3,y3

Example
triangle (10,10,50,50,90,90)
filltriangle (x1,y1,x2,y2,x3,y3)

Draws a filled triangle at x1,y1,x2,y2 and x3,y3

Example
filltriangle (10,10,50,50,90,90)
alphachannel (value)

Sets the alphachannel for all graphics primitves and image blitting functions. Value can range from 0-255. 255 means opaque, 0 means transparent.

Example
alphachannel (128)

 

Helper functions

wait (ms)
timeleft()
setframetimer (frames)
timerticks()
ostype()
int (number)
rnd()
chr (code) [Pascal: chrstr]
asc (char)
val (string)
left (string,pos)
right (string, pos)
mid (string, pos, length)
insert (string1, string2, pos) [Pascal: insertstr]
len (string)
time()
date()
uppercase(string) [Pascal: upper]
lowercase (string) [Pascal: lower]
arguments()
cos
sin
sqrt
abs
floor

 

Image

loadimage (filename)

Loads an image into the given variable (you can also call it "slot"). If you ommit the full path, the directory where your script is located is used. The following image formats are fully supported, expecting the given image in RGB format:
BMP
JPEG, JPEG2000
PNG/APNG, MNG, JNG
GIF
TGA
DDS
PBM, PGM, PPM, PAM, PFM
TIFF
PSD
PCX
XPM
Example
myimage = loadimage ("fighter.png")
putimage (x,y,image)

Draws a loaded image onto the screen at the given x and y position. All drawing operations must be made visible with redraw() or sync().

Example
putimage (100,150,myimage)
drawimage (x,y,w,h,xscreen,yscreen,image)

This draws a part of a loaded image onto the screen. Starting from the x and y position of the image with w and h pixels width resp. height at the screen position xscreen and yscreen.

Example
drawimage (10,10,64,32,100,100,myimage)
copyimage (x,y,w,h,srcimage)

This copies a part of the srcimage into a new slot.

Example
newimage = copyimage (0,0,32,32,myimage)
grabimage (x,y,w,h)

Grabs an image from the screen and puts it into a slot.

Example
anotherimage = grabimage (10,250,32,32)
imagewidth (image)

Returns the width of an image as an integer.

Example
w = imagewidth (myimage)
imageheight (image)

Returns the height of an image as an integer.

Example
h = imageheight (myimage)
saveimage (image,filename)

Saves an image onto the disc in the bmp format.

Example
openwindow (640,480,32,"Screenshot")
circle (320,240,240)
screenshot = grabimage (0,0,640,480)
saveimage (screenshot, "screenshot.bmp")
closewindow()
fliphorizontal (srcimage)

Flips the source image horizontal and stores it into a new slot.

Example
flipped = fliphorizontal (myimage)
flipvertical (srcimage)

Flips the source image vertical and stores it into a new slot.

Example
flipped = flipvertical (myimage)
zoomimage (srcimage,x,y)

Zooms the source image and copies the result into a new image, x and y are real numbers which means a zoom level of 1.0 is the original size. You can specify each a value for the x-axis and for the y-axis.

Example
newimage = zoomimage (srcimage, 1.5, 2.0)
rotateimage (srcimage,angle,zoom)

Rotates the source image with given angle and given zoom factor.

Example
newimage = rotateimage (srcimage, 220.5, 1.0)
colourkey (r,g,b)

colorkey (r,g,b) alternatively [works only with Lua not in Pascal]

Sets the colourkey (i.e. not drawn=transparent part) for next loaded or created image. Default is 255,0,255.

Example
colourkey (120,5,117)
nocolourkey()

nocolorkey() alternatively [works only with Lua not in Pascal]

Sometimes you might want to load an image without a transparent part, so the colourkey is turned off until a new colourkey is set.

Example
nocolourkey()

freeimage (image)
createimage (width,height)
startimagedraw (image)
stopimagedraw()
imagered (x,y,image)
imagegreen (x,y,image)
imageblue (x,y,image)
imagealpha (x,y,image)
loadtileset (filename, lines, rows, string)
drawtile (x, y, textstr, tileset)
alphachannel (value)

Sets the alphachannel for all graphics primitves and image blitting functions. Value can range from 0-255. 255 means opaque, 0 means transparent.

Example
alphachannel (128)

Joystick

joystickplugged()
getjoyx()
getjoyy()
getjoybutton(button)
numberjoybuttons()

Keyboard

getkey()
inkey()
keystate (key)

 

Mouse

mousex()
mousey()
mouseb()
mousehide()
mouseshow()
mousezone (x1,y1,x2,y2)

 

Screen

openwindow (x,y,b,caption)

screen (xsize,ysize,b,caption) alternatively [works only with Lua not in Pascal]

Opens a graphics window which is not fullscreen. Due to the limitations of SDL, only one window can be opened per time. This should be the first function to be called before any other function. The window will have the size of xsize * ysize with b bits depth. B can be 8..32 or 0. 0 is now recommended because it sets the windows depth to the used desktop depth.

Example
openwindow (640,480,32,"My Window")
closewindow()

Shuts everything down and releases the memory. Should be the last called function of your program. After that you can open a new window.

Example
closewindow()
clearscreen()

cls() alternatively [works only with Lua not in Pascal]

Clears the screen with current colour set with backcolour function. Default colour is black.

Example
clearscreen()
colour (r,g,b)

color (r,g,b) alternatively [works only with Lua not in Pascal]

Sets the drawing colour. All drawing functions executed after this will have current colour.

Example
colour (255,255,0)
-- sets colour to yellow
backcolour (r,g,b)

backcolor (r,g,b) alternatively [works only with Lua not in Pascal]

Sets the background colour in RGB format.

Example
backcolour (0,0,255)
-- sets background to blue
redraw()

Everything in EGSL is drawn to the double buffer. In order to make it visible you have to call this function.

Example
redraw()
togglefullscreen()

EGSL starts the graphical window in windowed mode. This function toggles between windowed and fullscreen mode.

Example
openwindow (640,480,32,"Go to fullscreen")
togglefullscreen()
wait (5000)
closewindow()
setcaption (caption)

With this you can change the initial caption of your window set with openwindow.

Example
openwindow 640,480,32,"First caption")
wait (5000)
setcaption ("Second caption ...")
wait (5000)
closewindow()
resizewindow (x,y)

This function changes the window size in the running application. After that the content of the window is empty and evrything has to be drawn again.

Example
openwindow (640,480,32,"Resize Window")
color (255,255,0)
fillcircle (320,240,150)
redraw()
inkey()
resizewindow (800,600)
fillcircle (400,300,250)
redraw()
inkey()
closewindow()
sync()

This is only thought for lazy programmers. ;-) It's actually a redraw() followed by the wait (timeleft()) statement.

Example
sync()
screenwidth()

This returns the actual width of the graphics screen.

Example
size=screenwidth()
drawtext (0,0,size)
screenheight()

This returns the actual height of the graphics screen.

Example
size=screenheight()
drawtext (0,0,size)
screenred (x,y)

It returns the value of the red amount of the pixel located at x,y. Value can range from 0-255.

Example
screen (640,480,"GetPixel Test")
color (123,50,70)
dot (200,200)
red=screenred (200,200)
--' red has the value of 123
screengreen (x,y)

It returns the value of the green amount of the pixel located at x,y. Value can range from 0-255.

Example
screen (640,480,"GetPixel Test")
color (123,50,70)
dot (200,200)
green=screengreen (200,200)
--' green has the value of 50

screenblue (x,y)

It returns the value of the blue amount of the pixel located at x,y. Value can range from 0-255.

Example
screen (640,480,"GetPixel Test")
color (123,50,70)
dot (200,200)
blue=screenblue (200,200)
--' blue has the value of 70
screenalpha (x,y)

It returns the alpha value of the pixel located at x,y. Value can range from 0-255.

Example
screen (640,480,"GetPixel Test")
alphachannel (128)
color (123,50,70)
dot (200,200)
alpha=screenalpha (200,200)
--' alpha has the value of 128

 

Sound and Music

loadsound (soundfile)
playsound (soundname,volume, channel, loop)
playmusic (musicfile,volume,loop)
loadmusic (musicfile)
pausemusic()
resumemusic()

 

Text output and input

drawtext (x,y,text)
input (x,y,length) [only with embedded font]
loadbmpfont (filename, lines, rows, fontface)
bmptext (x,y,text,font)
bmpinput (x,y,length,font)
True type font support removed from version 1.4.0 on:

loadfont (font,size) Deprecated!
text (x,y,text,font) [in Pascal: textout (x,y,text,font)] Deprecated!
ttfinput (x,y,length,font,fontspacing,fontsize) [works best with monotyped fonts] Deprecated!