1 registered members (AndrewAMD),
905
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: simple rotation per hour of gameplay...
[Re: EvilSOB]
#391380
01/11/12 15:00
01/11/12 15:00
|
Joined: Oct 2008
Posts: 513
Carlos3DGS
OP
User
|
OP
User
Joined: Oct 2008
Posts: 513
|
Thanks EvilSOB, you nailled it! That extra /16 for the pan (and *16 for the cycle) is what was missing from the formula.
and I learned a new engine function! No more ugly %= for me! (well that depends... which is faster? %= or cycle?)
Last edited by Carlos3DGS; 01/11/12 15:02.
|
|
|
Re: simple rotation per hour of gameplay...
[Re: Carlos3DGS]
#391383
01/11/12 15:45
01/11/12 15:45
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I believe % is faster than cycle, but you no longer have to worry about MOD-type casting errors.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: simple rotation per hour of gameplay...
[Re: EvilSOB]
#391393
01/11/12 16:41
01/11/12 16:41
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I don't know why you're so keen on using floats. This does not make any sense from my point of view. You don't gain any more precision as you have to cast to the fixed types anyways. Why don't you just:
void rotateperhour(ENTITY* ent)
{
fixed ticks;
while(1)
{
ticks = (ticks+time_frame) % 57600; // or time_step when you want to use time_factor
ent.pan = ticks / 16 / 60 / 60;
wait(1);
}
}
Alternatively you can use a skill of the entities instead of the local variable.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: simple rotation per hour of gameplay...
[Re: Uhrwerk]
#391401
01/11/12 18:23
01/11/12 18:23
|
Joined: Oct 2008
Posts: 513
Carlos3DGS
OP
User
|
OP
User
Joined: Oct 2008
Posts: 513
|
I would really like an explanation of MOD-TYPE casting error, what they are, and why they are produced? I have no idea what it is besides the fact that I got one.
Also an explanation of that "fixed" declaration would be nice, I have never declared a variable of the fixed type. I mainly have always used var, int, bool, and float (along with pointers and strings and of course variants of the mentioned before like: structs, arrays, vectors, etc...). But I have never used fixed, don't know what they are, how they work, what they are good for, what their limitations are, etc...
At first I thought it might be something similar to "static" due to its name, but after reading the entry in the manual it is obviously not the case. Anyway I really didn't understand what it is good for or how it works by the short definition in the manual, any further explanation would be apreciated.
|
|
|
Re: simple rotation per hour of gameplay...
[Re: Carlos3DGS]
#391404
01/11/12 19:00
01/11/12 19:00
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I have never declared a variable of the fixed type. I mainly have always used var ... That's a paradoxon. "var" is just a synonym for "fixed". It's the same 22.10 fixed point type. If you have a look into acknex.h you will find the redefinition: Sorry, didn't want to confuse you. I am just more used to fixed than to var. "Syntax error:Can't convert MOD:FLOAT:FLOAT:FLOAT" basically means, that the modulo operator is not defined for floating point numbers.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: simple rotation per hour of gameplay...
[Re: Uhrwerk]
#391446
01/12/12 10:13
01/12/12 10:13
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I don't know why you're so keen on using floats. This does not make any sense from my point of view. You don't gain any more precision as you have to cast to the fixed types anyways. Im not fixated on floats, its just thats what was already in the example.
void rotateperhour(ENTITY* ent)
{
var ticks;
while(1)
{
ticks = (ticks+time_step) % 57600;
ent.pan = ticks / 16 / 60 / 60;
wait(1);
}
}
I prefer this one (of yours) because it allows for time_factor manipulation. That will probably be necessary in Carlos's project...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|