summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/transition/SquareTransition.java
blob: dc178447842f7cd3bdbe9b9a99b38f47172dfba9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fourisland.fourpuzzle.transition;

import java.awt.Color;
import java.awt.Graphics2D;

/**
 *
 * @author hatkirby
 */
public class SquareTransition extends Transition {
    
    private int tick;
    public SquareTransition(boolean from) throws TransitionUnsupportedException
    {
        setDirection(from);
        
        if (from)
        {
            tick = 160;
        } else {
            tick = 0;
        }
    }
    
    public void render(Graphics2D g)
    {
        if (((!getDirection()) && (tick == 0)) || ((getDirection()) && (tick == 160)))
        {
            setRunning(false);
            return;
        }
        
        if (getDirection())
        {
            tick+=8;
        } else {
            tick-=8;
        }
        
        g.setBackground(Color.BLACK);
        g.fillRect(0, 0, 320, 240);
        g.setClip(160-tick, 140-tick, tick*2, tick*2-40);
    }

}