[SOLVED]How do I function parameters?

0 favourites
  • 10 posts
  • Hello World,

    I made a topic a few weeks back asking for help with pseudorandomness, you can go check it out if you wanna see what that was about. At that time someone helped me with a nice example for how my game worked at that time.

    Sadly since then I had to change some stuff around, instead of having a bunch of objects each with several frames I now have hundreds of objects with just the one frame each. So, unfortunately, the capx that person made doesn't help me anymore.

    I tried modifing it, I tried playing with arrays on my own, using other examples/tutorials for shuffling, etc. and I still can't do it....

    I'm pretty close to giving up but before I do I figured I might as well ask. Check the picture below please, with how my code looks, isn't there a way I could simply put some parameters on those functions so when they are called to create an object they don't create an object that has the same UID as another object on the same y as the object being created? This way I'd have "some"(I guess) randomezation without much repetition and I wouldn't have to modify my code much, just add those parameters, wouldn't have to worry about freaking arrays, etc....

    Thank you.

    P.S. Ignore the depressing lyrics of the music I'm listening to atm that appear in the image, I couldn't find the strenght to care enough to cut them out this time.

  • Bump. Nothing, nobody?:(

  • It's not clear what you want. Do you want the 46 and 592 to be a bit (uniquely) random for each object?

  • Basically I want to be able to create objects randomly but without much repetition blackhornet . If there is a lot of repetition that makes my game unplayable as the player doesn't stand a chance....

    And if I just leave create object family like that, even with just 8 objects in the family and a row of 6 created at a time it's still unplayable.

    Like I said, I tried doing a bunch of stuff and nothing worked(I can't really code for shit I guess), so I figured as a last ditch effort maybe I can just add some parameters to the function so there is no repetition per row.

    I'm hoping that no repetition per row would work best, not sure... Ideally I'd like a simple piece of code that is easily modifiable to give me some control to increase/decrease the randomness and that works with the spawning system I have. But at this point I'd settle for just those function parameters, if that's even possible at all....

  • Can these be organized in a grid? Given your X values are multiples of 80, I'm thinking yes, but I don't know about the Ys. If you can think of this as a grid, then things become easier, as you can easily check if a grid position is already taken, and not pick that one. This is easier than arbitrarily checking pixel positions.

  • Eighter you're misunderstanding what I'm taling about blackhornet , or I'm misunderstanding what you are talking about. So I'm gonna answer for both cases.:

    1. If you misunderstand:

    • forget about the positions, that is not the problem, I like the way I am positioning and moving them at the moment. The problem is that by just creating a family object(which is random in itself) things are too random, I get too many duplicates so I need a way to make it less random on created, but I don't see how that has anything to do with their positions.

    2. If I missunderstand:

    • yes, the gameplay area is basically a grid I guess. The problem is that the first row that gets created(the rows you see in those events) are non playable, they are basically just to show the player what's coming next. Think of tetris, you know how some versions of tetris have a small box, outside the play area, where it shows you a small sprite of the next object that's gonna drop down? Like that.

    Because of that the first row that gets created is smaller 45x45 so as to ocupy just half of the... "grid box space", then the first time it gets pushed up(and goes into the playable area) it moves just 60px, gets resized again to 65x65, after that every time that row gets pushed up it moves 71px on y.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can't rely on Family to create on, as you've discovered. You'll need to create specific objects that are in that Family. You could use a plugin I wrote to get unique random numbers, and then decode them into which object to create. This would give you unique objects per round. You can use functions to do all the repetitive work.

  • I'll take a look at it, but I doubt I'll be able to make it work... That's why I used the phrases "can't code for shit" and "simple piece of code".

    Thanks anyway blackhornet .

  • Here's a sample with four sprites in a Family.

  • K, I tried it out and managed to get it to work; I don't yet fully understand how and why it works, but it does.

    Sadly it only seems to have made my game slightly playable... I don't know, maybe the entire game idea wasn't any good to begin with....

    Alas, thank you for showing me how to do it blackhornet , it's probably gonna come in handy one day regardless of what happens with this project.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)