#include "_Global.h"

class MainObject1 extends Object
{
	var m:Main;
	var g:_Graphics;

	var _x:Number;
	var _y:Number;
	var _dx:Number;
	var _dy:Number;
	var _col:Number;

	// コンストラクタ
	function MainObject1( m:Main, x:Number, y:Number, dx:Number, dy:Number )
	{
		this.m = m;
		g = m.g;

		_x = x;
		_y = y;
		_dx = dx;
		_dy = dy;
		_col = g.getColorOfRGB(
			Math.abs( m.rand.next( 256 ) ),
			Math.abs( m.rand.next( 256 ) ),
			Math.abs( m.rand.next( 256 ) ) );
	}

	function update():Void
	{
		var vibrate:Boolean = false;
		_x += _dx;
		if( (_x < 0) || (_x >= 240) )
		{
			vibrate = true;
			_dx = -_dx;
		}
		_y += _dy;
		if( (_y < 0) || (_y >= 240) )
		{
			vibrate = true;
			_dy = -_dy;
		}
		if( vibrate )
		{
//			m.fsc.vibrate( 100 );
			m.sin = 1;
		}
	}

	function draw():Void
	{
		g.setColor( _col );
		g.fillRect( _x - 5, _y - 5, 10, 10 );
	}
}
