• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Question about choose.

M

mnbmnbmnb

Guest
This doesn't work, could you tell me how to make it works please?

if place_meeting(x,y,obj_guy)
{
instance_create(obj_thing.x,obj_thing.y-6000,stuff);
y -=6000
}

stuff = choose(obj_stuff,obj_stuff2)

Thanks
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Code:
if place_meeting(x, y, obj_guy)
{
stuff = choose(obj_stuff, obj_stuff2)
instance_create(obj_thing.x, obj_thing.y - 6000, stuff);
y -=6000;
}
Other than that it's difficult to know what may be the issue with your code as you don't explain anything, so if that doesn't fic what you want, then post the actual code and explain what each line is supposed to do and why...
 
X

Xskode

Guest
This doesn't work, could you tell me how to make it works please?

if place_meeting(x,y,obj_guy)
{
instance_create(obj_thing.x,obj_thing.y-6000,stuff);
y -=6000
}

stuff = choose(obj_stuff,obj_stuff2)

Thanks
If your trying to create an object out of the two choices then you need to place the stuff=choose above thee if place meeting and and randomize.


Code:
randomize();
stuff = choose(obj_stuff1, obj_stuff2)

if place_meeting(x,y,obj_guy)
{
instance_create(obj_thing.x,obj_thing.y-6000,stuff);
y -=6000
}
That should work if all you are trying to do is create an object randomly from two given choices. However, I can't say it will work- for there was not enough information on what exactly is the problem you are running into.
But let me know if that works.
 
A

Aura

Guest
@Xskode: randomize() is not meant to be run every time you need to get a random value. Run it once at the start of the game and you should be fine. ^^'

@mnbmnbmnb: A couple of issues with your code:

  • You are assigning stuff a value after you are creating an instance. You don't need to use a variable at all IMO unless you really need it. This should do the same thing:

    Code:
    instance_create(obj_thing.x, obj_thing.y-6000, choose(obj_stuff, obj_stuff2));
  • Why on the Earth are you using a value as large as 6000?
 
M

mnbmnbmnb

Guest
Both don't seem to be working so I guess it's something else. 5:00 am here so going to get some sleep and try again tomorrow.

To answer your question Aura I'm making a top down driving game where the car is stationary but the track moves and random segments of track come up. I go through 6000 pixels pretty fast.

It's a lot like the old Arcade game Spy Hunter.
 
M

mnbmnbmnb

Guest
So after slapping myself in the face a couple times I found the problem with one of my sprites. I actually did it the way you mentioned Aura before what I posted and since it was my first time using choose and since it didn't work. I thought I was doing something wrong with the syntax. Thanks everybody and sorry to be a bother.
 
Top