00001 // 00002 // Sprite.java 00003 // CGP-2D-Engine 00004 // 00005 // Created by Ryan Ruff, 1996. 00006 // Copyright 2009 ClassroomGamingProject.org. All rights reserved. 00007 // 00008 // This program is free software: you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 package org.classroomgaming.cgp; 00021 00022 import java.applet.Applet; 00023 import java.awt.Graphics; 00024 import java.awt.Image; 00025 import java.util.*; 00026 //import java.awt.image.ImageObserver; 00027 import org.classroomgaming.cgp.Entity; 00028 import org.classroomgaming.cgp.ImageManager; 00029 00035 class Sprite extends GameModule implements GameModule.Renderable { 00036 00037 protected int currentImageID; 00038 protected float x; 00039 protected float y; 00040 00041 public Sprite(String image, int i, int j) { 00042 00043 currentImageID = ImageManager.getInstance().load(image); 00044 00045 return; 00046 } 00047 00048 public Sprite() { 00049 00050 } 00051 00052 public Image getCurrentFrame() { 00053 00054 return ImageManager.getInstance().getImage(currentImageID); 00055 } 00056 00057 public void ponder(Entity o, float t) { 00058 x = o.getX(); 00059 y = o.getY(); 00060 } 00061 00062 public void handleEvent(Entity o, EventObject e) { 00063 } 00064 00065 public void render(Graphics g) { 00066 00067 int myX = CameraManager.getInstance().getScreenX((int) x); 00068 int myY = CameraManager.getInstance().getScreenY((int) y); 00069 00070 // g.drawImage(getCurrentFrame() , i2 , j2 , null); 00071 ImageManager.getInstance().drawImage(g, currentImageID, myX, myY); 00072 } 00073 }
1.5.8