Gamestudio Links
Zorro Links
Newest Posts
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 905 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
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 Offline OP
User
Carlos3DGS  Offline 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.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
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 Offline
Expert
EvilSOB  Offline
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 Offline
Expert
Uhrwerk  Offline
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:

Code:
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 Offline OP
User
Carlos3DGS  Offline 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.


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
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 Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: Carlos3DGS
I have never declared a variable of the fixed type. I mainly have always used var ...

That's a paradoxon. wink "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:
Code:
typedef fixed var;


Sorry, didn't want to confuse you. I am just more used to fixed than to var.
Originally Posted By: Error message
"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] #391410
01/11/12 19:29
01/11/12 19:29
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
That was much simpler than I expected... I thought it would be something much more complex to understand.
fixed == var
MOD typecast error == floats hate %


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
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 Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Originally Posted By: Uhrwerk
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.


Code:
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
Page 2 of 2 1 2

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