Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, Power_P), 1,065 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Setting a particles position directly? #415090
01/13/13 18:56
01/13/13 18:56
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Hi,
currently i need to set a particles position directly.
For this purpose, i save all particles in a list to access them.
(these particles are never deleted)

the global vars:
Code:
PARTICLE** PList;
int FirstPIndex = 0;



the particle function to initialize itself
Code:
function PInit(PARTICLE* p)
{
	PList[FirstPIndex] = p;
	FirstPIndex++;
	p.size = 16;
	p.lifespan = 100;
	set(p, MOVE | BRIGHT | TRANSLUCENT);
}



this should store the particles BUT when i loop through the registered range(0 to FirstPIndex-1) to manipulate the positions, nothing happens to them :|

Code:
for(i = 0; i < FirstPIndex; i++)
		{
			(PList[FirstPIndex]).x = 0;
			(PList[FirstPIndex]).y = 300;
			(PList[FirstPIndex]).z = 0;
		}



Someone has an idea?


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: Setting a particles position directly? [Re: Ayumi] #415094
01/13/13 19:39
01/13/13 19:39
Joined: Oct 2009
Posts: 149
Germany
M
muffel Offline
Member
muffel  Offline
Member
M

Joined: Oct 2009
Posts: 149
Germany
Flüchtigkeits Fehler. Schau dir die Indizes mal an.
So sollte es aussehen
Click to reveal..

Code:
for(i = 0; i < FirstPIndex; i++)
		{
			(PList[i]).x = 0;
			(PList[i]).y = 300;
			(PList[i]).z = 0;
		}


muffel

Re: Setting a particles position directly? [Re: muffel] #415104
01/13/13 21:11
01/13/13 21:11
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
ou...shame on me^^

But something is still wrong:

even after correcting, the particles do not changes their position according to the set values.

For testing purpose, i changed the list to store entities instead of Particles(and added entities) but they didnt change either. So something is still wrong o.O

And something that bothers me:
it seems a particle MUST have a function. The above particle function executes itself each frame(which leads to an array overflow). So i added a dummy event which just sets lifespan to 100.

Isnt it possible to just create undead particles without a function? thats currecntly up to 5k unecessary call stuff per frame frown

EDIT: okay that worked for some reason:

Code:
LP = PList[i];
			LP.x =  (GPosition[i]).x*40;	
			LP.y = (GPosition[i]).z*40;
			LP.z = (GPosition[i]).y*40;


Last edited by Rackscha; 01/13/13 21:20.

MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: Setting a particles position directly? [Re: Rackscha] #415115
01/14/13 00:14
01/14/13 00:14
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Of course you can use particles without functions. You can either pass NULL to effect or use a function in effect to initialize the particles and the manually set p->event to NULL.

Why "for some reason"? Is there anything unclear?


Always learn from history, to be sure you make the same mistakes again...
Re: Setting a particles position directly? [Re: Uhrwerk] #415130
01/14/13 10:10
01/14/13 10:10
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
The worked for "some reason" has the open question in my mind:

what is the difference between:

Code:
(List[Index]).x = 5;



and

Code:
LP = LIst[Index];
LP.x = 5;



The first doesnt work(but no exception/error), but the second works. Can someone explain this behaviour to me?


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: Setting a particles position directly? [Re: Rackscha] #415133
01/14/13 10:47
01/14/13 10:47
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Originally Posted By: Rackscha
The first doesnt work(but no exception/error), but the second works. Can someone explain this behaviour to me?

This is called Lite-C grin
I ran into this problem also and i hate it...

try with
(List[Index])->x

and a tip from my side:
#define PRAGMA_POINTER


Visit my site: www.masterq32.de

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