Random Positions...

Blitz3D Forums/Blitz3D Programming/Random Positions...

StOrM3(Posted 2003) [#1]
Hello, I was wondering if anyone has come up with a way to randomly position items in a level that might have platforms at different Y Levels.. Like 2 or 3 platforms connected via ramps. What I am looking for is a general purpose function that will position the items randomly, but no items floating in the air, only ones that are on platforms visible.. So I can make the levels different everytime someone plays it. Thanks for any help..


poopla(Posted 2003) [#2]
Well granted you make all your platforms pickable. Linepick down from above your level at random positiones. If you pick an entity, then place an ovject there. You can code that in no more then.... 10 - 15 lines.


Rob(Posted 2003) [#3]
Either that or have a dummy loop and "drop them" :)


poopla(Posted 2003) [#4]
yeah but thats so much more work :). BE LOGICAL ROB!!! ;)


StOrM3(Posted 2003) [#5]
Actually, I have it pick random x,z coords, then do the loop dropping the items from above checking for collisions and if they collide I stop backup .1 and set that for the Y coord. Also checking to ensure that if they fall below 0 to remove them from the level. I know this isn't the most elegant, but I can't really think of any other way to do it. So if anyone has any code examples on how to do it another way I would really appreciate it.

Thanks,

Ken


poopla(Posted 2003) [#6]
function DropItem(ent, x, z, w, l, p = 1); p = 1 to 100
     For ix = 1 to x + w
         for iz = 1 to z + l
             if rnd(0, 100) < p then
                linepick(ix, 100, iz, 0, -200, 0)
                if pickedentity() <> false then
                     positionentity Ent,ix,pixkedy#(),iz,1
                endif
             endif
         next
     next
end function  


I didnt test this just wrote it quickly.


StOrM3(Posted 2004) [#7]
Can someone help me with this ? I still don't have a working routine to drop the fruit models from above to a level model, stopping when they collide with it. I have a routine, but I get a memory error when I try to compile it.

Please Help, I will post the code I have if someone can help me, please, I am almost to the point I have a workable game, I have all the models etc.. done.


Thanks in advance.

Ken