Image Array Issue..... Any ideas???

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2008
Posts: 3,844
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Image Array Issue..... Any ideas???

 
0
  #21
Feb 29th, 2008
I do see one thing without running it. I don't know if this is a problem or not, but within your "run" function you have this while loop (I changed the brackets presentation to make it easier to see):

  1. while(running)
  2. {
  3. renderGame();
  4. updateGame();
  5. paintScreen();
  6.  
  7. sleepTime = 100;
  8.  
  9. if(sleepTime > 0)
  10. {
  11. try
  12. {
  13. Thread.sleep(50);
  14. }
  15. catch(Exception exc)
  16. {
  17. }
  18. }
  19. }
Not sure when "running" is set false, but you will never get to your println statement while running is true as far as I can tell because you'll never get out of this while loop. So if the println statement is supposed to execute within this while loop, I think you may have a bracket problem.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: CaffeineCoder is an unknown quantity at this point 
Solved Threads: 0
CaffeineCoder CaffeineCoder is offline Offline
Light Poster

Re: Image Array Issue..... Any ideas???

 
0
  #22
Feb 29th, 2008
Below are a few more of the files associated with this application. To save space I didn't add Constants, FireworksSpinnerSprite, and FireworksRocketSprite. The instances for the latter two can be replaced with FireworskSprite, and any value referring to Constants can be made up. Let me know if you have question, chances are I'll still be online.

By the way, if you see a log of code blocks in comments /* */ don't be confused or suprised. I have made several attempts at this, and for safe keeping have relocated those same attempts to lower in the screen in case I wished to revisit.






Fireworks.java
main file that executes entire app

  1. package Fireworks;
  2.  
  3. import java.awt.*;
  4. import java.util.*;
  5. import java.applet.*;
  6. import javax.swing.*;
  7. import java.io.*;
  8. import java.net.*;
  9. import javax.sound.midi.*;
  10. import javax.sound.sampled.*;
  11. import java.applet.AudioClip;
  12. import java.awt.Container;
  13. import java.awt.Graphics2D;
  14. import java.awt.Image;
  15. import java.lang.*;
  16.  
  17. public class Fireworks extends javax.swing.JApplet
  18. //public class Fireworks extends javax.swing.JFrame
  19. {
  20. Container gameContainer;
  21. FireworksPanel fwPanel;
  22. InstructionsPanel fwGuide;
  23. FireworksDisplay fwDisplay;
  24.  
  25.  
  26. public Fireworks()
  27. {
  28. //initComponents();
  29. makeUI();
  30. setSize(Constants.WIDTH, Constants.HEIGHT);
  31. setVisible(true);
  32. }
  33.  
  34. public void makeUI()
  35. {
  36. fwDisplay = new FireworksDisplay();
  37. fwGuide = new InstructionsPanel();
  38. fwDisplay.setGame(this);
  39. fwGuide.setGame(this);
  40.  
  41. GameDisplay();
  42. add(fwDisplay);
  43. add(fwGuide);
  44. }
  45.  
  46. public void GameDisplay()
  47. {
  48. fwDisplay.setEnabled(true);
  49. fwDisplay.setVisible(true);
  50.  
  51. fwGuide.setEnabled(false);
  52. fwGuide.setVisible(false);
  53. }
  54.  
  55. public void StartGame()
  56. {
  57. fwPanel = new FireworksPanel();
  58. fwPanel.setGame(this);
  59. fwPanel.setFocusable(true);
  60. fwPanel.setEnabled(true);
  61. fwPanel.setVisible(true);
  62.  
  63. add(fwPanel);
  64. fwDisplay.setEnabled(false);
  65. fwDisplay.setVisible(false);
  66.  
  67. fwPanel.startGame();
  68. // init();
  69.  
  70. /*JFrame frame = new JFrame ("Explosion");
  71.   frame.add (new ExplosionComponent ());
  72.   frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
  73.   frame.setSize (400, 400);
  74.   frame.setVisible (true);*/
  75. }
  76.  
  77. public void GuideDisplay()
  78. {
  79. fwGuide.setEnabled(true);
  80. fwGuide.setVisible(true);
  81.  
  82. fwDisplay.setEnabled(false);
  83. fwDisplay.setVisible(false);
  84. }
  85.  
  86. public void Back()
  87. {
  88. fwDisplay.setVisible(true);
  89. fwDisplay.setEnabled(true);
  90.  
  91. fwGuide.setVisible(false);
  92. fwGuide.setEnabled(false);
  93. }
  94.  
  95. /*
  96.   public void init()
  97.   {
  98.   try {
  99.   java.awt.EventQueue.invokeAndWait(new Runnable()
  100.   {
  101.   public void run() {
  102.   initComponents();
  103.   }
  104.   });
  105.   } catch (Exception ex)
  106.   {
  107.   ex.printStackTrace();
  108.   }
  109.   }
  110.   */
  111.  
  112. /** This method is called from within the init() method to
  113.   * initialize the form.
  114.   * WARNING: Do NOT modify this code. The content of this method is
  115.   * always regenerated by the Form Editor.
  116.   */
  117. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
  118. private void initComponents() {
  119.  
  120. org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
  121. getContentPane().setLayout(layout);
  122. layout.setHorizontalGroup(
  123. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  124. .add(0, 400, Short.MAX_VALUE)
  125. );
  126. layout.setVerticalGroup(
  127. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  128. .add(0, 300, Short.MAX_VALUE)
  129. );
  130. }
  131. // </editor-fold>//GEN-END:initComponents
  132.  
  133.  
  134. // Variables declaration - do not modify//GEN-BEGIN:variables
  135. // End of variables declaration//GEN-END:variables
  136.  
  137. /*public static void main(String args[])
  138.   {
  139.   java.awt.EventQueue.invokeLater(new Runnable(){
  140.   public void run()
  141.   {
  142.   new Fireworks().setVisible(true);
  143.   }
  144.   });
  145.   }*/
  146. }


