All pastes #467620 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-02 16:45 UTC
rendered paste body
import java.awt.*;
import javax.swing.*;
import javax.imageio.*;

import java.io.*;

public class Sprite extends JPanel
{
	private String image;
	private int x, y;
	Graphics g;
	private int current_x;
	
	public Sprite(Graphics _g, String _image, int _x, int _y)
	{
		g = _g;
		image = _image;
		x = _x;
		y=_y;
		
		try
		{
			g.drawImage(ImageIO.read(new File(image)), x, y, this);
		}
		
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	//change the x-value of the item
	void setX(int new_x)
	{
		current_x = current_x++;
		System.out.println("Set X: " + current_x);
		repaint();
	}
	
	//give the current value of the sprite
	int currentX()
	{
		return x;
		//System.out.println("Current X:" + current_x);
	}
}