File

From Bennu Wiki
Revision as of 03:51, 2 September 2009 by Madman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This is about the filetype. Did you mean the local variable file or the function file()?

Up to Filetypes


Description

A file is a container for graphics, identified by a non-negative integer (0 or higher). It holds all information about the contained graphics (pixels, width, height, depth, name, etc). Each of these graphics have a unique identifier inside the file (positive int).

A file can be created for example by loading an FPG (Fichero Para Gráficos, meaning "file for graphics") into it, by using fpg_load(), which creates a new file with the graphics from the loaded FPG and returns a unique identifier. Another option is to create a new, empty one by using fpg_new(). Don't let the name fpg_new() fool you: fpg_new() has nothing to do with the filetype FPG. This is because the FPG format is only for files and not for internal use. There are more ways to load graphics into a file.

A file can be used by using the local variable file or by using the identifier in the various functions with a file parameter.

Don't forget to unload it with fpg_unload() after use.

Example

import "mod_map"
import "mod_grproc"
import "mod_key"
import "mod_wm"

Global
    int file_id;
    int file_id2;
End

Process Main()
Begin

    // Load FPG
    file_id = load_fpg("example.fpg");
    file_id2 = load_fpg("example2.fpg");

    // Set locals for display of graph
    file = file_id;
    graph = 1;
    x = y = 50;
    
    // assign Ship to use example2.fpg
    Ship(300,100,5,file_id2,1); // undefined in this sample
    
    Repeat
        frame;
    Until(key(_ESC)||exit_status)

End

Used in example: load_fpg(), key(), x, y, file, graph. process

Media in example: example.fpg

Note: nothing will be seen unless you have an FPG "example.fpg" with a graphic with ID 1.


Filetypes
FBMFGCFHFPGFPLINCMAPPALPNGPRG