FireworksDisplay
shows opening window

  1. package Fireworks;
  2.  
  3. import java.awt.*;
  4.  
  5.  
  6.  
  7. public class FireworksDisplay extends javax.swing.JPanel
  8. {
  9. Fireworks Game;
  10. //int width, height;
  11.  
  12. public FireworksDisplay()
  13. {
  14. initComponents();
  15. setSize(Constants.WIDTH, Constants.HEIGHT);
  16. //width = Constants.WIDTH;
  17. //height = Constants.HEIGHT;
  18. repaint();
  19. }
  20.  
  21. public void setGame(Fireworks Game)
  22. {
  23. this.Game = Game;
  24. }
  25.  
  26. public Fireworks getGame()
  27. {
  28. return Game;
  29. }
  30.  
  31. public void paintComponents(Graphics g)
  32. {
  33. super.paintComponent(g);
  34. Graphics2D g2d = (Graphics2D)g;
  35. g2d.setFont(new Font("Times New Roman", Font.BOLD, 50));
  36. g2d.setColor(Color.BLUE);
  37. g2d.drawString("Fireworks Display", Constants.WIDTH/2, Constants.HEIGHT/2);
  38. g2d.setFont(new Font("Times New Roman", Font.BOLD, 15));
  39. g2d.drawString("Fireworks Display Program.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 40);
  40. g2d.drawString("Final Project, CS8680, Dr. Xu, KSU MSACS", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 60);
  41. g2d.drawString("Nathan Williams", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 80);
  42. g2d.drawString("Fall 2007.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 100);
  43. }
  44.  
  45.  
  46. /** This method is called from within the constructor to
  47.   * initialize the form.
  48.   * WARNING: Do NOT modify this code. The content of this method is
  49.   * always regenerated by the Form Editor.
  50.   */
  51. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
  52. private void initComponents() {
  53. jButton1 = new javax.swing.JButton();
  54. jButton2 = new javax.swing.JButton();
  55.  
  56. setLayout(null);
  57.  
  58. jButton1.setLabel("Start Game");
  59. jButton1.addActionListener(new java.awt.event.ActionListener() {
  60. public void actionPerformed(java.awt.event.ActionEvent evt) {
  61. jButton1ActionPerformed(evt);
  62. }
  63. });
  64.  
  65. add(jButton1);
  66. jButton1.setBounds(220, 170, 110, 23);
  67.  
  68. jButton2.setText("Instructions");
  69. jButton2.addActionListener(new java.awt.event.ActionListener() {
  70. public void actionPerformed(java.awt.event.ActionEvent evt) {
  71. jButton2ActionPerformed(evt);
  72. }
  73. });
  74.  
  75. add(jButton2);
  76. jButton2.setBounds(220, 200, 110, 23);
  77.  
  78. }// </editor-fold>//GEN-END:initComponents
  79.  
  80. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  81. Game.GuideDisplay();
  82. }//GEN-LAST:event_jButton2ActionPerformed
  83.  
  84. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  85. Game.StartGame();
  86. }//GEN-LAST:event_jButton1ActionPerformed
  87.  
  88.  
  89. // Variables declaration - do not modify//GEN-BEGIN:variables
  90. private javax.swing.JButton jButton1;
  91. private javax.swing.JButton jButton2;
  92. // End of variables declaration//GEN-END:variables
  93.  
  94. }



Fireworksmove
handles movement for fireworks object
  1. package Fireworks;
  2.  
  3.  
  4. public class FireworksMove implements Moveable
  5. {
  6. private int currX, currY;
  7. private int nextVx, nextVy;
  8. private int nextX, nextY;
  9.  
  10. public FireworksMove()
  11. {
  12. }
  13.  
  14. public void calcVelocity()
  15. {
  16. }
  17.  
  18. public void setCurrX(int x)
  19. {
  20. this.currX = x;
  21. }
  22.  
  23. public int getCurrX()
  24. {
  25. return this.currX;
  26. }
  27.  
  28. public void setCurrY(int y)
  29. {
  30. this.currY = y;
  31. }
  32.  
  33. public int getCurrY()
  34. {
  35. return this.currY;
  36. }
  37.  
  38. public void setNextVx(int vx)
  39. {
  40. this.nextVx = vx;
  41. }
  42.  
  43. public void setNextVy(int vy)
  44. {
  45. this.nextVy = vy;
  46. }
  47.  
  48. public int getNextVx()
  49. {
  50. return this.nextVx;
  51. }
  52.  
  53. public int getNextVy()
  54. {
  55. return this.nextVy;
  56. }
  57.  
  58. public int getNextX()
  59. {
  60. return this.nextX;
  61. }
  62.  
  63. public void setNextX(int nextX)
  64. {
  65. this.nextX = nextX;
  66. }
  67.  
  68. public int getNextY()
  69. {
  70. return this.nextY;
  71. }
  72.  
  73. public void setNextY(int y)
  74. {
  75. this.nextY = y;
  76. }
  77.  
  78. public void setPosition(int x, int y)
  79. {
  80. this.setCurrX(x);
  81. this.setCurrY(y);
  82. }
  83.  
  84. public void setVelocity(int vx, int vy)
  85. {
  86. this.setNextVx(vx);
  87. this.setNextVy(vy);
  88. }
  89.  
  90. public void updatePosition()
  91. {
  92. this.setNextX(getCurrX() + getNextVx());
  93. this.setNextY(getCurrY() + getNextVy());
  94. }
  95. }

