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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Baklazhan, Ayumi, Hanky27), 1,387 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Best way to do things ( random grass generator) #179721
01/24/08 15:55
01/24/08 15:55
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
Hi
I have a function that generates 500 sprites of a grass image(32bits TGA)
in randomly positions over the level.
I found out that I needed a bit more than 1000 to cover my level decently.
So i made a function that any sprite that is X(eg. 5000) quants farther from the player, gets its invisble flag on.(for speed and rendering improvment)

But IF i make a function that maintan a max number of sprites 200(which is enough to fool the vision of the player) and as i walk, it creates and removes sprites using the same distance comparison.

Which one do you think is the best? ( speed, memory, rendering...)

ps. I´m not using no ones particular generator code and no generator tutorial code(if there is any).

thanks

Re: Best way to do things ( random grass generator [Re: DestroyTheRunner] #179722
01/24/08 15:59
01/24/08 15:59
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
You should create only once, and then move them on positions around the player instead of removing and creating again. That's the fastest way I can think of.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Best way to do things ( random grass generator [Re: Joozey] #179723
01/24/08 16:13
01/24/08 16:13
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
but what about memory?
1000 grass sprites means:

1000 entities + 1000 functions running.

Im kind of gathering PROS and CONS about this two methods.

Re: Best way to do things ( random grass generator [Re: DestroyTheRunner] #179724
01/24/08 17:00
01/24/08 17:00
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Quote:

But IF i make a function that maintan a max number of sprites 200(which is enough to fool the vision of the player)



200 grass sprites means: 200 entities + 1 function running.

you create the grass sprites, store their pointers somewhere and check the distance of all the sprites from the player each frame. This would give 200 loops per frame, that's fine.

Last edited by Joozey; 01/24/08 17:00.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Best way to do things ( random grass generator [Re: Joozey] #179725
01/24/08 17:32
01/24/08 17:32
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
ok
sorry if i couldnt be a bit clear...
200 grass sprites only apply to the vision of the player. example, the level
has to have 1000 grass sprites to cover the land decently, but i need 200 visible.
But im getting a problem with it, I´ll explain to you the real thing so you can have a more clear vision of the problem:

"Basically im throwing rocks at a castle, and when it hits the castle wall, it disappears and create 10 small rocks with c_move and c_trace running on each of them ( each small rock has 12 faces), then they fall to the ground and some seconds later they disappear and all their functions terminated."

NOW the problem, if there is more than ~300 grass sprites in the level EVEN WITH THEIR FLAG INVISIBLE ON, and i throw the rock at the castle, when it creates those 10 small rocks, the FPS drops from 60 to 35/40! until they disappear and it comes back to 60.

So the most i could get was 200 grass and the FPS still drops 8 to 10fpss(~52fps)

Did you get the Drama?

(my current pc specs is AMD Athlon 1600mhz 256mb ram Video Card GeForce4 but i get the same results in a P4 2.6 512ram video card ATI Radeon 345m 128 shared with the ram memory)

Re: Best way to do things ( random grass generator [Re: DestroyTheRunner] #179726
01/24/08 17:36
01/24/08 17:36
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I think I know why, it's because you have grass sprites everywhere, but not visible. c_move detects the sprites and collides with them. Either turn of sprite collision in c_move/trace, or do as I told in my previous post.

if you only have 200 entities visible max, you really only need to make 200 grass sprites, not 1000. The level doesn't need to be filled if you dont see them anyway. If you create 200 grass sprites around the player at random locations, and you move the player forward, the grass sprites outside the visibility range should be relocated to some new location around the player that just appeared in visibility range.

That's the most effective way.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Best way to do things ( random grass generator [Re: Joozey] #179727
01/24/08 17:46
01/24/08 17:46
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
Quote:


If you create 200 grass sprites around the player at random locations, and you move the player forward, the grass sprites outside the visibility range should be relocated to some new location around the player that just appeared in visibility range.
That's the most effective way.




you are right, thats was what i was trying to achieve creating and removing grass entities...
but still
about the c_move stuff... the rocks has their sprite collision detection OFF already AND they rarely make it to collide with a sprite.
And still 200 makes the FPS to drop but its playable, im only affraid when the game get more stuff in its vision or level, whats goind to happen...

I will try to come up with a code that makes what you said before,
have any more thoughts or ideas about the FPS drop and anything else?

thanks

Re: Best way to do things ( random grass generator [Re: DestroyTheRunner] #179728
01/24/08 18:21
01/24/08 18:21
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
I don't know actually what causes the fps drop, for 10 small rocks moving with c-move, IMO there shouldn't be a drop of 20fps. You could post a new post with this specific question and give some more details.

Last edited by Joozey; 01/24/08 18:21.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Best way to do things ( random grass generator [Re: Joozey] #179729
01/24/08 18:52
01/24/08 18:52
Joined: Aug 2007
Posts: 286
DestroyTheRunner Offline OP
Member
DestroyTheRunner  Offline OP
Member

Joined: Aug 2007
Posts: 286
well yeah..
it does if theres like 500 grass and i create this 10 small rocks i get this drop for some moments and then it gets back to 60. =/


I am in need of one more help from you, to make it like
200 entities and 1 function running, i should not put any while in their initial function.
So far I have made this:
Code:

var grass_array_x[1000];
var grass_array_y[1000];
var grass_array_index;

function define_grass_pos()
{

while(grass_array_index < 1000)
{
grass_array_x[grass_array_index] = random(10000);
grass_array_y[grass_array_index] = random(10000);

grass_array_index += 1;

}

}


So I have defined 1000 positions (x,y) inside my level in a random area of 10,000.
Now I need to create 200 grasses and move them into 200 player nearest positions of this 1000 total positions.
So how am I going to move the grasses between this positions if i cant have a while loop inside their functions? because otherwise it will make 200 running functions.

I was trying to find an Entity Array so i could directly move them. but it doesnt seems to have Entity Arrays only Var and string arrays.
So am i really going to define 200 ENTITIES MANUALLY?
eg.
entity* grass1;
entity* grass2;
...

?

ps. the reason I pre-defined 1000 postitions randomly only once is because once you loaded the game, and the positions are defined, even if you walk out from an area and the grass is removed from there to fill another position, i wanted to when you go back to that place, the grass is put back in the same place, instead of you walk in the same area 10 times and see the grass in 10 different places everytime you walk in that area. ( it may be stupid, maybe the player wont notice it but i wanted it this way unless i really need to change it)

Last edited by DestroyTheRunner; 01/24/08 18:57.
Re: Best way to do things ( random grass generator [Re: DestroyTheRunner] #179730
01/24/08 19:29
01/24/08 19:29
Joined: Dec 2003
Posts: 129
Osnabrück, Germany
Ready Offline
Member
Ready  Offline
Member

Joined: Dec 2003
Posts: 129
Osnabrück, Germany
Had a problem somewhat related to that earlier today, check out this thread
http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/813157/an/0/page/0#Post813157


Do not underestimate people because they have a low post count... :0
Page 1 of 3 1 2 3

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