View Javadoc

    1   /*
    2    * "Peko" Visual Novel System
    3    *
    4    * All Rights Reserved.
    5    * Copyright (c) 1999-2003 Tsukuba Bunko.
    6    *
    7    * $Id: PataPataEffect.java,v 1.1 2005/07/11 12:49:18 ppoi Exp $
    8    */
    9   package tsukuba_bunko.peko.canvas.stage.effect;
    10
    11  import	java.awt.Color;
    12  import	java.awt.Dimension;
    13  import	java.awt.Graphics2D;
    14
    15  import	java.awt.image.BufferedImage;
    16  import	java.awt.image.ImageObserver;
    17
    18  import	tsukuba_bunko.peko.canvas.stage.Effect;
    19
    20  /***
    21   * "ぱたぱた" エフェクトです。
    22   * @author	$Author: ppoi $
    23   * @version	$Revision: 1.1 $
    24   */
    25  public class PataPataEffect	extends Effect	{
    26
    27  	/***
    28  	 * <code>PataPataEffect</code> のインスタンスを作成します。
    29  	 */
    30  	public PataPataEffect()
    31  	{
    32  		super();
    33  	}
    34
    35
    36  	/***
    37  	 * エフェクト名 "peko:pata-pata" を取得します。
    38  	 */
    39  	public String getName()
    40  	{
    41  		return "pata-pata";
    42  	}
    43
    44  	/***
    45  	 * "pata-pata" を実行します。
    46  	 */
    47  	public void perform( BufferedImage screen, BufferedImage next )
    48  	{
    49  		ImageObserver	observer = getStageCanvas();
    50  		Graphics2D	g2 = screen.createGraphics();
    51  		g2.setColor( Color.black );
    52
    53  		Dimension	size = getCanvasSize();
    54
    55  		int	width = size.width;
    56  		int	height = size.height;
    57  		int	part = (width / 16) + ( (width % 16) != 0 ? 1 : 0 );
    58  		int	x = 0;
    59  		int	pos = 0;
    60
    61  		int	d = 0;
    62  		for( int i = 0; i < 4; ++i )	{
    63  			x += 4;
    64  			for( int j = part - 1; j >= 0; --j )	{
    65  				pos = (j * 16);
    66  				d = x;
    67  				if( pos + x <= width )	{
    68  					g2.setClip( pos, 0, d, height );
    69  					g2.fillRect( 0, 0, width, height );
    70  				}
    71  			}
    72  			drawImage( screen );
    73  			try	{
    74  				synchronized( this )	{
    75  					wait( 25L );
    76  				}
    77  			}
    78  			catch( Exception e )	{
    79  				e.printStackTrace();
    80  			}
    81  		}
    82
    83  		try	{
    84  			synchronized( this )	{
    85  				wait( 100L );
    86  			}
    87  		}
    88  		catch( Exception e )	{
    89  			e.printStackTrace();
    90  		}
    91
    92  		x = 0;
    93  		pos = 0;
    94  		d = 0;
    95  		for( int i = 0; i < 4; ++i )	{
    96  			x += 4;
    97  			for( int j = part - 1; j >= 0; --j )	{
    98  				pos = (j * 16);
    99  				d = x;
    100 				if( pos + x <= 640 )	{
    101 					g2.setClip( pos, 0, d, height );
    102 					g2.drawImage( next, 0, 0, observer );
    103 				}
    104 			}
    105 			drawImage( screen );
    106 			try	{
    107 				synchronized( this )	{
    108 					wait( 25L );
    109 				}
    110 			}
    111 			catch( Exception e )	{
    112 				e.printStackTrace();
    113 			}
    114 		}
    115 	}
    116 }