view game/ResourceLoader.java @ 138:9eb791e2fa17

Optimize board updating logic, so that the old placed tiles need not to be redrawn from scratch on each screen update, as they do not change usually.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 25 Nov 2011 11:04:09 +0200
parents 4c0dec72e2f0
children d6d92845d6a2
line wrap: on
line source

/*
 * Ristipolku Resource Loader
 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
 */
package game;

import java.util.*;
import java.io.*;
import java.net.*;


public class ResourceLoader
{
    InputStream stream;
    String name;
    URL resourceURL;

    public ResourceLoader(String name)
    {
        this.name = name;
        resourceURL = getClass().getClassLoader().getResource(name);
        if (resourceURL != null)
            stream = getClass().getClassLoader().getResourceAsStream(name);

        System.out.print("ResourceLoader('"+ name +"'): "+ resourceURL +" - "+ stream +"\n");
    }

    public InputStream getStream()
    {
        return stream;
    }

    public URL getURL()
    {
        return resourceURL;
    }
}