Add right click editor removal

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 2 years ago
parent cd993296e6
commit 65d7ed8cce
  1. BIN
      bin/controls.config
  2. 2
      src/sig/engine/KeyBind.java
  3. 10
      src/sig/events/DataEvent.java
  4. 3
      src/sig/events/Event.java
  5. 10
      src/sig/events/SpawnEvent.java
  6. 13
      src/sig/events/WaterEvent.java
  7. 18
      src/sig/map/DataTile.java
  8. 21
      src/sig/map/Map.java
  9. 21
      src/sig/objects/EditorRenderer.java

Binary file not shown.

@ -62,7 +62,7 @@ public class KeyBind {
}
} else
if (RabiClone.CONTROLLERS.length>port && id instanceof Identifier.Axis) {
return Math.abs(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())>=RabiClone.CONTROLLERS[port].getComponent(id).getDeadZone()&&Math.signum(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())==Math.signum(val);
return Math.abs(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())>=Math.max(RabiClone.CONTROLLERS[port].getComponent(id).getDeadZone(),0.2)&&Math.signum(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())==Math.signum(val);
}
else {
return false;

@ -0,0 +1,10 @@
package sig.events;
public class DataEvent implements Event{
@Override
public boolean perform(int x, int y) {
return true;
}
}

@ -1,9 +1,6 @@
package sig.events;
import sig.engine.String;
public interface Event{
public String getDescription();
/**
* Perform this event at position {@code (x,y)}.
* @return {@code True} to keep this event alive after it runs.

@ -3,23 +3,15 @@ package sig.events;
import java.lang.reflect.InvocationTargetException;
import sig.RabiClone;
import sig.engine.String;
import sig.engine.objects.Object;
import sig.map.Tile;
public class SpawnEvent implements Event{
Class<?> entity;
String description;
public SpawnEvent(java.lang.String description,Class<?> o) {
public SpawnEvent(Class<?> o) {
this.entity=o;
this.description=new String(description);
}
@Override
public String getDescription() {
return description;
}
@Override

@ -0,0 +1,13 @@
package sig.events;
import sig.RabiClone;
public class WaterEvent implements Event{
@Override
public boolean perform(int x, int y) {
RabiClone.CURRENT_MAP.getMap().setWaterLevel(RabiClone.CURRENT_MAP.getMap().getDataTileValue(x+1, y));
return true;
}
}

@ -1,8 +1,10 @@
package sig.map;
import sig.engine.String;
import sig.events.DataEvent;
import sig.events.Event;
import sig.events.SpawnEvent;
import sig.events.WaterEvent;
import sig.objects.enemies.BlueBun;
import sig.objects.Erinoah;
import sig.objects.enemies.GreenBun;
@ -11,11 +13,13 @@ import sig.objects.enemies.YellowBun;
public enum DataTile {
NULL, //File is populated by 0s by default. This represents nothing.
BUN0(new SpawnEvent("Spawns an Erinoa bun",Erinoah.class)),
BUN1(new SpawnEvent("Spawns a red bun",RedBun.class)),
BUN2(new SpawnEvent("Spawns a blue bun",BlueBun.class)),
BUN3(new SpawnEvent("Spawns a yellow bun",YellowBun.class)),
BUN4(new SpawnEvent("Spawns a green bun",GreenBun.class));
BUN0("Spawns an Erinoa bun",new SpawnEvent(Erinoah.class)),
BUN1("Spawns a red bun",new SpawnEvent(RedBun.class)),
BUN2("Spawns a blue bun",new SpawnEvent(BlueBun.class)),
BUN3("Spawns a yellow bun",new SpawnEvent(YellowBun.class)),
BUN4("Spawns a green bun",new SpawnEvent(GreenBun.class)),
WATERLEVEL("Sets the water level according to the data tile at X+1",new WaterEvent()),
DATATILE("Uses a value between 32768-65536 to represent extra data.",new DataEvent());
String description;
Event event;
@ -23,8 +27,8 @@ public enum DataTile {
DataTile(){
this.description=new String("");
}
DataTile(Event e) {
this.description=e.getDescription();
DataTile(java.lang.String description,Event e) {
this.description=new String(description);
this.event=e;
}
public String getDescription() {

@ -37,6 +37,8 @@ public class Map {
byte[] types = new byte[MAP_SCREENS_X*MAP_SCREENS_Y];
char[] data = new char[MAP_WIDTH*MAP_HEIGHT];
char waterLevel = 144;
int eventTileCount=0;
final static byte MAP_DATA = 0;
@ -238,4 +240,23 @@ public class Map {
data[y*Map.MAP_WIDTH+x]=(char)(t.ordinal());
//System.out.println("Tile "+(y*MAP_WIDTH+x)+" is now "+tiles[y*MAP_WIDTH+x]+".");
}
public char getWaterLevel() {
return waterLevel;
}
public void setWaterLevel(char waterLevel) {
this.waterLevel = waterLevel;
}
/*
* This will return the tile's value minus 32768.
* This value represents a data tile value, but not
* necessarily a data tile.
*/
public char getDataTileValue(int x,int y) {
return (char)(data[y*Map.MAP_WIDTH+x]-32768);
}
}

@ -32,6 +32,10 @@ public class EditorRenderer extends LevelRenderer{
final static char CAMERA_SPD = 512;
boolean dataTileView=false;
boolean inputDataTileValue=false;
char dataTileValue=0;
String inputMessageLogDisplay = new String();
public EditorRenderer(Panel panel) {
super(panel);
@ -58,19 +62,33 @@ public class EditorRenderer extends LevelRenderer{
if (up-down!=0) {
setY(Math.max(0,getY()+(down-up)*CAMERA_SPD*updateMult));
}
if (!inputDataTileValue) {
boolean left_mb = MouseHeld(MouseEvent.BUTTON1);
// boolean middle_mb = MouseHeld(MouseEvent.BUTTON2);
// boolean right_mb = MouseHeld(MouseEvent.BUTTON3);
boolean right_mb = MouseHeld(MouseEvent.BUTTON3);
if(left_mb){
int tileX = (int)(RabiClone.MOUSE_POS.getX()+getX())/Tile.TILE_WIDTH;
int tileY = (int)(RabiClone.MOUSE_POS.getY()+getY())/Tile.TILE_HEIGHT;
if (dataTileView) {
RabiClone.CURRENT_MAP.ModifyDataTile(tileX, tileY, selectedDataTile);
if (selectedDataTile==DataTile.DATATILE) {
inputDataTileValue=true;
}
} else {
RabiClone.CURRENT_MAP.ModifyTile(tileX, tileY, selectedTile);
}
}
if (right_mb) {
int tileX = (int)(RabiClone.MOUSE_POS.getX()+getX())/Tile.TILE_WIDTH;
int tileY = (int)(RabiClone.MOUSE_POS.getY()+getY())/Tile.TILE_HEIGHT;
if (dataTileView) {
RabiClone.CURRENT_MAP.ModifyDataTile(tileX, tileY, DataTile.NULL);
} else {
RabiClone.CURRENT_MAP.ModifyTile(tileX, tileY, Tile.VOID);
}
}
if(KeyHeld(Action.SLIDE)&&KeyHeld(Action.FALL)){
AddMessage("Saving map...");
try {
@ -81,6 +99,7 @@ public class EditorRenderer extends LevelRenderer{
AddMessage(PaletteColor.RED,"Map failed to save: ",e.getLocalizedMessage());
}
}
}
updateMessageLog();
}

Loading…
Cancel
Save