Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>main
parent
121dc6acb6
commit
f2a3ba9fd6
@ -0,0 +1,6 @@ |
||||
package sig.engine; |
||||
|
||||
public interface GameEntity { |
||||
public void update(double updateMult); |
||||
public void draw(int[] p); |
||||
} |
@ -0,0 +1,34 @@ |
||||
package sig.engine; |
||||
|
||||
public abstract class Object implements GameEntity{ |
||||
double x,y; |
||||
Sprite spr; |
||||
Panel panel; |
||||
|
||||
protected Object(Panel panel) { |
||||
this.panel=panel; |
||||
} |
||||
|
||||
public double getX() { |
||||
return x; |
||||
} |
||||
public void setX(double x) { |
||||
this.x = x; |
||||
} |
||||
public double getY() { |
||||
return y; |
||||
} |
||||
public void setY(double y) { |
||||
this.y = y; |
||||
} |
||||
public Sprite getSprite() { |
||||
return spr; |
||||
} |
||||
public void setSprite(Sprite spr) { |
||||
this.spr = spr; |
||||
} |
||||
|
||||
protected boolean KeyHeld(int key) { |
||||
return panel.KEYS.getOrDefault(key,false); |
||||
} |
||||
} |
@ -0,0 +1,29 @@ |
||||
package sig.objects; |
||||
|
||||
import sig.DrawLoop; |
||||
import sig.engine.Object; |
||||
import sig.engine.Panel; |
||||
import sig.engine.Sprite; |
||||
import java.awt.event.KeyEvent; |
||||
|
||||
public class Player extends Object{ |
||||
|
||||
public Player(Panel panel) { |
||||
super(panel); |
||||
this.setSprite(Sprite.NANA); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void update(double updateMult) { |
||||
if (KeyHeld(KeyEvent.VK_RIGHT)) { |
||||
setX(getX()+32*updateMult); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void draw(int[] p) { |
||||
DrawLoop.Draw_Sprite(this.getX(), this.getY(), this.getSprite()); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue