I am trying to write a Mario 3 level 1 clone in Java, and my inspiration is Łukasz Jakowski's SMB 1 clone. You can find the source code on Github; I cloned his repo and looked thru it, noticing that the Mario sprites are actually pink boxes with Mario in them, but no such pink ever shows up.
Here's my code:
public class Mario{
//all numbers multiplied by 2 from OG game
protected MarioState state;
protected int x, y;
protected BufferedImage sprite;
public Mario(){
this.state = MarioState.SMALL;
this.x = 54;
this.y = 806;
URL spriteAtLoc = getClass().getResource("sprites/Mario/SmallStandFaceRight.bmp");
try{
sprite = ImageIO.read(spriteAtLoc);
} catch(IOException e){
System.out.println("sprite not found");
e.printStackTrace();
}
}
...
public void draw(Graphics g){
g.drawImage(sprite, this.x, this.y, null);
}
and then in my MarioComponent class, I draw paint this way:
public void paintComponent(Graphics g){
marioSprite.draw(g);
}
How can I get my program to omit colors in the OG sprite as Jakowski does? I know his is in C++ and mine in Java, and I'm making all the tiles objects rather than taking a whole level sheet (IDK if that's a good idea), but I ultimately plan to do this by making everything on the screen an object.