Do you like my tutorials?

Then consider supporting me on Ko-fi

Talking about Actionscript 2, Flash and Users contributions.

This is a Flash effect you can use for a background effect or for a shoot’em up wave (hint! hint!)

I received this script from Ashker (the creator of Olympclicks)

« Hello Emanuele. Today I tried to make an object move in a circular motion in Flash, and i succeeded. I also discovered that i could make other random motions by changing a few variables.

Thought of some ideas it could be used for : background animations, creating new level designs, creatin paths for Enemies. »

That’s right!

With this simple script:

attachMovie("ball", "ball", 1)
ball._x = 250
ball._y = 200
timey = 0
fps = 3
xvel = 0
yvel = 3
xcha = .1
ycha = .1
i = 0

onEnterFrame = function(){
	timey ++
	if(timey == fps){
		dave = _root.attachMovie("blob","blob" + i, _root.getNextHighestDepth())
		dave._x = ball._x
		dave._y = ball._y
		timey = 0
		i++
	}
}

ball.onEnterFrame = function(){
	this._x -= xvel
	this._y -= yvel
	xvel += xcha
	yvel -= ycha
	if(xvel >= 3 || xvel <= -3){
		xcha = -xcha 
	}
	if(yvel >= 3 || yvel <= -3){
		ycha = -ycha 
	}
	if(this._x > 500){
		this._x = 0
	}
	if(this._x < 0){
		this._x = 500
	}
	if(this._y > 400){
		this._y = 0
	}
	if(this._y < 0){
		this._y = 400
	}
}

playing with xvel, yvel, xcha and ycha you can achieve a wide range of effects.

Ashker invites you all to play with these variables and eventually publish here the most interesting results.

Here are some random effect you can make:

Download the source code and share interesting values, and I'll show you how to use them in a shoot'em up.

Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.