FireworksSprite

  1. package Fireworks;
  2.  
  3. import java.awt.*;
  4. import java.awt.Color;
  5. import java.awt.Graphics2D;
  6. import java.awt.Graphics;
  7. import java.awt.Point;
  8. import java.util.*;
  9. import java.beans.PropertyChangeListener;
  10. import java.beans.PropertyChangeSupport;
  11. import java.lang.Thread;
  12. import java.lang.Math;
  13. import java.lang.*;
  14. import java.awt.image.BufferedImage;
  15. import javax.imageio.ImageIO;
  16.  
  17. public class FireworksSprite extends Sprite2D implements Runnable
  18. {
  19. FireworksMove fwm;
  20. PropertyChangeSupport propChange;
  21. boolean launched;
  22. private long LaunchTime;
  23. private long ExplodeTime;
  24. double seed;
  25. int[] vx, vy;
  26. public int PosX, PosY;
  27. int dx, dy, x, y;
  28. // AnimationSprite explosion;
  29. Thread thread;
  30. //private FireworksExplosionSprite bomb_Burst[];
  31. private FireworksSprite explosion[];
  32. private FireworksSprite oneExplosion;
  33. private BufferedImage burst[];
  34. int gravity = 20;
  35. int time = 0;
  36. int RocketX[], RocketY[];
  37. int burstCount = 90;
  38. int length = 150;
  39. Random random;
  40. public FireworksSprite()
  41. {
  42. super();
  43. propChange = new PropertyChangeSupport(this);
  44. fwm = new FireworksMove();
  45. LaunchTime = 0;
  46. ExplodeTime = 10;
  47. fwm.setVelocity(1,-5);
  48. launched = false;
  49. }
  50.  
  51.  
  52. public void setFireworksVelocity(int x, int y)
  53. {
  54. fwm.setVelocity(x, y);
  55. }
  56.  
  57. public void run()
  58. {
  59. }
  60.  
  61. public void paintSprite(Graphics2D g2d)
  62. {
  63. if(isVisible())
  64. {
  65. Random r = new Random();
  66. Color color = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
  67. g2d.setColor(color);
  68. g2d.fillOval(this.getLocx(), this.getLocy(), 5, 5);
  69. // call explosion once firework reaches alt of 15.
  70. if(this.getLocy()<=50 && this.getLocy()<=15)
  71. {
  72. //public void initBurst(Graphics2D g)
  73. //{
  74.  
  75.  
  76. /* burst = new BufferedImage[3];
  77.   try
  78.   {
  79.   burst[0] = ImageIO.read(getClass().getResource("images\\one.gif"));
  80.   burst[1] = ImageIO.read(getClass().getResource("images\\two.gif"));
  81.   burst[2] = ImageIO.read(getClass().getResource("images\\three.gif"));
  82.   //burst[3] = ImageIO.read(getClass().getResource(".gif"));
  83.   //burst[4] = ImageIO.read(getClass().getResource(".gif"));
  84.   //burst[5] = ImageIO.read(getClass().getResource(".gif"));
  85.   //burst[6] = ImageIO.read(getClass().getResource(".gif"));
  86.   //burst[7] = ImageIO.read(getClass().getResource(".gif"));
  87.   //burst[8] = ImageIO.read(getClass().getResource(".gif"));
  88.   //burst[9] = ImageIO.read(getClass().getResource(".gif"));
  89.   }catch (Exception ex){System.out.println("Invalid Image");}
  90.  
  91.   for(int i = 0; i < burst.length; i ++)
  92.   {
  93.   //for(int t = 0; t < 100; t ++)
  94.   //{
  95.   g2d.drawImage((BufferedImage)burst[i], 150, 150, null);
  96.   try
  97.   {
  98.   thread.sleep(100);
  99.   }
  100.   catch(InterruptedException x){}
  101.  
  102.   //}
  103.   }
  104.   */
  105. //load the explosion
  106. /*explosion = new AnimationSprite(this, g2d);
  107.   explosion.load("explosion96x96x16.png", 4, 4, 96, 96);
  108.   explosion.setFrameDelay(2);
  109.   explosion.setAlive(false);*/
  110. //startExplosion //this.getLocx(), this.getLocy(), g);
  111. //drawExplosions
  112. }
  113. }
  114. }
  115.  
  116. public void initExplosion()
  117. {
  118.  
  119. }
  120.  
  121. public void updateSprite()
  122. {
  123. if(isVisible())
  124. {
  125. fwm.setVelocity(fwm.getNextVx(), fwm.getNextVy());
  126. fwm.setPosition(this.getLocx(), this.getLocy());
  127. fwm.updatePosition();
  128. this.setLocx(fwm.getNextX());
  129. this.setLocy(fwm.getNextY());
  130. rocketDecay();
  131. fireNewLocation(new Point(this.getLocx(), this.getLocy()));
  132. }
  133. }
  134.  
  135.  
  136.  
  137. public void fireNewLocation(Point p)
  138. {
  139. Point oldLoc = new Point(0,0);
  140.  
  141. Point newLoc = p;
  142. propChange.firePropertyChange("NewP",oldLoc,newLoc);
  143. }
  144.  
  145. private void rocketDecay()
  146. {
  147. if(this.getLocy() <= 0 || this.getLocy() > 1000)
  148. { //firework no longer visible
  149. this.setActive(false);
  150. this.setVisible(false);
  151. }
  152.  
  153. //initBurst(PosX, PosY);
  154. }
  155.  
  156. public void addPropertyChangeListener(PropertyChangeListener listener)
  157. {
  158. propChange.addPropertyChangeListener(listener);
  159. }
  160.  
  161. public long getLaunchTime()
  162. {
  163. return this.LaunchTime;
  164. }
  165.  
  166. public boolean isLaunched()
  167. {
  168. return this.launched;
  169. }
  170.  
  171. public void setLaunched(boolean bool)
  172. {
  173. this.launched = bool;
  174. }
  175.  
  176. public void setLaunchTime(long LaunchTime)
  177. {
  178. this.LaunchTime = LaunchTime;
  179. }
  180.  
  181. public long getExplodeTime()
  182. {
  183. return this.ExplodeTime;
  184. }
  185.  
  186. public void setExplodeTime(long ExplodeTime)
  187. {
  188. this.ExplodeTime = ExplodeTime;
  189. }
  190.  
  191. public void setVel(int x, int y)
  192. {
  193. fwm.setVelocity(x, y);
  194. }
  195. }
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. /*a = r.nextInt(50); //(int)Math.random();
  203.   v = r.nextInt(50); //(int)Math.random();
  204.   System.out.println("a = " + a);
  205.   System.out.println("v = " + v);
  206.   valueA = v*Math.sin(a)*t;
  207.   valueB = (.5)*gravity*(t*t);
  208.   dx = v*Math.cos(a)*t;
  209.   dy = valueA - valueB; //v*Math.sin(a)*t-.5gravity*t*t;
  210.   System.out.println("dx = " + dx);
  211.   System.out.println("dy = " + dy);*/
  212.  
  213.  
  214.  
  215.  
  216. /*
  217. class FireworksExplosionSprite
  218. {
  219.   public int powerLevel;
  220.   public int burstCount;
  221.   public int length_of_stream;
  222.   public int gravity;
  223.   public int time;
  224.   public int[] vx, vy;
  225.   public int x, y;
  226.   public double seed;
  227.   Color color;
  228.   public boolean sleep = true;
  229.   private int dx, dy;
  230.   private Random random;
  231.  
  232.   public FireworksExplosionSprite(int xSprite, int ySprite, int g)
  233.   {
  234.   dx = xSprite;
  235.   dy = ySprite;
  236.   gravity = g;
  237.   }
  238.  
  239.   public void initExplosion(int power, int burst, int length, Color burstColor, long seed)
  240.   {
  241.   powerLevel = power;
  242.   burstCount = burst;
  243.   length_of_stream = length;
  244.   color = burstColor;
  245.   random = new Random(seed);
  246.   vx = new int[burstCount];
  247.   vy = new int[burstCount];
  248.  
  249.   for(int i = 0; i < burstCount; i ++)
  250.   {
  251.   vx[i] = (int)(Math.random()*powerLevel)-powerLevel/2;
  252.   vy[i] = (int)(Math.random()*powerLevel*7/8)-powerLevel/8;
  253.   }
  254.   }
  255.  
  256.   public void start()
  257.   {
  258.   time = 0;
  259.   sleep = false;
  260.   }
  261.  
  262. */
  263. /*public void setExplosionSpeed(int burstSpeed)
  264. {
  265. }
  266.  
  267. public int getExplosionSpeed(int burstSpeed)
  268. {
  269. return burstSpeed;
  270. }
  271.  
  272. public void setExplosionStyle(int burstSpeed)
  273. {
  274. }
  275.  
  276. public int getExplosionStyle(int burstSpeed)
  277. {
  278. return burstSpeed;
  279. }
  280.  
  281. public void setBurstEnergy(int burstSpeed)
  282. {
  283. }
  284.  
  285. public int getBurstEnergy(int burstSpeed)
  286. {
  287. return burstSpeed;
  288. }
  289.  
  290. public void setRocketNumber(int burstSpeed)
  291. {
  292. }
  293.  
  294. public int getRocketNumber(int burstSpeed)
  295. {
  296. return burstSpeed;
  297. }
  298.  
  299. public void setBurstCount(int burstSpeed)
  300. {
  301. }
  302.  
  303. public int getBurstCount(int burstSpeed)
  304. {
  305. return burstSpeed;
  306. }
  307.  
  308. public void setRocketTailLength(int burstSpeed)
  309. {
  310. }
  311.  
  312. public int getRocketTailLength(int burstSpeed)
  313. {
  314. return burstSpeed;
  315. }
  316.  
  317. public void setGravityStrength(int burstSpeed)
  318. {
  319. }
  320.  
  321. public int getGravityStrength(int burstSpeed)
  322. {
  323. return burstSpeed;
  324. }*/
  325.  
  326.  
  327. /* public void paint(Graphics g)
  328.   {
  329.   if(!sleep)
  330.   {
  331. if(time < length_of_stream)
  332. {
  333.   double s;
  334. for(int i = 0; i < burstCount; i ++)
  335. {
  336.   s = (double)time/100;
  337.   x = (int)(vx[i]*s);
  338.   y = (int)(vy[i]*s-gravity*s*s);
  339.   g.setColor(Color.YELLOW); //color);
  340.   g.drawLine(dx + x, dy - y, dx + x, dy - y);
  341.   if(time >= length_of_stream/2)
  342.   {
  343.   for(int k = 0; k < burstCount; k ++)
  344.   {
  345.   s = (double)((time-length_of_stream/2)*2+k)/100;
  346.   x = (int)(vx[i]*s);
  347.   y = (int)(vy[i]*s-gravity*s*s);
  348.   g.setColor(Color.BLACK);
  349.   g.drawLine(dx + x, dy - y, dx + x, dy - y);
  350.   }
  351.   }
  352.   }
  353.  
  354. time ++;
  355.   }
  356.   else
  357.   {
  358.   sleep = true;
  359.   }
  360.   }
  361.   }*/
  362. //}
  363.  
  364.  
  365.  
  366.  
  367. /* int i;
  368.   int e = 200;
  369.   int p = 100;
  370.   int l = 100;
  371.   long s = (long)(Math.random()*10000);
  372.   boolean sleep;
  373. //Graphics g = getGraphics();
  374.   while(true)
  375.   {
  376.   try
  377.   {
  378.   animation.sleep(20);
  379.   }
  380.   catch(InterruptedException x){}
  381.  
  382.   sleep=true;
  383.   for(i=0;i<MaxRocketNumber;i++)
  384.   sleep=sleep&&bomb_Burst[i].sleep;
  385.   if(sleep&&Math.random()*100<RocketStyleVariability)
  386.   {
  387.   e=200;
  388.   p=100;
  389.   l=100;
  390.   s=(long)(Math.random()*10000);
  391.   }
  392.   // }
  393.  
  394.   for(i=0;i<MaxRocketNumber;i++)
  395.   {
  396.   if(bomb_Burst[i].sleep&&Math.random()*MaxRocketNumber*l<1)
  397.   {
  398.  
  399.   bomb_Burst[i].initExplosion(e,p,l,Color.YELLOW,s);
  400.   bomb_Burst[i].start();
  401.   }
  402.   bomb_Burst[i].paint(g);
  403.   }
  404.   }
  405. */
  406.  
  407.  
  408.  
  409. /*int AnimationSpeed = 100;
  410.   int RocketValue = 20;
  411.   int RocketCount = 10;
  412.   int RocketPower = 500;
  413.   int RocketBurstCount = 50;
  414.   int RocketBurstLength = 100;
  415.   int time = 0;
  416.   int power, burst, length;
  417.   int dx, dy;
  418.   int RocketX[], RocketY[];
  419.   int Gravity = 20;
  420.   Random random;
  421.   //mx=350;
  422.   //my=200;
  423.  
  424.   power =(int)(Math.random()*RocketPower*3/4) + RocketPower/4+1;
  425.   burst =(int)(Math.random()*RocketCount*3/4) + RocketCount/4+1;
  426.   length =(int)(Math.random()*RocketBurstLength*3/4) + RocketBurstLength/4+1;
  427.   int i;
  428.   long seed=(long)(Math.random()*10000);
  429.   boolean sleep;
  430.  
  431.   while(true)
  432.   {
  433.   try {
  434.   animation.sleep(100/AnimationSpeed);
  435.   }
  436.   catch(InterruptedException err){}
  437.   sleep=true;
  438.   if(sleep&&Math.random()*100<RocketValue)
  439.   {
  440.   power = 200;
  441.   burst = 100;
  442.   length = 100;
  443.   seed=(long)(Math.random()*10000);
  444.   }
  445.   random=new Random(seed);
  446.   RocketX=new int[burst];
  447.   RocketY=new int[burst];
  448.   dx=150;
  449.   dy=150;
  450.   for(i=0;i<burst;i++)
  451.   {
  452.   RocketX[i]=(int)(Math.random()*power)-power/2;
  453.   RocketY[i]=(int)(Math.random()*power*7/8)-power/8;
  454.   }
  455.  
  456.   if(time<length)
  457.   {
  458.   double sl;
  459.   Color color;
  460.  
  461.   for(i=0;i<burst;i++)
  462.   {
  463.   sl=(double)time/100;
  464.   x=(int)(RocketX[i]*sl);
  465.   y=(int)(RocketY[i]*sl-Gravity*sl*sl);
  466.  
  467.   g.setColor(Color.YELLOW);
  468.   g.drawLine(dx+x,dy-y,dx+x,dy-y);
  469.  
  470.   if(time>=length/2)
  471.   {
  472.   int j;
  473.   for(j=0;j<2;j++)
  474.   {
  475.   sl=(double)((time-length/2)*2+j)/100;
  476.   x=(int)(RocketX[i]*sl);
  477.   y=(int)(RocketY[i]*sl-Gravity*sl*sl);
  478.  
  479.   g.setColor(Color.black);
  480.   g.drawLine(dx+x,dy-y,dx+x,dy-y);
  481.   }
  482.   }
  483.   }
  484.  
  485.   time++;
  486.   }
  487.   }*/
  488.  
  489. //Explosion = new FireworksSprite[30];
  490. /*for(int i = 0; i < Explosion; i++)
  491.   {
  492.   double a = Math.random() * 2.0f * 3.1415f;
  493.   double r = Math.random() * 1.0f;
  494.  
  495.   double dx = Math.cos(a) * r;
  496.   double dy = Math.sin(a) * r;
  497.  
  498.   //Explosion[i] = new Bullet(x0, y0, dx0 + dx, dy0 + dy, _g, _size, _xmax, _ymax, _trail, _life_len, _fg, _bg);
  499.   }*/
  500.  
  501. /* AnimationSpeed = 1;
  502. RocketStyleVariability = 10;
  503. MaxRocketNumber = 1;
  504. MaxRocketExplosionEnergy = 500;
  505. MaxRocketPatchNumber = 90;
  506. MaxRocketPatchLength = 150;
  507. Gravity = 20;
  508.  
  509. bomb_Burst = new FireworksExplosionSprite[MaxRocketNumber];
  510. for(int i = 0; i < MaxRocketNumber; i ++)
  511. bomb_Burst[i] = new FireworksExplosionSprite(x, y, Gravity);*/
  512.  
  513. /* int AnimationSpeed = 100;
  514.   int RocketValue = 20;
  515.   int RocketCount = 10;
  516.   int RocketPower = 500;
  517.   int RocketBurstCount = 50;
  518.   int RocketBurstLength = 100;
  519.   int time = 0;
  520.   int power, burst, length;
  521.   int dx, dy;
  522.   int RocketX[], RocketY[];
  523.   int Gravity = 20;
  524.   Random random;
  525.   mx=350;
  526.   my=200;
  527.  
  528.   power =(int)(Math.random()*RocketPower*3/4) + RocketPower/4+1;
  529.   burst =(int)(Math.random()*RocketCount*3/4) + RocketCount/4+1;
  530.   length =(int)(Math.random()*RocketBurstLength*3/4) + RocketBurstLength/4+1;
  531.   int i;
  532.   long seed=(long)(Math.random()*10000);
  533.   boolean sleep;
  534.  
  535.   while(true)
  536.   {
  537.   try {
  538.   animation.sleep(100/AnimationSpeed);
  539.   }
  540.   catch(InterruptedException err){}
  541.   sleep=true;
  542.   if(sleep&&Math.random()*100<RocketValue)
  543.   {
  544.   power = 200;
  545.   burst = 100;
  546.   length = 100;
  547.   seed=(long)(Math.random()*10000);
  548.   }
  549.   random=new Random(seed);
  550.   RocketX=new int[burst];
  551.   RocketY=new int[burst];
  552.   dx=150;
  553.   dy=150;
  554.   for(i=0;i<burst;i++)
  555.   {
  556.   RocketX[i]=(int)(Math.random()*power)-power/2;
  557.   RocketY[i]=(int)(Math.random()*power*7/8)-power/8;
  558.   }
  559.  
  560.   if(time<length)
  561.   {
  562.   double sl;
  563.   Color color;
  564.  
  565.   for(i=0;i<burst;i++)
  566.   {
  567.   sl=(double)time/100;
  568.   x=(int)(RocketX[i]*sl);
  569.   y=(int)(RocketY[i]*sl-Gravity*sl*sl);
  570.  
  571.   g.setColor(Color.RED);
  572.   g.drawLine(dx+x,dy-y,dx+x,dy-y);
  573.  
  574.   if(time>=length/2)
  575.   {
  576.   int j;
  577.   for(j=0;j<2;j++)
  578.   {
  579.   sl=(double)((time-length/2)*2+j)/100;
  580.   x=(int)(RocketX[i]*sl);
  581.   y=(int)(RocketY[i]*sl-Gravity*sl*sl);
  582.  
  583.   g.setColor(Color.black);
  584.   g.drawLine(dx+x,dy-y,dx+x,dy-y);
  585.   }
  586.   }
  587.   }
  588.  
  589.   time++;
  590.   }
  591.  
  592.   //showBurst(x, y, g);
  593.   }*/
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601. /*public void initBurst(Graphics2D g)
  602. {
  603.   int gravity, a, v, T, L, x, y;
  604.   explosion = new FireworksSprite[100];
  605.   oneExplosion = new FireworksSprite();
  606.   double valueA, valueB, dx, dy;
  607.   int t = 0;
  608.   Random r = new Random();
  609.   for(t = 0; t < explosion.length; t ++)
  610.   {
  611.   gravity = 20;
  612.   a = 15; //r.nextInt(5);
  613.   v = 10; //r.nextInt(5);
  614.   //System.out.println("a = " + a);
  615.   //System.out.println("v = " + v);
  616.   valueA = v*Math.sin(a)*t;
  617.   valueB = (.5)*gravity*(t*t);
  618.   dx = (int)v*Math.cos(a)*t;
  619.   dy = (int)valueA - valueB;
  620.   x = (int)dx;
  621.   y = (int)dy;
  622.   oneExplosion = new FireworksSprite();
  623.   oneExplosion.setSpriteH(15);
  624.   oneExplosion.setSpriteW(10);
  625.   oneExplosion.setLocx(x);
  626.   oneExplosion.setLocy(y);
  627.   oneExplosion.setActive(true);
  628.   oneExplosion.setVisible(true);
  629.   oneExplosion.setVel(0, v);
  630.   //System.out.print("Iterating through Array" + t);
  631.   /*explosion[t] = new FireworksSprite();
  632.   explosion[t].setSpriteH(15);
  633.   explosion[t].setSpriteW(10);
  634.   explosion[t].setLocx(x);
  635.   explosion[t].setLocy(y);
  636.   explosion[t].setActive(true);
  637.   explosion[t].setVisible(true);
  638.   explosion[t].setVel(0, v);
  639.   for (int i = 0; i < explosion.length; i ++)
  640.   {
  641.   g.setColor(Color.YELLOW);
  642.   g.fillOval(x, y, 25, 25);
  643.   //g.drawLine(x, y, x+50, y+50);
  644.   }
  645.   }
  646. }*/
  647. /*
  648. public void paintBurst(Graphics2D g)
  649. {
  650.   for (int i = 0; i < 100; i ++) //explosion.length; i ++)
  651.   {
  652.   //explosion[i].paintSprite(g);
  653.   }
  654. }*/
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662. /* int i;
  663.   int e = 200;
  664.   int p = 100;
  665.   int l = 100;
  666.   long s = (long)(Math.random()*10000);
  667.   boolean sleep;
  668. //Graphics g = getGraphics();
  669.   while(true)
  670.   {
  671.   try
  672.   {
  673.   animation.sleep(20);
  674.   }
  675.   catch(InterruptedException x){}
  676.  
  677.   sleep=true;
  678.   for(i=0;i<MaxRocketNumber;i++)
  679.   sleep=sleep&&bomb_Burst[i].sleep;
  680.   if(sleep&&Math.random()*100<RocketStyleVariability)
  681.   {
  682.   e=200;
  683.   p=100;
  684.   l=100;
  685.   s=(long)(Math.random()*10000);
  686.   }
  687.   }*/


Moveable
(interface)

  1. package Fireworks;
  2.  
  3. public interface Moveable
  4. {
  5. public abstract void setPosition(int x, int y);
  6. public abstract void setVelocity(int vx, int vy);
  7. public abstract void updatePosition();
  8. }


Sprite
  1. package Fireworks;
  2.  
  3. import java.awt.*;
  4.  
  5. abstract class Sprite
  6. {
  7. protected boolean visible;
  8. protected boolean active;
  9.  
  10. abstract void paintSprite(Graphics2D g);
  11. abstract void updateSprite();
  12.  
  13. public boolean isVisible()
  14. {
  15. return visible;
  16. }
  17.  
  18. public void setVisible(boolean b)
  19. {
  20. visible = b;
  21. }
  22.  
  23. public boolean isActive()
  24. {
  25. return active;
  26. }
  27.  
  28. public void setActive(boolean b)
  29. {
  30. active = b;
  31. }
  32.  
  33. public void suspend()
  34. {
  35. setVisible(false);
  36. setActive(false);
  37. }
  38.  
  39. public void restore()
  40. {
  41. setVisible(true);
  42. setActive(true);
  43. }
  44. }



Sprite2D

  1. package Fireworks;
  2.  
  3. import java.awt.*;
  4.  
  5. abstract class Sprite2D extends Sprite
  6. {
  7. protected int locx;
  8. protected int locy;
  9. protected int spriteW;
  10. protected int spriteH;
  11.  
  12. protected int xPoints[];
  13. protected int yPoints[];
  14.  
  15. Color color;
  16. boolean fill;
  17.  
  18. public void setLocx(int locx)
  19. {
  20. this.locx = locx;
  21. }
  22.  
  23. public int getLocx()
  24. {
  25. return this.locx;
  26. }
  27.  
  28. public void setLocy(int locy)
  29. {
  30. this.locy = locy;
  31. }
  32.  
  33. public int getLocy()
  34. {
  35. return this.locy;
  36. }
  37.  
  38. public void setSpriteH(int spriteH)
  39. {
  40. this.spriteH = spriteH;
  41. }
  42.  
  43. public int getSpriteH()
  44. {
  45. return this.spriteH;
  46. }
  47.  
  48. public void setSpriteW(int spriteW)
  49. {
  50. this.spriteW = spriteW;
  51. }
  52.  
  53. public int getSpriteW()
  54. {
  55. return this.spriteW;
  56. }
  57.  
  58. public void setFill(boolean b)
  59. {
  60. fill = b;
  61. }
  62.  
  63. public boolean getFill()
  64. {
  65. return fill;
  66. }
  67.  
  68. public boolean isFill()
  69. {
  70. return getFill();
  71. }
  72.  
  73. public void setColor(Color c)
  74. {
  75. color = c;
  76. }
  77.  
  78. public Color getColor()
  79. {
  80. return color;
  81. }
  82. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,844
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Image Array Issue..... Any ideas???

 
0
  #23
Mar 1st, 2008
Okay, I created this file for the Constants class. It might be better to have the real Constants (these are just random numbers):
  1. package Fireworks;
  2.  
  3. public class Constants
  4. {
  5. static int SPEED = 3000;
  6. static int WIDTH = 500;
  7. static int HEIGHT = 500;
  8. static int FIREWORKS_COUNT = 500;
  9. static int SPINNER_COUNT = 500;
  10. static int ROCKET_COUNT = 500;
  11. // Constants.SONG I left blank since I don't know what type it is.
  12. }

It won't compile without the SongSprite and InstructionsPanel classes though.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: CaffeineCoder is an unknown quantity at this point 
Solved Threads: 0
CaffeineCoder CaffeineCoder is offline Offline
Light Poster

Re: Image Array Issue..... Any ideas???

 
0
  #24
Mar 1st, 2008
Originally Posted by VernonDozier View Post
Okay, I created this file for the Constants class. It might be better to have the real Constants (these are just random numbers):
  1. package Fireworks;
  2.  
  3. public class Constants
  4. {
  5. static int SPEED = 3000;
  6. static int WIDTH = 500;
  7. static int HEIGHT = 500;
  8. static int FIREWORKS_COUNT = 500;
  9. static int SPINNER_COUNT = 500;
  10. static int ROCKET_COUNT = 500;
  11. // Constants.SONG I left blank since I don't know what type it is.
  12. }

It won't compile without the SongSprite and InstructionsPanel classes though.

Sorry 'bout that. Didn't think about that part. Here are those classes below.

Constants
  1. public class Constants
  2. {
  3. static public int WIDTH = 800;
  4. static public int HEIGHT = 800;
  5. static public int SPEED = 1000;
  6. static public int ROCKET_HEIGHT = 10;
  7. static public int ROCKET_WIDTH = 2;
  8. static public int FIREWORKS_COUNT = 10;
  9. static public int SPINNER_COUNT = 10;
  10. static public int ROCKET_COUNT = 10;
  11. static public String SONG = "WilliamTell.wav";
  12. static public String BANG = "fireworks.wav";
  13.  
  14.  
  15. public Constants()
  16. {
  17. }
  18.  
  19. }

SongSprite
  1.  
  2. import java.io.IOException;
  3. import java.text.DecimalFormat;
  4. import javax.sound.sampled.AudioFormat;
  5. import javax.sound.sampled.AudioInputStream;
  6. import javax.sound.sampled.AudioSystem;
  7. import javax.sound.sampled.Clip ;
  8. import javax.sound.sampled.DataLine;
  9. import javax.sound.sampled.LineEvent;
  10. import javax.sound.sampled.LineListener;
  11. import javax.sound.sampled.LineUnavailableException;
  12. import javax.sound.sampled.UnsupportedAudioFileException ;
  13. import javax.sound.midi.*;
  14. import javax.sound.sampled.*;
  15. import java.applet.AudioClip;
  16. import java.util.*;
  17. import java.applet.*;
  18. import javax.swing.*;
  19. import java.io.*;
  20. import java.net.*;
  21.  
  22.  
  23.  
  24. public class SongSprite implements LineListener
  25. {
  26. private String name;
  27. private Clip SongClip;
  28. private String file;
  29. private DecimalFormat df;
  30.  
  31.  
  32. public SongSprite()
  33. {
  34. }
  35.  
  36. public void setFilename(String Songfile)
  37. {
  38. this.file = file;
  39. }
  40.  
  41. public String getFilename()
  42. {
  43. return file;
  44. }
  45.  
  46.  
  47. /*public void loadClip()
  48.   {
  49.  
  50.   try
  51.   {
  52.   Sequence midiSong = MidiSystem.getSequence(getClass().getResource("WilliamTell.mid"));
  53.   Sequencer midiSequence = MidiSystem.getSequencer();
  54.   midiSequence.setSequence(midiSong);
  55.   midiSequence.open();
  56.   midiSequence.start();
  57.   } catch (MalformedURLException e) {
  58.   } catch (IOException e) {
  59.   } catch (InvalidMidiDataException e) {
  60.   } catch (MidiUnavailableException e) {}
  61.   }
  62.   */
  63. /* try
  64.   {
  65.   AudioClip FireworkSound = Applet.newAudioClip (getClass().getResource(filename));
  66.   FireworkSound.play ();
  67.   }
  68.   catch(Exception e)
  69.   {
  70.   System.out.println("Problem with " + filename);
  71.   }*/
  72. //URL url = getClass().getResource(explosion);
  73. //getAudioClip(url).play();
  74. //getAudioClip(url).loop();
  75.  
  76.  
  77.  
  78. public void update(LineEvent SoundEvent)
  79. {
  80. SongClip.stop();
  81. SongClip.setFramePosition(0);
  82. SongClip.start();
  83. }
  84.  
  85. public void close(){
  86. if(SongClip != null){
  87. SongClip.stop ();
  88. SongClip.close();
  89. }
  90. }
  91.  
  92. public void play()
  93. {
  94. if(SongClip != null)
  95. {
  96. SongClip.start();
  97. }
  98. //else
  99. //System.out.Println("Invalid file selected.");
  100. }
  101.  
  102.  
  103. public void stop()
  104. {
  105. if(SongClip != null)
  106. {
  107. SongClip.stop();
  108. }
  109. //else
  110. //System.out.Println("Invalid file selected.");
  111. }
  112.  
  113. public void pause()
  114. {
  115. if(SongClip != null)
  116. SongClip.stop();
  117. //else
  118. //System.out.Println ("Invalid file selected.");
  119. }
  120.  
  121. public void resume()
  122. {
  123. if(SongClip != null)
  124. SongClip.start();
  125. //else
  126. //System.out.Println("Invalid file selected.");
  127. }
  128. }

InstructionsPanel
  1. import java.awt.*;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.event.*;
  7. import java.awt.Container;
  8. import javax.swing.*;
  9. import javax.swing.JButton;
  10. import javax.imageio.ImageIO;
  11.  
  12. public class InstructionsPanel extends javax.swing.JPanel
  13. {
  14. Fireworks Game;
  15. //Graphics g;
  16.  
  17.  
  18. public InstructionsPanel()
  19. {
  20. initComponents();
  21. //paintComponent(g);
  22. }
  23.  
  24.  
  25. public void setGame(Fireworks Game)
  26. {
  27. this.Game = Game;
  28. }
  29.  
  30. // Variables declaration - do not modify
  31. // End of variables declaration
  32.  
  33. public void paintComponent(Graphics g)
  34. {
  35. super.paintComponent(g);
  36. Graphics2D g2d = (Graphics2D)g;
  37. g2d.setFont(new Font("TimesRoman", Font.BOLD,20));
  38. g2d.setColor(Color.BLACK);
  39.  
  40. g2d.setFont(new Font("Times New Roman", Font.BOLD, 15));
  41. g2d.drawString("Fireworks Display", Constants.WIDTH/2 + 20, Constants.HEIGHT/2);
  42. g2d.drawString("Story Line: It is time for your town's annual Fireworks show.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 40);
  43. g2d.drawString("As a new Pyrotechnics expert in the region, you have been hired to conduct this year's festivities.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 60);
  44. g2d.drawString("Due to past shows, the audience will be a hard sale to please.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 80);
  45. g2d.drawString("Earn points for each display and make the crowd happy.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 100);
  46. g2d.drawString("Will you succeed where others have failed?", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 120);
  47.  
  48. g2d.drawString("Instructions.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 160);
  49. g2d.drawString("Please click on a Firework type to launch a show to display.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 180);
  50. g2d.drawString("Each type of show earns points for the user.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 200);
  51. g2d.drawString("The objective is to reach a total of 100 points from Fireworks.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 220);
  52. g2d.drawString("Fireworks Rockets Show (Keyboard Letter C) -> 5 points.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 240);
  53. g2d.drawString("Fireworks Spinners show (Keyboard Letter V) -> 10 points.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 260);
  54. g2d.drawString("Finale show (all types) (Keyboard Letter B) -> 15 points.", Constants.WIDTH/2 + 20, Constants.HEIGHT/2 + 280);
  55. }
  56.  
  57.  
  58. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
  59. private void initComponents() {
  60. jButton1 = new javax.swing.JButton();
  61.  
  62. jButton1.setText("Back");
  63. jButton1.addActionListener(new java.awt.event.ActionListener() {
  64. public void actionPerformed(java.awt.event.ActionEvent evt) {
  65. jButton1ActionPerformed(evt);
  66. }
  67. });
  68.  
  69. org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
  70. this.setLayout(layout);
  71. layout.setHorizontalGroup(
  72. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  73. .add(layout.createSequentialGroup()
  74. .addContainerGap()
  75. .add(jButton1)
  76. .addContainerGap(335, Short.MAX_VALUE))
  77. );
  78. layout.setVerticalGroup(
  79. layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
  80. .add(layout.createSequentialGroup()
  81. .addContainerGap()
  82. .add(jButton1)
  83. .addContainerGap(266, Short.MAX_VALUE))
  84. );
  85. }// </editor-fold>
  86.  
  87. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  88. Game.Back();
  89. }
  90.  
  91.  
  92. // Variables declaration - do not modify
  93. private javax.swing.JButton jButton1;
  94. // End of variables declaration
  95.  
  96. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,844
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Image Array Issue..... Any ideas???

 
0
  #25
Mar 1st, 2008
Had to comment out the "org.jdesktop.layout.GroupLayout" lines since my NetBeans installation couldn't find them. I uncommented the "Fireworks.java" main function and ran that (I assume that's the main file to run?). I see no calls to the AbsFireworksPanel "run" function, so it's not just the println command that's not being implemented. The entire "run" function is not called. So I'm not sure which "main" is supposed to be implemented, where "run" is supposed to be called from for AbsFireworksPanel, and like I said, at least my Java installation can't handle the "org.desktop.layout.GroupLayout" lines since it can't find that package.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: CaffeineCoder is an unknown quantity at this point 
Solved Threads: 0
CaffeineCoder CaffeineCoder is offline Offline
Light Poster

Re: Image Array Issue..... Any ideas???

 
0
  #26
Mar 1st, 2008
Originally Posted by VernonDozier View Post
Had to comment out the "org.jdesktop.layout.GroupLayout" lines since my NetBeans installation couldn't find them. I uncommented the "Fireworks.java" main function and ran that (I assume that's the main file to run?). I see no calls to the AbsFireworksPanel "run" function, so it's not just the println command that's not being implemented. The entire "run" function is not called. So I'm not sure which "main" is supposed to be implemented, where "run" is supposed to be called from for AbsFireworksPanel, and like I said, at least my Java installation can't handle the "org.desktop.layout.GroupLayout" lines since it can't find that package.

I should have mentioned what IDE I'm using.....Sun Java Studio Enterprise 8.1 (it generates some of the stuff that your system didn't like).

As for the primary file, the fireworks.java is the correct one. I'll look through the run() statement again, but it should only be handling the outer instantiation of the program (start game, end game, blah blah).

I'll still have this window up if you have any questions......I'm *STILL* trying to figure this mess out.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,844
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Image Array Issue..... Any ideas???

 
0
  #27
Mar 1st, 2008
Originally Posted by CaffeineCoder View Post
I should have mentioned what IDE I'm using.....Sun Java Studio Enterprise 8.1 (it generates some of the stuff that your system didn't like).

As for the primary file, the fireworks.java is the correct one. I'll look through the run() statement again, but it should only be handling the outer instantiation of the program (start game, end game, blah blah).

I'll still have this window up if you have any questions......I'm *STILL* trying to figure this mess out.

Well, your test line:
  1. System.out.println("TEST EXPLODE!!");
is in the run function of AbsFireworksPanel and you were saying it doesn't print, so if that function is never called from anywhere, it's no surprise that it doesn't print. If all you want it to do is handle the outer stuff and it has nothing to do with where the explosion is being painted, maybe you should have your run function with the Thread sleep in the Fireworks class and take it out of AbsFireworksPanel.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: CaffeineCoder is an unknown quantity at this point 
Solved Threads: 0
CaffeineCoder CaffeineCoder is offline Offline
Light Poster

Re: Image Array Issue..... Any ideas???

 
0
  #28
Mar 1st, 2008
Originally Posted by VernonDozier View Post
Well, your test line:
  1. System.out.println("TEST EXPLODE!!");
is in the run function of AbsFireworksPanel and you were saying it doesn't print, so if that function is never called from anywhere, it's no surprise that it doesn't print. If all you want it to do is handle the outer stuff and it has nothing to do with where the explosion is being painted, maybe you should have your run function with the Thread sleep in the Fireworks class and take it out of AbsFireworksPanel.
I've tried placing a run() function in the extended class, but it doesn't do any good (only result was a black screen, and no score paint, or firework, or anything). I also tried getting rid of run entirely from the outer class and use it in the inner class; that too was a bust. The only reason the outer function has the println right now was that I was trying to attempt to "piggy-back" the code; have the thread support the extended class, while also working on the ABS class (hey, desperate attempt, I know). Of course, it too was a bust.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: CaffeineCoder is an unknown quantity at this point 
Solved Threads: 0
CaffeineCoder CaffeineCoder is offline Offline
Light Poster

Re: Image Array Issue..... Any ideas???

 
0
  #29
Mar 2nd, 2008
Originally Posted by VernonDozier View Post
Well, your test line:
  1. System.out.println("TEST EXPLODE!!");
is in the run function of AbsFireworksPanel and you were saying it doesn't print, so if that function is never called from anywhere, it's no surprise that it doesn't print. If all you want it to do is handle the outer stuff and it has nothing to do with where the explosion is being painted, maybe you should have your run function with the Thread sleep in the Fireworks class and take it out of AbsFireworksPanel.

Played with the code more. The run() works up to updateGame() call. The rest of the function works fine.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 46
Reputation: CaffeineCoder is an unknown quantity at this point 
Solved Threads: 0
CaffeineCoder CaffeineCoder is offline Offline
Light Poster

Re: Image Array Issue..... Any ideas???

 
0
  #30
Mar 5th, 2008
Is there a way to create a buffered image inside a JPanel instead of an applet? Was going through looking around for this, but the code doesn't like what I'm trying from the books.
Any references or ideas?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4527 | Replies: 32
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC