|
TheExDeus
|
|
Reply #1 Posted on: November 18, 2013, 03:45:03 pm |
|
|
Joined: Apr 2008
Posts: 1860
|
Create instance of random object instance_create(x,y,choose(object1,object2,object3,object4)); With a change perform next action if (ceil(random(n))==1){} Draw the lives as image for (unsigned int i=0; i<lives; ++i){ draw_sprite(sprite,0,x+i*sprite_get_width(sprite),y); } //If lives are positive or 0. Needs negative check if they can be negative. Create an effect effect_create_below(kind, x, y, size, color); effect_create_above(kind, x, y, size, color);
|
|
|
Logged
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #3 Posted on: November 20, 2013, 10:24:57 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Use [snip=EDL]if (random(n) < 1)[/snip] rather than [snip=EDL]if (ceil(random(n)) == 1)[/snip].
|
|
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
intygamer
|
|
Reply #5 Posted on: November 23, 2013, 10:38:09 am |
|
|
Joined: Mar 2013
Posts: 77
|
Ohh shit Harri you beat me to it, but yah that page is kind of out of date. Thanks all for links and additional info. Create instance of random object instance_create(x,y,choose(object1,object2,object3,object4));
I did not know you could create multiply instances with one comand. Thanks Joe
|
|
« Last Edit: November 23, 2013, 10:46:49 am by intygamer »
|
Logged
|
|
|
|
AsuMagic
|
|
Reply #6 Posted on: November 23, 2013, 03:34:53 pm |
|
|
Joined: Nov 2013
Posts: 23
|
I did not know you could create multiply instances with one comand.
Not sure if you think it spawns multiple instances, but if you think that, you're wrong, it's choosing the object in the list. choose(1,2,3,4); may return 1, 2, 3 or 4. Edit : If you want to spawn multiple objects, it is var objlist; objlist[0]=obj_something; objlist[1]=obj_someone; /* etc */ for(i=0; i<8 /* Total amount of objects in the list */; i+=1) { instance_create(x,y,objlist ); } ( Didn't test but should work ) enjoy
|
|
« Last Edit: November 23, 2013, 03:40:14 pm by AsuMagic »
|
Logged
|
|
|
|
|
intygamer
|
|
Reply #8 Posted on: November 23, 2013, 05:13:12 pm |
|
|
Joined: Mar 2013
Posts: 77
|
I did not know you could create multiply instances with one comand.
Not sure if you think it spawns multiple instances, but if you think that, you're wrong, it's choosing the object in the list. choose(1,2,3,4); may return 1, 2, 3 or 4.
So choose is the same as random, where computer picks 1 of 4 objects to create? Thanks for multiple instance script too. Joe
|
|
|
Logged
|
|
|
|
|
|
|
Goombert
|
|
Reply #12 Posted on: November 24, 2013, 08:35:35 am |
|
|
Location: Cappuccino, CA Joined: Jan 2013
Posts: 2993
|
Not just that though harri it is rather useful and saves you a lot of code from having to generate a random number table
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.
|
|
|
|
Josh @ Dreamland
|
|
Reply #14 Posted on: November 24, 2013, 11:53:49 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
You don't need a random number table. Choose picks a random number and then accesses that element in the va_list (or more specifically, enigma::varargs).
I recommend [snip=EDL]if (random(n) < 1)[/snip] over [snip=EDL]if (ceil(random(n)) == 1)[/snip] for non-aesthetic reasons, too. A true RNG will return values in [0,1). So if I use your code for "with a chance in 1 perform the next action," it will fail with some small probability (when the RNG returns zero). Mine only fails if the RNG is broken and returns one. You could just use <= if that is the case, of course.
|
|
« Last Edit: November 24, 2013, 11:58:37 am by Josh @ Dreamland »
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|