Advance

From Bennu Wiki
Jump to: navigation, search


Definition

INT advance ( <INT distance> )

Moves the calling process forward by distance units in the direction of the process' angle.

This function is influenced by the local variables angle and resolution.

Parameters

INT distance - Distance to advance in units.

Returns

INT : Returns true if successful and false if failed.

Example

import "mod_grproc"
import "mod_map"
import "mod_wm" // for exit_status
import "mod_key" // for key()
import "mod_proc"

Process Main()
Private
    int my_proc;
Begin

    proc(); //create a new process
    proc2(); //create a new process

    Repeat
        frame;
    Until(key(_ESC) || exit_status)

OnExit

    signal(my_proc,S_KILL);

End

Process proc()
Begin

    // Create a cyan square and assign it to 'graph'
    graph = map_new(100,100,8);
    map_clear(0,graph,rgb(0,255,255));

    // Set starting position
    x = 50;
    y = 50;

    // This loop makes this process advance 3 pixels every frame
    Loop
        advance(3); // advance 3 pixels
        frame;
    End

End

Process proc2()
Begin

    // Set resolution to 100
    resolution = 100;

    // Create a cyan square and assign it to 'graph'
    graph = map_new(100,100,8);
    map_clear(0,graph,rgb(0,255,255));

    // Set starting position
    x = 50*resolution;
    y = 150*resolution;

    // This loop makes this process advance 3/100 pixels every frame
    Loop
        advance(3); // advance 3/100 pixels
        frame;
    End

OnExit

    map_unload(0,graph);

End

Used in example: key(), signal(), map_new(), map_clear(), rgb(), advance(), map_unload(), exit_status, graph, x, y, resolution


Mod_grproc
Globals None
Imported:
DumptypeFadingFpsFrametimeFullscreenGraphmodeM7MouseRestoretypeScalemodeScaleresolutionScaleresolutionaspectratioScaleresolutionorientation
Constants None
Imported:
BACKGROUNDBABLENDBALPHABHMIRRORBNOCOLORKEYBSBLENDBTRANSLUCENTBVMIRRORCOMPLETEDUMPCOMPLETERESTORECSCREENDOUBLEBUFFERHWSURFACEM1024X768M1280X1024M320X200M320X240M320X400M360X240M376X282M400X300M512X384M640X400M640X480M800X600MODE16BITSMODE16BPPMODE2XSCALEMODE8BITSMODE8BPPMODEDOUBLEBUFFERMODEFRAMELESSMODEFULLSCREENMODEHARDWAREMODEMODALMODEWAITVSYNCMODEWINDOWNORESTOREPARTIALDUMPPARTIALRESTORESCALEHQ2XSCALENOFILTERSCALENONESCALENORMAL2XSCALESCALE2XSCALESCANLINE2XSCREEN
Locals None
Imported:
AngleCnumberCtypeSpecial:Badtitle/NS108:FileFlagsHeightRegionResolutionSizeSizexSizeyXXgraphYZ
Functions Advance()Collision()Collisionbox()Collisioncircle()Getangle()Getdist()Getrealpoint()Xadvance()