[CYBERCLONE.C] Global Code Clone Library GCCL V3

Talk about making games.

[CYBERCLONE.C] Global Code Clone Library GCCL V3

Postby bat78 » Sat Mar 01, 2014 6:21 am

sign.png
sign.png (22.08 KiB) Viewed 4396 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 4396 times
Last edited by bat78 on Tue Mar 11, 2014 8:04 am, edited 21 times in total.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby DeltaLeeds » Sat Mar 01, 2014 6:57 am

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
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

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

Postby bat78 » Sat Mar 01, 2014 7:09 am

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.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby CrackedP0t » Mon Mar 03, 2014 2:04 am

Wow, this is cool.
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

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

Postby bat78 » Tue Mar 04, 2014 9:04 am

Thank you = )
I just added two more useful functions.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby JaroodaGames » Thu Mar 06, 2014 11:42 pm

Nice work bat.
User avatar
JaroodaGames
 
Posts: 56
Joined: Sun Jun 09, 2013 5:57 pm
Score: 2 Give a positive score

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

Postby bat78 » Fri Mar 07, 2014 12:39 am

Thank you.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby lcl » Fri Mar 07, 2014 9:11 pm

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby bat78 » Fri Mar 07, 2014 9:19 pm

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 :)
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby lcl » Fri Mar 07, 2014 9:30 pm

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! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

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

Postby bat78 » Sat Mar 08, 2014 3:41 am

*currently working on the DEMO - it's going nice and tomorrow it will be released :)*
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby bat78 » Tue Mar 11, 2014 7:50 am

Image UPDATED!
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby CrackedP0t » Wed Mar 12, 2014 1:38 am

Saw this in your code... what's the difference between Actor * and Actor **?
/人 ◕‿‿◕ 人\
Fang Pictures, my game development company:
http://fangpictures.comuf.com
User avatar
CrackedP0t
 
Posts: 157
Joined: Mon Dec 30, 2013 5:49 pm
Location: Crested Butte, CO (The US of A)
Score: 8 Give a positive score

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

Postby bat78 » Wed Mar 12, 2014 1:44 am

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.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

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

Postby Hares » Sun May 04, 2014 10:22 pm

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 ... :?
User avatar
Hares
 
Posts: 105
Joined: Fri Dec 20, 2013 8:39 pm
Location: Belgium
Score: 14 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest