Skip to content

Commit

Permalink
Adding and rendering zombie avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
ramielrowe committed Apr 8, 2012
1 parent 30d42d6 commit 88c3142
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/images.xml
Expand Up @@ -4,6 +4,7 @@
<resource key="image3" location="images/image3.png" />
<resource key="image4" location="images/image4.png" />
<resource key="player1" location="images/test_sprite.png" />
<resource key="zombie" location="images/test_zombie.png" />
<resource key="titleScreen" location="images/TitleScreen.png" />
<resource key="selector" location="images/cog_selector.png" />
<resource key="door" location="images/door.png" />
Expand Down
Binary file added resources/images/test_zombie.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion src/com/vulcastudios/actors/Zombie.java
Expand Up @@ -5,6 +5,7 @@
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.StateBasedGame;
Expand All @@ -23,6 +24,7 @@ public class Zombie{
private float yPosStart = 0;

private Button onButton = null;
private Image image = null;

private ResourceManager rm;
private LinkedList<ZombieMove> movementMap;
Expand Down Expand Up @@ -80,7 +82,8 @@ public void update(GameContainer container, StateBasedGame game, int delta){

public void render(GameContainer container, Graphics g){
g.setColor(Color.green);
g.drawRect(this.getXPos(), this.getYPos(), WIDTH, HEIGHT);
//g.drawRect(this.getXPos(), this.getYPos(), WIDTH, HEIGHT);
g.drawImage(this.getImage(), this.getXPos(), this.getYPos());
}

public float getXPos() {
Expand Down Expand Up @@ -115,4 +118,11 @@ public void setOnButton(Button b){
}
}

public Image getImage(){
if(this.image == null)
this.image = this.rm.getImage("zombie").getScaledCopy(Zombie.WIDTH, Zombie.HEIGHT);
return this.image;

}

}

0 comments on commit 88c3142

Please sign in to comment.