Advertisement
StormWingDelta

InnerQueryClassFailed

Jul 1st, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.32 KB | None | 0 0
  1. //An inner Class of my game's list system in Java, Doesn't seem to work for some reason
  2. public class Query
  3.     {
  4.         private Text displayer;
  5.         private LinkedList<AnimatedSprite> SList;
  6.         public LinkedList<AnimatedSprite> getQueryList(){return SList;}
  7.         boolean conditions;
  8.         private Graphics2D G2D;
  9.         public Query()
  10.         {
  11.             //System.out.println("Query Made");
  12.             SList = new LinkedList<AnimatedSprite>();
  13.         }
  14.         public Query(Graphics2D G2D2)
  15.         {
  16.             //System.out.println("Query Made");
  17.             SList = new LinkedList<AnimatedSprite>();
  18.             G2D = G2D2;
  19.             displayer = new Text(G2D, 30, Color.BLUE);
  20.             //queryGUI("Query Made");
  21.         }
  22.         public Query(boolean con)
  23.         {
  24.             //System.out.println("Query Made");
  25.             SList = new LinkedList<AnimatedSprite>();
  26.             conditions = con;
  27.            
  28.         }
  29.         public Query(boolean con, Graphics2D G2D2)
  30.         {
  31.             //System.out.println("Query Made");
  32.             SList = new LinkedList<AnimatedSprite>();
  33.             conditions = con;
  34.             G2D = G2D2;
  35.             displayer = new Text(G2D, 30, Color.BLUE);
  36.             //queryGUI("Query Made");
  37.         }
  38.        
  39.         public void updateQuery()
  40.         {
  41.             //Check target List
  42.             //System.err.println("Query Update Called");
  43.             queryGUI("Query Update Called");
  44.             for(int I = 0; I < spritesM.size(); I++)
  45.             {
  46.                 AnimatedSprite MS = getSLS(I);
  47.                 queryGUI("In Loop ONE");
  48.                 if(conditions == true)
  49.                 {
  50.                     //System.err.println("Con true");
  51.                     queryGUI("Con true");
  52.                     if(!SList.contains(MS))
  53.                     {
  54.                         //System.err.println("Sprite Added");
  55.                         queryGUI("Sprite Added");
  56.                         SList.add(MS);
  57.                     }
  58.                     else
  59.                     {
  60.                         continue;
  61.                     }
  62.                 }
  63.                 /*
  64.                 else if(conditions == false)
  65.                 {
  66.                     //System.err.println("Con false");
  67.                     queryGUI("Con false");
  68.                     if(SList.contains(MS))
  69.                     {
  70.                         //System.err.println("Sprite removed");
  71.                         queryGUI("Sprite removed");
  72.                         SList.remove(MS);
  73.                     }
  74.                     else if(MS == null && SList.contains(MS))
  75.                     {
  76.                         //System.err.println("Sprite removed");
  77.                         queryGUI("Sprite removed");
  78.                         SList.remove(MS);
  79.                        
  80.                     }
  81.                     else
  82.                     {
  83.                         continue;
  84.                     }
  85.                 }*/
  86.                
  87.             }
  88.            
  89.             //Check Query's list
  90.             for(int I = 0; I < SList.size(); I++)
  91.             {
  92.                 AnimatedSprite MS = SList.get(I);
  93.                 queryGUI("In Loop TWO");
  94.                 if(conditions == false)
  95.                 {
  96.                     if(SList.contains(MS))
  97.                     {
  98.                         //System.err.println("Sprite removed");
  99.                         queryGUI("Sprite removed");
  100.                         SList.remove(MS);
  101.                     }
  102.                     /*
  103.                     else if(MS == null && SList.contains(MS))
  104.                     {
  105.                         //System.err.println("Sprite removed");
  106.                         queryGUI("Sprite removed");
  107.                         SList.remove(MS);
  108.                        
  109.                     }*/
  110.                    
  111.                 }
  112.                 /*
  113.                 else if(conditions == true)
  114.                 {
  115.                    
  116.                     queryGUI("Con Still True");
  117.                     continue;
  118.                 }*/
  119.             }
  120.            
  121.            
  122.         }
  123.        
  124.         public void queryGUI()
  125.         {
  126.             if(G2D != null)
  127.             {
  128.                 displayer.setText("" + SList.size());
  129.                 displayer.drawText(240, 340);
  130.             }
  131.         }
  132.         public void queryGUI(String DSP)
  133.         {
  134.             if(G2D != null)
  135.             {
  136.                 displayer.setText(DSP);
  137.                 displayer.drawText(240, 440);
  138.             }
  139.         }
  140.        
  141.         public boolean getConditions(){return conditions;}
  142.         public void setConditions(boolean con){conditions = con;}
  143.        
  144.        
  145.     }
  146.    
  147.     public void queryListUpdates()
  148.     {
  149.         //Check Query's list
  150.         //System.err.println("queryListUpdates() loop Called");
  151.         //queryGUI("queryListUpdates() loop Called");
  152.         for(int I = 0; I < QList.size(); I++)
  153.         {
  154.             Query temp = (Query)QList.get(I);
  155.             temp.queryGUI();
  156.             //temp.queryGUI();
  157.             queryListUpdates(temp);
  158.         }
  159.        
  160.     }
  161.  
  162. //in use declaration in game class
  163. public static GlobalList sprLists;
  164. public static GlobalList.Query areAsteriods;
  165. sprLists = new GlobalList();
  166. areAsteriods = sprLists.new Query(graphics());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement