GRAPHICS

 

Screen

Sets the screen mode. Please note that all objects and images will be destroyed. So load/reload everything after this command. This is a DirectX-limit.

Usage:

SCREEN width, height, depth [, mode]

Notes:

You can also use thing command as function which takes no parameters. This points to screen buffer and becomes handy in conjunction with CopyBox.

 

Lock, Unlock

Locks a buffer for fast pixel operations (GetPixel2, PutPixel2). After you finish the task, always remember to unlock the buffer. If buffer is not specified, current buffer will be used (usually screen). Point a buffer with Screen() and Image().

Usage:

Lock [buffer]

Unlock [buffer]

Example:

Lock(Image(myImage))

 

GetPixel, PutPixel

Reads a pixel value from current buffer. Puts a pixel to current buffer. These commands are designed for advanced users.

Usage:

pixel = GetPixel(X, Y [,buffer])

PutPixel(X, Y, pixel [,buffer])

Example:

SCREEN 640,480

AddText "Press any key to copy..."

'First make a gradient

For i=0 To 240

    Color 0,i+15,0

    Line 0,i,640,i

Next i

DrawScreen OFF

WaitKey

'make 154 481 iterations, copy each pixel

For y=0 To 240

For x=0 To 640

    PutPixel x,480-y,GetPixel(x, y)

Next x

Next y

DrawScreen

WaitKey

 

GetPixel2, PutPixel2

The same as above, but for locked buffers only.

 

CopyBox

Multi-purpose graphics-portion-copy-thingy. Ignores mask colour. Use Screen() and Image() to point buffers.

Usage:

CopyBox x1, y1, width, height, x2, y2 [, source_buffer] [, destination_buffer]

Example:

'Load the map and cow

themap=LoadImage("Media/map.bmp")

cow=LoadImage("Media/cow.bmp")

'Copy the cow to the map - permanently

CopyBox 0,0,30,25,100,80,Image(cow),Image(themap)

While Not EscapeKey()

    Cls

    'draw the map

    DrawImage themap,MouseX()-200,MouseY()-150

    DrawScreen

Wend

End

 

Color, ClsColor

Sets the current drawing colour. ClsColor sets the current background colour (defaults to blabk – RGB:0,0,0). See Cls.

Usage:

Color red, green, blue

ClsColor red, green, blue

 

Cls

Clears the current buffer (usually screen) to ClsColor. However, DrawScreen does this for you by default.

 

Dot

Paints a dot to the screen in the current drawing colour.

Usage:

Dot X, Y

 

Line

Draws a line to given coordinates screen in the current drawing colour.

Usage:

Line X1, Y1, X2, Y2

 

Box

Draws a box to screen. Optionally you can make it outlined. Filled by default.

Usage:

Box X, Y, Width, Height [, filled]

·         Filled 1 to enable, 0 to disable

 

Circle

Renders a circle to screen. Optionally you can make it outlined. Filled by default.

Usage:

Circle x, y, radius [, filled]

 

Ellipse

The same thing as above, but you can specify its size in more detail. See the example.

Usage:

Oval x, y, width, height [, filled]

Example:

FrameLimit 40

Color cbred

ep=1

e=50

Repeat

    'animate

    e=e+ep

    If e>100 Or e<0 Then ep= -ep   

    'draw

    Ellipse 200-e/2,150-((100-e)/2),e,100-e

    DrawScreen

Until EscapeKey()

 

PickColor

Picks a colour from screen coordinates an sets the current drawing colour to it.

Usage:

PickColor X, Y

 

ScreenGamma

Alters the colour balance of screen in runtime. You can, for example, fade screen black ot white. This effect only works in fullscreen mode. Also, call this command only once in a loop and only if it's necessary.

Usage:

ScreenGamma red, green, blue

Example:

SCREEN 640,480,16,cbfullscreen

themap=LoadImage("Media/map.bmp")

While Not EscapeKey()

    Cls

    'First draw the map

    DrawImage themap,100,50

    oldgamma=gamma

    If LeftKey() Then gamma=gamma-1

    If RightKey() Then gamma=gamma+1

    If gamma< -255 Then gamma= -255

    If gamma>255 Then gamma=255

    If KeyDown(cbkeyreturn) Then

        'hue red

        ScreenGamma 255,0,0

    Else

        'if changed, update gamma

        If oldgamma<>gamma Then ScreenGamma gamma,gamma,gamma

    EndIf

    Text 0,0,"Use arrows to adjust screen gamma."

    Text 0,14,"Press Return for Blood Fill"

    DrawScreen

Wend

End

 

DrawToImage

Directs all drawing operations to an image. See the example.

Usage:

DrawToImage image_variable

Example:

themap=LoadImage("Media/map.bmp")

angle=0

While Not EscapeKey()

    Cls

    'Draw the map to mouse coordinates

    DrawImage themap,MouseX() -200,MouseY() -150

    'Manipulate image every second

    If TIMER()>moment+1000 Then

        DrawToImage themap

        'red filled circle

        Color 255,0,0

        Circle 200+Cos(angle)*100-5,150-Sin(angle)*100-5,10

        'black hollow circle (outlines)

        Color 0,0,0

        Circle 200+Cos(angle)*100-5,150-Sin(angle)*100-5,10,OFF

        angle=angle+10

        moment=TIMER()

        'set drawing back to screen

        DrawToScreen

    EndIf

    'Let's see what we have here

    DrawScreen

Wend

End

 

DrawToScreen

Returns the drawing operations to screen. See the DrawToImage-command example.

 

DrawToWorld

Game world coorinates differ from screen coordinates:

 

    

 

Normally drawing commands (line, box, circle etc.) render accordingly to screen coordinates. Sometimes it's handy to be able to render into game world without the need to convert coordinates between these two systems. For example, you want to draw a line for rail gun. In order to draw 2d-graphics correctly, you should first call DrawGame, then draw your stuff, and finally call DrawScreen. Optionally you can turn this behaviour ON for images and text as well. Defaults OFF.

   

Usage:

DrawToWorld gfx [, images] [, text]

·         use ON/OFF for each parameter.

 

Example:

'Set all drawing commands to draw to game world

DrawToWorld ON

FrameLimit 40

'Create scene

grass= MakeObjectFloor()

lawn= LoadImage("Media\grass.bmp")

PaintObject grass, lawn

character= LoadObject("Media\guy.bmp",72)

AddText "Use arrows to move..."

 

Repeat

    'Guide

    If LeftKey() Then TurnObject character,5

    If RightKey() Then TurnObject character, -5

    If UpKey() Then MoveObject character,2

    If DownKey() Then MoveObject character, -2

    'Camera follow

    CloneCameraPosition character

    DrawGame   

    'draw a hollow circle at the center

    Circle-5,5,10,OFF    

    'draw a line

    Line 0,0,50, -50   

    'draw a box

    Box-100,100,200,160,OFF   

    DrawScreen

Until EscapeKey()

 

Smooth2D

Affects the quality of ResizeImage and RotateImage, but if ON, results in slower loading. Defults OFF.

Usage:

Smooth2D ON/OFF

 

ScreenShot

Records a BMP image of screen. Call just before DrawScreen. Prefer not to use PrtSc.

Usage:

ScreenShot filename$

 

UpdateGame

Refresh collision system and update animations. You don't need to call this command, because DrawScreen will call it automatically if necessary. A typical situation where you need this command occurs if you've enabled automatic collision system for an object you're currently following with CloneCameraPosition. Then call this before.

 

DrawGame

See DrawToWorld help.

 

DrawScreen

Renders the screen including all game world objects and drawn graphics. Very Important. Don't forget – or your game doesn't show a thing.

Usage:

DrawScreen [auto-CLS] [, mode]

·         Optional AutoCLS defaults ON.

·         mode: 0=GFX Card VSync, 1=CPU Vsync (default)

 

Image

Returns an image buffer. See CopyBox.

Usage:

buff = Image(image_variable [, frame])

 

GetRGB

Tell the current drawing colour.

Usage:

result = GetRGB(channel)

 

ScreenWidth

Tells current window width (or screen) in pixels.

Usage:

width = ScreenWidth()

 

ScreenHeight

Tells current window height (or screen) in pixels.

Usage:

height = ScreenHeight()

 

SreenDepth

Tells current colour depth.

Usage:

depth = ScreenDepth()

 

GFXModeExists

Returns True if specified full screen resolution is available on current graphics adapter. It might be a good idea not to hard-code screen modes to your games. For example, small TFT-monitors are incapable to display larger resolutions than 1024x768.

Usage:

available = GFXModeExists(width, height, depth)