Global code - how to start?

Non-platform specific questions.

Global code - how to start?

Postby Camper1995 » Wed Sep 16, 2009 11:29 am

global code.JPG
global code.JPG (1.6 KiB) Viewed 829 times


Hi all. I want to learn to make scripts in global code, but I dont know how to begin..

can anyone explain me how to use global code please? Thank you. :)

Camper...

;)
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Global code - how to start?

Postby Hblade » Wed Sep 16, 2009 2:02 pm

k Open up Global Code.

Then, to make a function that can be called during ANY other script, simpy use the command void functionname()
{
code here
}
Then in any other code, Just use functionname(); and you have it!


For more... advanced functions... inside of the parentheses, you can put stuff like void functionname(int var1).

Other commands you can put are:
int - User wil choose which number when called in other code - functionname(1);
char *nam - User will input text when called in other code - functionname("Hello")

You can also combine these,
void functionname(int var1, vhar *msg)

How to use:
To controle what the int and char do, we are going to write a little script and I'll comment it :D
Code: Select all
void PlaceText(char *msg) // Place texts
{
              strcpy(text, msg); // Changes the original text into the msg's text
}

Now we wanna call that code. Make a text actor, he can say what ever it is he wants to say for now Now go to Draw actor - script editor - And put in PlaceText("Hi this is a test"); and click ok. Now test your game and you'll see that it says "Hi this is a test".
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Global code - how to start?

Postby Camper1995 » Wed Sep 16, 2009 7:29 pm

Uh, thanks. I will try to do this :)

I will send a post here if I do this. :)
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Global code - how to start?

Postby cforall » Fri Sep 18, 2009 5:46 am

Hi Camper
Im here to talk something about global code
Im a beginner and just wanna share experience with your guys :D

It's all about COLOR

1.The first thing I will show how to define canvas pen and how to set color to actor

Code: Select all
setpen(WHITE,0,1);                             /*equal to*/      setpen(255,255,255,0,1);
setcolor(&youractorname,WHITE);   /*equal to*/      youractorname.r = 255; youractorname.g = 255; youractorname.b = 255; 

It does seem a bit odd, does not it? I will explain it later

2.And then I will show what I typed in Global code [#define part]
Code: Select all
#define MAGENTA_R  201
#define MAGENTA_G  21
#define MAGENTA_B  123

#define CYAN_R     0
#define CYAN_G     183
#define CYAN_B     235

#define GRAY_R     128
#define GRAY_G     128
#define GRAY_B     128

#define BLACK_R    0
#define BLACK_G    0
#define BLACK_B    0

#define WHITE_R    255
#define WHITE_G    255
#define WHITE_B    255

#define MAGENTA            MAGENTA_R, MAGENTA_G, MAGENTA_B
#define WHITE              WHITE_R,   WHITE_G,   WHITE_B
#define BLACK              BLACK_R,   BLACK_G,   BLACK_B
#define CYAN               CYAN_R,    CYAN_G,    CYAN_B
#define GRAY               GRAY_R,    GRAY_G,    GRAY_B

want more colors? check here http://en.wikipedia.org/wiki/List_of_colors

3.Now I will show what I typed in Global code [function part]
Code: Select all
void setcolor( Actor *actor, int c_r, int c_g, int c_b)
{
 if(actor)
 {
  actor->r = c_r;
  actor->g = c_g;
  actor->b = c_b;
 }
else
 {
  r = c_r;
  g = c_g;
  b = c_b;
 }
}


4.Well, how to use
You donot have to remember the RGB value of any color when you wanna set color to canvas pen or set color to actor.
The only thing you need is to remember the name of color.
type code like this if you wanna a black/gray/magenta pen:
Code: Select all
setpen(BLACK, 0 ,1); setpen(GRAY, 0 ,1); setpen(MAGENTA, 0 ,1);

type code like this if you create a normal actor named A and want a black/gray/magenta A:
Code: Select all
setcolor(&A, BLACK); setcolor(&A, GRAY); setcolor(&A, MAGENTA);

if you just want change color of current actor I mean the Event Actor you could type simply like this:
Code: Select all
setcolor(0, BLACK); setcolor(0, GRAY); setcolor(0, MAGENTA);

pretty easy, right?
hope this will be helpful :D
My english sucks maybe I did not make myself clear so if you have any question don't bother to ask

cforall
User avatar
cforall
 
Posts: 65
Joined: Thu Aug 06, 2009 2:46 pm
Location: Shanghai
Score: 8 Give a positive score

Re: Global code - how to start?

Postby Chai » Fri Sep 18, 2009 7:09 am

If your C language knowledge is limited as I am.
For me, I 've learnt from Demos.
You can find various Demos from the GE Demos forum.
It's very powerful for any beginner.

But if you know very well in C.
You can go with a above suggestion.
User avatar
Chai
 
Posts: 361
Joined: Sat Apr 30, 2005 2:26 pm
Location: Thailand
Score: 30 Give a positive score

Re: Global code - how to start?

Postby Camper1995 » Thu Sep 24, 2009 5:36 pm

Well, first, I wanna thank all of you for helpinf me. :P

cforall: I dont understand this too much. I just wanna know the basic thing. How to start writing in Global code.

You know, when I open it, what then? How to start? ;)

So if can anyone help me? Thanks all ;)

global code.jpg
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron