import java.awt.*; class Spelare extends Synliga{ final private int STEG=5, STORLEK=20; private int poäng=0, steg=0; private Spelplan plan; private SpelFrame hela; public Spelare(int x, int y, Spelplan p, SpelFrame sf){ super(x, y); plan=p; hela=sf; } public void skrivut(Graphics g){ g.setColor(Color.blue); g.fillRect(xpos,ypos,STORLEK,STORLEK); } public void move(int x, int y){ xpos+=STEG*x; ypos+=STEG*y; if (xpos<0) xpos=0; if (ypos<0) ypos=0; if (xpos+STORLEK>plan.getWidth()) xpos-=STEG; if (ypos+STORLEK>plan.getHeight()) ypos-=STEG; steg++; hela.setSteg(steg); } public void ökaPoäng(int ökning){ poäng+=ökning; hela.setPoäng(poäng); } public int getPoäng(){ return poäng; } public int getSteg(){ return steg; } }