[SOLVED]How do I function parameters?

Get help using Construct 2

Post » Sun Jan 31, 2016 5:03 pm

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....

Image

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.
Last edited by VIKINGS on Mon Feb 01, 2016 7:31 pm, edited 1 time in total.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sun Jan 31, 2016 10:40 pm

Bump. Nothing, nobody?:(
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sun Jan 31, 2016 10:44 pm

It's not clear what you want. Do you want the 46 and 592 to be a bit (uniquely) random for each object?
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Sun Jan 31, 2016 11:21 pm

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....
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sun Jan 31, 2016 11:29 pm

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.
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Sun Jan 31, 2016 11:48 pm

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.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Feb 01, 2016 12:08 am

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.

plugin-smart-random_t163624
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Mon Feb 01, 2016 12:42 am

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 .
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Feb 01, 2016 3:10 am

Here's a sample with four sprites in a Family.
www.blackhornettechnologies.com/Constru ... rator.capx
ImageImageImage
B
71
S
22
G
249
Posts: 3,762
Reputation: 138,575

Post » Mon Feb 01, 2016 6:13 pm

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.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335


Return to How do I....?

Who is online

Users browsing this forum: Cubeeo and 24 guests