How would create randomly generated barriers


(Reece Speight) #1

I am creating an endless running styled game but i cant seem to understand how to add any randomly generated barriers. As it stands I have been doing this four times package { import net.flashpunk.Entity; import net.flashpunk.FP; import net.flashpunk.Graphic; import net.flashpunk.Mask; import net.flashpunk.graphics.Image;

public class wall extends Entity
{
	[Embed(source="post.png")] public const POST:Class;
	public function wall()
	{	
		graphic = new Image(POST)
		y = 400;
		x = 800;
		setHitboxTo(graphic)
		type = "Wall";
		
	}
	
	override public function update():void
	{
		//move the position to the bottom
		x = x -5;
		if (x < 0){
			//remove from the world
			world.remove(this);
		}
	}
	
}

} Does anyone know how i can have these as randomly generated? Thanks!


How can I add enemies randomly?
(Jacob Albano) #2

There was a post about this recently that might help you.


(Zachary Lewis) #3

Here’s the source I put together in that other thread.