about summary refs log tree commit diff stats
path: root/vendor/nlohmann
Commit message (Collapse)AuthorAgeFilesLines
* Tracker connects to AP nowStar Rauchenberger2023-05-021-0/+24596
href='#n11'>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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fourisland.fourpuzzle.transition;

import com.fourisland.fourpuzzle.Game;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

/**
 *
 * @author hatkirby
 */
public class SquareTransition implements MultidirectionalTransition {
    
    private int tick;
    private TransitionDirection direction;
    public SquareTransition(TransitionDirection direction)
    {
        this.direction = direction;
        
        if (direction == TransitionDirection.Out)
        {
            tick = 160;
        } else {
            tick = 0;
        }
    }
    
    public boolean render(Graphics2D g)
    {
        if (direction == TransitionDirection.In)
        {
            tick+=8;
            
            g.drawImage(preTransition, 0, 0, null);
            g.drawImage(postTransition, 160-tick, 140-tick, tick*2+(160-tick), tick*2-40+(140-tick), 160-tick, 140-tick, tick*2+(160-tick), tick*2-40+(140-tick), null);
        } else {
            tick-=8;
            
            g.setColor(Color.BLACK);
            g.fillRect(0, 0, Game.WIDTH, 160-tick);
            g.fillRect(0, 0, 160-tick, Game.HEIGHT);
            g.fillRect(tick*2+(160-tick), 0, Game.WIDTH-(tick*2), Game.HEIGHT);
            g.fillRect(0, tick*2-40+(140-tick), Game.WIDTH, Game.HEIGHT-(tick*2-40));
        }
        
        if (((direction == TransitionDirection.Out) && (tick == 0)) || ((direction == TransitionDirection.In) && (tick == 160)))
        {
            return true;
        }
        
        return false;
    }

    public TransitionDirection getDirection()
    {
        return direction;
    }
    
    private BufferedImage preTransition;
    public void setPreTransition(BufferedImage preTransition)
    {
        this.preTransition = preTransition;
    }
    
    private BufferedImage postTransition;
    public void setPostTransition(BufferedImage postTransition)
    {
        this.postTransition = postTransition;
    }

}