Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
More structs help... #148615
08/17/07 07:27
08/17/07 07:27
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I know I have posted this before, but I'm asking a different question this time.

I would like to know what I can really use structs for, as I have no idea what to do.

I understand that they can be used for special functions and whatnot, but I don't know how I would do this.

Basically what I'm asking is, "How do I make a struct actually put something on-screen?"

Like, I could have a struct called WORD*, and I want it to put a word on the screen.

Code:

typedef struct
{
char word[20];
} WORD;

WORD* test_word=
{
word= "Word.";
}



The only way I can think of to put that word on-screen is to use two pre-defined structs, STRING* and TEXT*:

Code:

STRING* show_struct_content= "";

typedef struct
{
char word[20];
} WORD;

WORD* test_word=
{
word= "Word.";
}

TEXT* show_test_word=
{
string= show_struct_content;
flags= VISIBLE;
}

void show_word()
{
str_cpy(show_struct_content,test_word.word);
}



Just add the "#include <acknex.h>" and you have a script that will display the content of struct WORD* on the screen.

Is this the preferred way, or is there something different that I'm not understanding?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: More structs help... [Re: MrCode] #148616
08/17/07 10:23
08/17/07 10:23
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
You should not use it to create functionality that is already there. A struct WORD would be useles in lite-c; we already have STRING and TEXT. What you want to use structs for is create something on a "higher level".

Say you are creating a multiplayer RPG and you want a character with many properties and a name above his head on screen. You could create a Character type that contains an ENTITY*, some built in types for its properties (int level, float health) and a TEXT* for the name. This way you don't have to write code to know which TEXT* name belongs to which ENTITY* character. You can pass a pointer to the struct to a function, so the function can change any parameter.

Structs don't really make new things possible that wheren't possible before, but they make it possible to create a more structured program.

Re: More structs help... [Re: Excessus] #148617
08/17/07 14:32
08/17/07 14:32
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
F.e. i use structs to store tricks data in my game(sport simulator). there is a struct called TRICK, and it has parameters like type, speed, difficulty, animation, and so on. i've got a TRICK array that stores all tricks. Without structs it would be more complicated


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1