Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //An inner Class of my game's list system in Java, Doesn't seem to work for some reason
- public class Query
- {
- private Text displayer;
- private LinkedList<AnimatedSprite> SList;
- public LinkedList<AnimatedSprite> getQueryList(){return SList;}
- boolean conditions;
- private Graphics2D G2D;
- public Query()
- {
- //System.out.println("Query Made");
- SList = new LinkedList<AnimatedSprite>();
- }
- public Query(Graphics2D G2D2)
- {
- //System.out.println("Query Made");
- SList = new LinkedList<AnimatedSprite>();
- G2D = G2D2;
- displayer = new Text(G2D, 30, Color.BLUE);
- //queryGUI("Query Made");
- }
- public Query(boolean con)
- {
- //System.out.println("Query Made");
- SList = new LinkedList<AnimatedSprite>();
- conditions = con;
- }
- public Query(boolean con, Graphics2D G2D2)
- {
- //System.out.println("Query Made");
- SList = new LinkedList<AnimatedSprite>();
- conditions = con;
- G2D = G2D2;
- displayer = new Text(G2D, 30, Color.BLUE);
- //queryGUI("Query Made");
- }
- public void updateQuery()
- {
- //Check target List
- //System.err.println("Query Update Called");
- queryGUI("Query Update Called");
- for(int I = 0; I < spritesM.size(); I++)
- {
- AnimatedSprite MS = getSLS(I);
- queryGUI("In Loop ONE");
- if(conditions == true)
- {
- //System.err.println("Con true");
- queryGUI("Con true");
- if(!SList.contains(MS))
- {
- //System.err.println("Sprite Added");
- queryGUI("Sprite Added");
- SList.add(MS);
- }
- else
- {
- continue;
- }
- }
- /*
- else if(conditions == false)
- {
- //System.err.println("Con false");
- queryGUI("Con false");
- if(SList.contains(MS))
- {
- //System.err.println("Sprite removed");
- queryGUI("Sprite removed");
- SList.remove(MS);
- }
- else if(MS == null && SList.contains(MS))
- {
- //System.err.println("Sprite removed");
- queryGUI("Sprite removed");
- SList.remove(MS);
- }
- else
- {
- continue;
- }
- }*/
- }
- //Check Query's list
- for(int I = 0; I < SList.size(); I++)
- {
- AnimatedSprite MS = SList.get(I);
- queryGUI("In Loop TWO");
- if(conditions == false)
- {
- if(SList.contains(MS))
- {
- //System.err.println("Sprite removed");
- queryGUI("Sprite removed");
- SList.remove(MS);
- }
- /*
- else if(MS == null && SList.contains(MS))
- {
- //System.err.println("Sprite removed");
- queryGUI("Sprite removed");
- SList.remove(MS);
- }*/
- }
- /*
- else if(conditions == true)
- {
- queryGUI("Con Still True");
- continue;
- }*/
- }
- }
- public void queryGUI()
- {
- if(G2D != null)
- {
- displayer.setText("" + SList.size());
- displayer.drawText(240, 340);
- }
- }
- public void queryGUI(String DSP)
- {
- if(G2D != null)
- {
- displayer.setText(DSP);
- displayer.drawText(240, 440);
- }
- }
- public boolean getConditions(){return conditions;}
- public void setConditions(boolean con){conditions = con;}
- }
- public void queryListUpdates()
- {
- //Check Query's list
- //System.err.println("queryListUpdates() loop Called");
- //queryGUI("queryListUpdates() loop Called");
- for(int I = 0; I < QList.size(); I++)
- {
- Query temp = (Query)QList.get(I);
- temp.queryGUI();
- //temp.queryGUI();
- queryListUpdates(temp);
- }
- }
- //in use declaration in game class
- public static GlobalList sprLists;
- public static GlobalList.Query areAsteriods;
- sprLists = new GlobalList();
- areAsteriods = sprLists.new Query(graphics());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement