Page 1 of 2

[CYBERCLONE.C] Global Code Clone Library GCCL V3

PostPosted: Sat Mar 01, 2014 6:21 am
by bat78
sign.png
sign.png (22.08 KiB) Viewed 4389 times


UPDATE: Added new function, compatible for all versions of gE, functions and descriptions update, demo and debug future ( [D] ).

Cyberlone.c is a global code script that contains plenty of functions with the clones in GameEditor.
Please comment so i can continue share newer and newer versions on it and soon.. even demos.
I would be more then happy to receive suggestions as well. I am open to renew and upload :)
There is the "Scripting Reference":


c_make: Makes a certain amount of clones with the position of the actor who call this function.[D]
Syntax: void c_make ( char * cName, int cCount )
Example: c_make ( "Rocket", 5 );

c_make2: Makes a certain amount of clones with declared position [D]
Syntax: void c_make2 ( char * cName, int cCount, int xCoord, int yCoord )
Example: c_make2 ( "Rocket", 5, 140, -50 );

c_makeArray: Like "Clone Array" option, it makes clone array at x and y with selected distance.
Syntax: void c_makeArray ( Actor c_source , int c_offset_x , int c_offset_y , int c_count_x , int c_count_y , int c_dist_x, int c_dist_y )
Example: c_makeAt ( GridCell, 140, -50, 5, 5, NULL, NULL );
Note: If you pass NULL instead of distance in pixels, it will set the distance as "Automatic".

c_xTable: Returns an array with all the clone's x coordinates.
Syntax: int * c_xTable ( char * cName )
Example: int * c_xpos = c_xTable ( "Naruto" );

c_yTable: Returns an array with all the clone's y coordinates.
Syntax: int * c_yTable ( char * cName )
Example: int * c_ypos = c_yTable ( "Naruto" );

c_position: Set an specific clone into a y and x coordinates. [D]
Syntax: char * c_position ( char * cName, int cIndex, int xCoord, int yCoord )
Example: c_pos = c_position ( "Naruto", 0, 50, 50);

c_distance: Returns an array with the distance between actor a and actor b.
Syntax: int * c_distance ( char * cName1, int cIndex1, char * cName2, int cIndex2 )
Example: int * c_dist = c_distance( "Naruto", 1, "Sakura", 1);
Return values:
array[0] returns -1 if there are no clones in 1
array[0] returns -2 if there are no clones in 2.
array[0] returns -3 if there are no clones according to the pointed ones.
array[1] returns actor's horizontal distance in pixels.
array[2] returns actor's vertical distance in pixels.

c_setDistance: Set distance between actor a and actor b.
Syntax: void c_setDistance ( char * cName1, int cIndex1, char * cName2, int cIndex2, int xDist, int yDist )
Example: c_setDistance ( "Naruto", 1, "Boss", 1, 50, 0 );

c_properties: Colors or set transparency of the actor specified.
Syntax: void c_properties ( char * cName , int cIndex , double cRed , double cGreen , double cBlue , float cTransp )
Example: c_properties ( "Naruto", 4, 255, 0, 0, 0.5);
Function Macros: m: For color value m means max color (255)

c_destroy: Destroys an specified actor.
Syntax: void c_destroy ( char * cName , int cIndex )
Example: c_destroy ( "Naruto", 4 );

c_destroy2: Destroys an specified actor from index to index.
Syntax: void c_destroy2 ( char * cName , int cSTARTIndex , int cENDIndex)
Example: c_destroy2 ( "Naruto", 0, 4 );

c_velocity: Control the velocity in specific direction of the pointed actor or clone.
Syntax: void c_velocity ( char * cName , int cIndex , double cDirection , int cVelocity, ... )
Example: c_velocity ( "Ball", 0, 90, 1 ); //Ball with cloneindex 0 in direction of 90 degree will move with 1 px per fps

c_tree: Return an array with pointers to all clones specified. Helps you control all the clones easy.
Syntax: Actor ** c_tree ( char * cName, ... )
Example: Usage: Actor ** varexample = c_tree ( "naruto" ); varexample[0]->transp = 0.5; //that will set the clone with index 0 with transparency of 0.5
Warning: I do not suggest you using this function, till i update her (read cyberclone.c desribtion for more info)

c_ged: Return pointer to an actor/clone with desired index.
Syntax: Actor * c_get ( char cName[] , int cIndex )
Example: Usage: c_get("actor", 5)->x = 250; //will set actor.5 on position x = 250.


_________________________________________________________________________________________________________
  • For some functions you can also use the following macros:
    c_end with means the last clone
    c_rand with means random clone
  • Credits:
    bat78
    DarkParadox
_________________________________________________________________________________________________________
Direct download:
Download
_________________________________________________________________________________________________________
Download demo:
DOWNLOAD

    Content:
  • data
  • Cyberclone DEMO BETA.ged
  • Cyberclone DEMO BETA.exe
  • cyberclone.c
_________________________________________________________________________________________________________
sign.png
sign.png (22.08 KiB) Viewed 4389 times

Re: [CYBERCLONE.C] Global Code Clone Library GCCL

PostPosted: Sat Mar 01, 2014 6:57 am
by DeltaLeeds
Wow!!! I'm going to use this!!! Before, defining and changing distances and clone stuff are hard, with this piece of code, it's going to be a lot easier! +1 to you! :D

Re: [CYBERCLONE.C] Global Code Clone Library GCCL

PostPosted: Sat Mar 01, 2014 7:09 am
by bat78
Thanks! :D Yep it is not meant to be code for super hard processes but it is made to make clone work much easier :P
Thanks.

Re: [CYBERCLONE.C] Global Code Clone Library GCCL

PostPosted: Mon Mar 03, 2014 2:04 am
by CrackedP0t
Wow, this is cool.

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V2

PostPosted: Tue Mar 04, 2014 9:04 am
by bat78
Thank you = )
I just added two more useful functions.

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V2

PostPosted: Thu Mar 06, 2014 11:42 pm
by JaroodaGames
Nice work bat.

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V2

PostPosted: Fri Mar 07, 2014 12:39 am
by bat78
Thank you.

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V2

PostPosted: Fri Mar 07, 2014 9:11 pm
by lcl
Cool! You've done great work.
An example .ged would possibly be very good for people to understand what to use this for.

Also, I'd recommend writing all comments using the //-method because the /* and */ -method preserves the same colors as the code has, and thus
makes it difficult to read the comments.

I'd also like to ask why there is this ", ..." in the end of many functions' parameter lists?
Does it do something? :D

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V2

PostPosted: Fri Mar 07, 2014 9:19 pm
by bat78
Hello lcl, thanks for your note!
The "..." argument is also known as "variadic argument" and i define it like possibility to add additional arguments like "sprintf".
However that statement do not work in gE, because the variadic control macros are not included in gE's lib. I use it for a pretty pointless reason - to prevent the error of wrong number of arguments if someone get in confusing :D
Sure thing! I will make a presentation demo.

And i agree with you about the preferences of line comment instead of phrases comment.. since gE uses sort of ancient compiler i was even thinking /* doesn't even work (till i tested it).. i might be able to fix this in game-editor's files since it is a issue of Script Editor's text box. I'm currently working on "cybertext.c" with extends the possibilities of using string functions. I also re-write some functions and add some new ones from the C11 like isdigit, strtok etc :)

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V2

PostPosted: Fri Mar 07, 2014 9:30 pm
by lcl
Oh, wow, that's cool! I've always wondered how sprintf is coded.
And by googling "variadic functions" I found this: http://en.cppreference.com/w/cpp/utility/variadic
Now I know one thing more about C programming :mrgreen: Thanks!

And I'll be waiting for the demo to see this in action! :)

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V2

PostPosted: Sat Mar 08, 2014 3:41 am
by bat78
*currently working on the DEMO - it's going nice and tomorrow it will be released :)*

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V3

PostPosted: Tue Mar 11, 2014 7:50 am
by bat78
Image UPDATED!

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V3

PostPosted: Wed Mar 12, 2014 1:38 am
by CrackedP0t
Saw this in your code... what's the difference between Actor * and Actor **?

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V3

PostPosted: Wed Mar 12, 2014 1:44 am
by bat78
Actor * var. var is actor pointer.
Actor ** var. var is actor pointer to pointer.

In my case the first pointer points to the array that points to the actors. So it becomes pointer to an array of actors.

Re: [CYBERCLONE.C] Global Code Clone Library GCCL V3

PostPosted: Sun May 04, 2014 10:22 pm
by Hares
Thanks for sharing this. +1

I hope this will make working with clones easier, because it's giving me a hard time ...

Question about c_get.
In the global code it says this in comments:
Code: Select all
/* c_get: Returns a pointer to the ACTOR specified
Function call: Draw Actor
Syntax: Actor * c_get ( char name[] , int index )
cName: The name of the actor you wish
cIndex: The number of the clone you wish
Usage: c_get("actor", 5)->x = 250; //will set actor.5 on position x = 250.

Function call: Draw Actor -> does this mean I can only call the function from a draw actor?
I am trying to make it work from a create actor ... :?