Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, 1 invisible), 721 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Suggestions for improving some lite-c standard functions [Re: Alan] #286512
08/25/09 15:50
08/25/09 15:50
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
A #define would indeed make sense, but does not work here either because engine objects don't accept #defines for their default values. But #defines for engine objects are indeed on our implementation list.

At the moment though, a function is the best way to set your panel position to the screen resolution.

Re: Suggestions for improving some lite-c standard functions [Re: jcl] #286535
08/25/09 18:03
08/25/09 18:03
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline OP
Senior Member
Alan  Offline OP
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
Well then - I'm looking forward to it!
And by the way... what about the dx and dy values of windows (Panel element)? Currently, they cannot be changed after their creation, even with a function (please correct me if I'm wrong). It would be great if that was possible. Please refer to the start post for an example.

Re: Suggestions for improving some lite-c standard functions [Re: Alan] #286584
08/26/09 00:19
08/26/09 00:19
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
@jcl: Wow, I had no idea about that. I just assumed all #defines were replaced with their appropriate values just before it gets compiled.

@Alan: In C (and Lite-C) you can put in your code (usually near the top with your #includes) a #define.
eg:
Code:
#define SCALESIZE 15
...
...
action scaledEnt() {
// scale all dimensions of the entity by a pre-determined constant
   my.scale_x = my.scale_y = my.scale_z = SCALESIZE;
}

This is common practice to remove "magic numbers" (that is, constants in your code that may or may not need to change later on in production); this makes the code more readable (someone reading my code doesn't know why I'm scaling this entity by 15, but if they see it scaled by a #define they can usually see what purpose it is serving). It also means if you need to change that constant, and it is used a lot in your code, you can just change it in the #define.

It doesn't have to be a number, either. It's often used for skills:
Code:
#define HEALTH skill1
#define VITALITY skill1
...
...
my.HEALTH = 30;
my.VITALITY = 30; // redundant, since VITALITY and HEALTH both become "skill1"

You can have two different defines for the same skill or value (as I've just done), but you have to be sure one entity won't need them both to be different things (here HEALTH and VITALITY mean the same thing, but if an entity needs HEALTH and VITALITY to be different, one of them should be #defined to a different skill instead; this is just to show its flexibility).

Does anyone care to explain why it won't work for engine objects? That sounds weird to me, although I obviously don't know exactly how the compiler works.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Suggestions for improving some lite-c standard functions [Re: JibbSmart] #286622
08/26/09 08:35
08/26/09 08:35
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline OP
Senior Member
Alan  Offline OP
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
@JulzMighty: Ah, I understand what you mean now. I wonder whether or not it is possible to do calculations within defines as well, like this:

Code:
#define ss_x 1024     //ss_x = screen_size_x
#define ss_y 768      //ss_y = screen_size_y
#define panpos_x (ss_x / 2)
#define panpos_y (ss_y / 2)

PANEL* my_pan = 
{
   pos_x = panpos_x;
   pos_y = panpos_y;
}



I can't test that out myself because according to JCL defines can not be parameters for panel positions, but would the defines for panpos_x and panpos_y in my example above work that way?

Re: Suggestions for improving some lite-c standard functions [Re: Alan] #286624
08/26/09 08:43
08/26/09 08:43
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
The defines just stick in what's there before compilation, so it won't perform the calculation for you, it'll still end up being "pos_x = 1024 / 2;", I'm pretty sure.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Suggestions for improving some lite-c standard functions [Re: JibbSmart] #286649
08/26/09 10:33
08/26/09 10:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
JutzMighty is correct.
As a MASSIVE over-simplification, the "define" is just a "text replacement tool".


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Suggestions for improving some lite-c standard functions [Re: EvilSOB] #288619
09/07/09 16:37
09/07/09 16:37
Joined: Nov 2005
Posts: 94
Texas
3
3Dski Offline
Junior Member
3Dski  Offline
Junior Member
3

Joined: Nov 2005
Posts: 94
Texas
Is panel_create slow and a lot of overhead to place in an action? Why wouldn't you create the panel, then only change pos_x and pos_y in the action?

Page 2 of 2 1 2

Moderated by  aztec, Spirit 

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