diff --git a/src/sig/engine/objects/Object.java b/src/sig/engine/objects/Object.java index 8d4879f..b215f9b 100644 --- a/src/sig/engine/objects/Object.java +++ b/src/sig/engine/objects/Object.java @@ -92,6 +92,10 @@ public abstract class Object implements GameEntity{ DrawLoop.Draw_Sprite(x,y,sprite); } + protected void Draw_Sprite(double x, double y, Sprite sprite, Transform transform){ + DrawLoop.Draw_Sprite(x,y,sprite,transform); + } + protected void Draw_Animated_Sprite(double x, double y, AnimatedSprite sprite, double frameIndex){ DrawLoop.Draw_Animated_Sprite(x,y,sprite,frameIndex); } diff --git a/src/sig/events/Event.java b/src/sig/events/Event.java new file mode 100644 index 0000000..78e11a1 --- /dev/null +++ b/src/sig/events/Event.java @@ -0,0 +1,8 @@ +package sig.events; + +import sig.engine.String; + +public interface Event{ + public String getDescription(); + public void perform(int x, int y); +} diff --git a/src/sig/events/SpawnEvent.java b/src/sig/events/SpawnEvent.java new file mode 100644 index 0000000..8ce220c --- /dev/null +++ b/src/sig/events/SpawnEvent.java @@ -0,0 +1,34 @@ +package sig.events; + +import java.lang.reflect.InvocationTargetException; + +import sig.RabiClone; +import sig.engine.String; +import sig.engine.objects.Object; + +public class SpawnEvent implements Event{ + + Class entity; + String description; + + public SpawnEvent(java.lang.String description,Class o) { + this.entity=o; + this.description=new String(description); + } + + @Override + public String getDescription() { + return description; + } + + @Override + public void perform(int x, int y) { + try { + RabiClone.OBJ.add((Object)entity.getDeclaredConstructor(new Class[]{Double.class,Double.class}).newInstance(x,y)); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException + | NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/sig/map/DataTile.java b/src/sig/map/DataTile.java index d2db68e..da052c9 100644 --- a/src/sig/map/DataTile.java +++ b/src/sig/map/DataTile.java @@ -1,19 +1,22 @@ package sig.map; import sig.engine.String; +import sig.events.Event; +import sig.events.SpawnEvent; +import sig.objects.Erinoah; public enum DataTile { NULL, //File is populated by 0s by default. This represents nothing. - BUN1("Spawns a blue bun"), - BUN2("Spawns a green bun"), - BUN3("Spawns a yellow bun"), - BUN4("Spawns a red bun"); + BUN1(new SpawnEvent("Spawns a blue bun",Erinoah.class)), + BUN2(new SpawnEvent("Spawns a green bun",Erinoah.class)), + BUN3(new SpawnEvent("Spawns a yellow bun",Erinoah.class)), + BUN4(new SpawnEvent("Spawns a red bun",Erinoah.class)); String description; DataTile(){} - DataTile(java.lang.String s) { - this.description=new String(s); + DataTile(Event e) { + this.description=e.getDescription(); } public String getDescription() { return description; diff --git a/src/sig/objects/Erinoah.java b/src/sig/objects/Erinoah.java index ee951f7..bb4a2d6 100644 --- a/src/sig/objects/Erinoah.java +++ b/src/sig/objects/Erinoah.java @@ -1,13 +1,16 @@ package sig.objects; -import sig.engine.Panel; +import sig.RabiClone; import sig.engine.Sprite; import sig.engine.objects.AnimatedObject; +import sig.objects.actor.RenderedObject; -public class Erinoah extends AnimatedObject{ +public class Erinoah extends AnimatedObject implements RenderedObject{ - public Erinoah(Panel panel) { - super(Sprite.ERINOAH, 6.5, panel); + public Erinoah(double x, double y) { + super(Sprite.ERINOAH,6.5,RabiClone.p); + setX(x); + setY(y); } @Override diff --git a/src/sig/objects/LevelRenderer.java b/src/sig/objects/LevelRenderer.java index f1a87ab..aae8aa8 100644 --- a/src/sig/objects/LevelRenderer.java +++ b/src/sig/objects/LevelRenderer.java @@ -18,6 +18,7 @@ import sig.map.Background; import sig.map.DataTile; import sig.map.Map; import sig.map.Tile; +import sig.objects.actor.RenderedObject; public class LevelRenderer extends Object{ @@ -28,6 +29,19 @@ public class LevelRenderer extends Object{ @Override public void update(double updateMult) { + for (int y=(int)(this.getY()/Tile.TILE_HEIGHT);y<(int)(RabiClone.BASE_HEIGHT/Tile.TILE_HEIGHT+this.getY()/Tile.TILE_HEIGHT+1);y++) { + if (y<0||y>Map.MAP_HEIGHT) { + continue; + } + for (int x=(int)(0+this.getX()/Tile.TILE_WIDTH);x<(int)(RabiClone.BASE_WIDTH/Tile.TILE_WIDTH+this.getX()/Tile.TILE_WIDTH+1);x++) { + if (x<0||x>Map.MAP_WIDTH) { + continue; + } + if (RabiClone.CURRENT_MAP.getDataTile(x,y)!=DataTile.NULL) { + + } + } + } } @Override @@ -49,8 +63,17 @@ public class LevelRenderer extends Object{ } } } + for (int i=0;i