Spawn Spacing

33 views
Skip to first unread message

xhunterko

unread,
Apr 15, 2016, 7:10:17 PM4/15/16
to haxef...@googlegroups.com
So I'm making an avoider game where objects come from random spaces at the top of the screen.

Instead of it being random, how can I have it so the objects are spawned every 32 pixels, or every 16 pixels, apart from one another?

Currently I'm doing:

if (thing happen) spawnPill();

public function spawnPill():Void
   
{        
       
var DropPill = new Pill(Random.float(168,468),-180);    
         _pills
.add(DropPill);
   
}


Dondudu

unread,
Apr 15, 2016, 10:40:48 PM4/15/16
to HaxeFlixel
If you wanted to spawn at the locations e.g. 0,32,64,96... up to 320, you would generate a random integer between 0 and 10, then multiply it by 32. I hope you get the idea.

Ashiq A.

unread,
Apr 15, 2016, 10:58:27 PM4/15/16
to haxef...@googlegroups.com
The other option is to use something like (x / 32) * 32. 

--
HaxeFlixel Development Community
See our github https://github.com/haxeflixel/ and our documentation http://haxeflixel.com/documentation/
---
You received this message because you are subscribed to the Google Groups "HaxeFlixel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haxeflixel+...@googlegroups.com.
Visit this group at https://groups.google.com/group/haxeflixel.
To view this discussion on the web visit https://groups.google.com/d/msgid/haxeflixel/e485cb66-e508-426e-aece-3d390c018b47%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages