Graphics question

Started by quasist, December 07, 2009, 10:29:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

quasist

It was fun installing bennu (on Windows XP) and making some simple "hello, 1000 random lines :)" projects for Wiz.
Since It is hard for me to uderstand spanish soucecode examples I have few questions.

As I suppose - when you DRAW_... someting it becomes a process(or something alike) and still presents onwards with it's ID. Am I correct?

How to draw a sprite on screen? Is it possible without putting it to graphics library?
Is it like

int i_gfx[127];
...

i_gfx[0]=Load_Png("gfx/wall00ne.png");

...Function how to draw multiple i_gfx[0] with X and Y on screen?

...unload from memory at shutdown

As I think I will need to make something alike
(idea in C format)
i_image[i_image_count++]=Draw_ ... somehow i_gfx[0] :P

and clear all drawing in i_image array at clearing the screen ?
Function Int Write_Signature()
Private
Begin
End;

Windgate

I can't understand all your question, but let's see:

Every PROCESS has a local variable called graph, if you do graph = load_png ( ... ), the process will show the png.

You need call 1 process for each graph you want to have on screen, it is not possible to have a process having more than 1 graphic.

I hope it help you...
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

Drumpi

When you draw something with DRAW_* functions, is not a "process", maybe an item, or class. It returns an ID and you can use it with MOVE_DRAW to move it, or DELETE_DRAW, etc, but is not a process.
A process it's a code, generally with a graphic, with his own properties, located on LOCAL VARIABLES (like X, Y, ANGLE, ALPHA...). You can't rotate a DRAW_* item, or change it form, color or else... but is faster to draw and move (i think, because it not have a code to execute, or lots of variables to check).

And yes, you can load maps without use an FPG. MAP and PNG are maps supported files that you can use alone. They are stored internally in FPG=0, so, you must do
FILE=0;
in every process you want to use it, and assign the ID that LOAD_* returns in GRAPH local variable. I.e:

int my_map, other_map;
my_map=LOAD_PNG("bored.png");
other_map=LOAD_PNG("happy.png);

PROCESS one ()
BEGIN
FILE=0;
GRAPH=my_map;
//rest of code
END
PROCESS two ()
BEGIN
FILE=0;
GRAPH=other_map;
//rest of code
END

I hope it help you ;)
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)

quasist

Quote from: Drumpi on December 08, 2009, 02:15:19 AM
PROCESS one ()
BEGIN
FILE=0;
GRAPH=my_map;
//rest of code
END
PROCESS two ()
BEGIN
FILE=0;
GRAPH=other_map;
//rest of code
END

I hope it help you ;)
How to create array of processes ? :)
Function Int Write_Signature()
Private
Begin
End;

Drumpi

Uh? a process is like a C function or procedure, but them not finish his execution, they're runing every frame of the program at the same time than others.

By the way, when you call a process, it returns an ID and can store it in an INT array. Something like:

INT my_array[10];
(...)
my_array[0]=one();
my_array[1]=one();
my_array[2]=two();
(...)
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)

Windgate

Array of processes, I don't know what do you exactly want to do, let's see:

As Drumpi said, if you want to launch 1000 PROCESS one ( ) and keep all process ids on an array you also can do:

GLOBAL
   int array [ 1000 ];

...
FROM x = 0 TO 999;
   array [ x ] = one ( );
END
...


Is this what you want?
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

quasist

#6
Is it possible to launch a bunch (~256) processes with unique graph ID(to various PNG-s) from some loop structure?

Like to draw level map in Field of View by tiles.
Function Int Write_Signature()
Private
Begin
End;

Windgate

Definitively, yes, try it xD
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

Sandman

Use parameters.

Global
    int array [255];
End

Process Main()
Private
    int i;
    int map[1];
Begin
    map[0] = load_png("file");
    map[1] = load_png("other file");
    array[i] = proc(50,50,map[0]);
    array[i] = proc(150,150,map[1]);

    Repeat
        frame;
    Until(key(_ESC))

    let_me_alone();

OnExit
    unload_map(map[0]);
    unload_map(map[1]);
End

Process proc(int x, int y, int graph)
Begin
    Loop
        frame;
    End
End
...
-- Sandman

quasist

Function Int Write_Signature()
Private
Begin
End;

Windgate

Oh, just fucking parameters, ok, keep on trying, you will see Bennu is like a drug... If you start you won't stop... Any other problem you can report it ;)
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

quasist

Works perfect!

Now I have few more ( moddesc was not quite informative :( )

1) How to set transparent color?

2) How to correctly delete process with sprite? So I could alter the sprite on his ID.
Function Int Write_Signature()
Private
Begin
End;

Sandman

1) What do you mean? Do you mean you want to change the transparency of the process' graphic or that you want to change which colour 'is the transparent color'? In the first case, use the local alpha, in the second case, you're out of luck, but you could use 32bit images.

2) Not sure what you mean by this. If you want to unload a map that only a specific process uses, you can use OnExit, like in the example I gave you, but in the proc process. To alter the graphic of a process you can change the local variable graph.

* Alpha is not documented, but it's a local variable. Ranges from 0 to 255. 0 means fully transparent, 255 means solid.
-- Sandman

Windgate

Sandman said it all...

If you are using 16 bits colour mode, black (RGB = 0,0,0) is transparent, try it.

TIP: If you are using Gimp, Paint.NET, Photoshop, etc. you should always use PNG format on all your graphics.
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

quasist

Quote from: Windgate on December 12, 2009, 04:32:31 AM
If you are using 16 bits colour mode, black (RGB = 0,0,0) is transparent, try it.
Didn't work :(
Function Int Write_Signature()
Private
Begin
End;