Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Game Development / Newbie & Debugging Questions / Re: Double Buffering implementation on: 2012-12-11 16:12:34
Thanks, I will test both of the solutions!
2  Game Development / Newbie & Debugging Questions / Re: Double Buffering implementation on: 2012-12-11 15:51:32
the BufferStrategy  line wasn't here 10minutes before posting, I just forgot to remove it.

You mean the repaint(); method is already doublebuffered?Because I use it with ease =)

I just want to choose a faster way to paint on screen.. LWJGL seems a bit hard for me x) and slick2D don't convice me..

Can you lie to me and tell me that I can make it work in few days... (I keep my old files, i just change my graphic classes).
3  Game Development / Newbie & Debugging Questions / Re: Double Buffering implementation on: 2012-12-11 15:25:25
Ok, thanks ! So i'll try LWJGL and if my brain explode, I'll go for Slick2D..

Pray for me =)
4  Game Development / Newbie & Debugging Questions / Re: Double Buffering implementation on: 2012-12-11 15:17:36
Ok, thanks, i'll try LWJGL so. It seems good. I hope this isn't much harder than g2d wich I found easy to use.

What are the advantages to use LWJGL instead of graphics2D ?

5  Game Development / Newbie & Debugging Questions / Re: Double Buffering implementation on: 2012-12-11 15:13:05
Thanks !

So i need to recode my game entirely? Can i use JOGL/LWJGL instead?
6  Game Development / Newbie & Debugging Questions / Re: Double Buffering implementation on: 2012-12-11 14:55:28
Thx ultroman, but do you think using graphics2D as I do is good for a "complex" game?
7  Game Development / Newbie & Debugging Questions / Re: Double Buffering implementation on: 2012-12-11 14:49:22
No, I didn't tried Canvas. In fact, I was thinking about using JPanel.

Every tutorial about Double Buffering use "MyClass extends Frame"

I use MyClass extends JPanel.

Is there any better way (more stable/fast) to paint on screen?

My game works fine on my laptop but run with a non decent framerate on friends pc (with good hardware)

8  Game Development / Newbie & Debugging Questions / Re: [SOLVED] How to delete a object from the screen? on: 2012-12-11 14:21:00
You can create an object with the Square position and dimensions, put that Object in an Array and then draw what's inside the Array. Then, you can delete your Object if you want. (Dont forget to clear your screen)

The method you used dont create an Object, it just draw it.


So yes, you can "delete" your object on the screen by clearing your screen, or drawing something else over your Square.
9  Game Development / Newbie & Debugging Questions / Re: [SOLVED] How to delete a object from the screen? on: 2012-12-11 13:12:52
Just put a condition before drawing your square..

For example :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
boolean DrawSquare = true;


if (DrawSquare){
glBegin(GL_QUADS);
   glVertex2f(0, 0);
   glVertex2f(0, 50);
   glVertex2f(50, 50);
   glVertex2f(50, 0);
glEnd();
}
10  Game Development / Newbie & Debugging Questions / Double Buffering implementation on: 2012-12-11 12:43:50
Hello everyone, I made a game (not finished yet), and I want to implement the double Buffering to solve the tearing/flashing effect.

Problem, all the tutorials I tried don't work because I don't use a common way to paint on the screen (I think  Cry )

What can I do (simpliest way) to implement Double Buffering ?

Sorry for my bad English, I'm French. Thanks

Here's my code (simplified) :


My Main :

             
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   public static JFrame frame = new JFrame("The wake");


                frame.add(new Box());
      frame.setSize(LargeurFenetre+5,HauteurFenetre+27);  // les bords de la fenetre  &  l'en tete de la fenetre
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
      frame.setResizable(false);
      frame.createBufferStrategy(2);


Class Box :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
package hugo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.Timer;




public class Box extends JPanel implements ActionListener,MouseListener,MouseMotionListener{




   
   static Image Hero= new ImageIcon(Main.InstallPath+"hero/herocrouch.png").getImage();
        ... loading few images.
   

   float alphacomposite = 0;

   Timer time;

   Font font = new Font("Arial", Font.PLAIN, 20);
   static boolean handCursor = false;
   static boolean beating = false;

   static int crouchdecal = 0;

   static inputBoy Input = new inputBoy();

   Objects[] visible;
   human[] humans;

   static Particle[] particles;
   static Particle[] Bloodparticles;
   static Particle[] RainParticles;

   private double rainDarkness = 0.60f;
   private Color SkyColor = new Color(129, 107, 112);
   private Color flashColor = new Color(253,239,74);



   public Box(){

      addKeyListener(new AL());
      addMouseListener(this);
      addMouseMotionListener(this);
      setFocusable(true);
      setBackground(Color.BLACK);


      time = new Timer (Main.FPStiming, this);

      time.start();
      Main.maps.setCurrentMap(Main.maps.getCurrentMap().getID());

      particles = new Particle[20];
      Bloodparticles = new Particle[20];
      RainParticles = new Particle[600];




   }

   public void actionPerformed(ActionEvent e) {

      repaint();

   }

   public void paint(Graphics g){



      super.paint(g);
      Graphics2D g2d = (Graphics2D) g;
     
      g2d.clearRect(0, 0, 1200, 500);      //On supprime le fond
     g2d.setColor(SkyColor);
      g2d.fillRect(0, 0, 1200, 200);     //On dessine le fond
     for (int i=0;i<250;i++){

         g2d.setColor(new Color(SkyColor.getRed()+i/2,SkyColor.getGreen()+i/2,SkyColor.getBlue()+i/2));
         g2d.fillRect(0, 200+i, 1200, 2);
         i++;
      }
      g2d.setColor(Color.BLACK);
     
      ThunderEffect(g2d);


   
   }

   private void ThunderEffect(Graphics2D g2d){

      if (Nature.Thunder!=null && Nature.Thunder.alive){

         Nature.Thunder.ttl--;
         Stroke s = g2d.getStroke();

         for (int i = 0; i<9;i++){

            //System.out.println("point en:"+Nature.Thunder.getTree()[i+1][0]+" , "+Nature.Thunder.getTree()[i+1][1]+ "case :"+i);


            g2d.setStroke(new BasicStroke(5));
            if (!(Nature.Thunder.getTree()[i+1][0]==0)){
               g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,1f));
               g2d.setColor(Color.WHITE);
               g2d.drawLine(Nature.Thunder.getTree()[i][0], Nature.Thunder.getTree()[i][1], Nature.Thunder.getTree()[i+1][0], Nature.Thunder.getTree()[i+1][1]);
               //lumièe autour du l'éclair
              g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.6f));
               g2d.setStroke(new BasicStroke(10));
               g2d.drawLine(Nature.Thunder.getTree()[i][0], Nature.Thunder.getTree()[i][1], Nature.Thunder.getTree()[i+1][0], Nature.Thunder.getTree()[i+1][1]);
               //lumière lointaine
           }

            if (Nature.Thunder.getTree()[i+1][1]>300){   // quand l'eclair touche le sol
              g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.09f));
               g2d.fillRect(0, 0,1200, 505);
               g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,1f));
            }

         }




         g2d.setStroke(s);
         g2d.setColor(Color.BLACK);

         if (Nature.Thunder.ttl<1){
            Nature.Thunder.alive=false;
         }
      }




   }

   public void FadeOut(Graphics2D g2d){
   }

   public void paintMenu(Graphics2D g2d){
}

   public void paintDeath(Graphics2D g2d){
   }

   public void paintSettings(Graphics2D g2d){
   }

   public void paintInventory(Graphics2D g2d){
   }
11  Game Development / Newbie & Debugging Questions / Re: Comprehension problem... on: 2010-01-13 19:09:02
h3ckboy, the code you gave me worked fine for define a new name for each button, but, these buttons don't appear in my frame ^^

THe game don't crash, but Jbutton "DoodeVert" aren't in the frame... I tried to solve this problem by lots of way, and now, my code is crap and I think I have regressed...  Undecided
12  Game Development / Newbie & Debugging Questions / Comprehension problem... on: 2010-01-13 16:03:18
Hi everybody!  I still have the same problem..  Undecided

I know that's a nooby problem, but nobody understand me...

So, I will explain you very simply...


I have 3 classes: A main, a frame and a Button class.

The main lauch the frame class with "frame f = new frame();"

The frame class create a frame with :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
public class frame extends Button implements MouseListener, ActionListener{


   JFrame frame;



   
   public frame (){
     
      JPanel contenu;


      frame = new JFrame("Doode - Jeu");
      frame.setLayout(null);
     
      contenu = new JPanel();
           
      contenu.addMouseListener(this);
     
       frame.setContentPane(contenu);
       

         frame.setSize(400,400);
         frame.setResizable(false);
         frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         frame.setVisible(true);

Button b = new Button();
 
}}


The Button class create a JButton by :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
public int CoorX=0;
public int CoorY=0;
JPanel contenu;
public JButton Doode = new JButton ("",new ImageIcon("DoodeImages/vert.gif"));



public Button(){
      System.out.print("doode crée ");

      Doode.setBounds(15,15,50,50);
      Doode.setFocusPainted(false);
      Doode.setBorderPainted(false);                  
      Doode.setContentAreaFilled(false);
      Doode.addMouseListener(this);
      Doode.setVisible(true);

}

public void mouseClicked(MouseEvent arg0) {
   // TODO Auto-generated method stub
 
}



public void mouseEntered(MouseEvent arg0) {
   // TODO Auto-generated method stub
 
}




public void mouseExited(MouseEvent arg0) {
   // TODO Auto-generated method stub
 
}



public void mousePressed(MouseEvent arg0) {
   // TODO Auto-generated method stub
 
}



public void mouseReleased(MouseEvent f) {
   Object source = f.getSource();  

   if(SwingUtilities.isRightMouseButton(f)) {

      CoorX=f.getX();
      CoorY=f.getY();
 }

}}

I want that everytime I put the line "Button v = new Button();" in the frame class, it show me a new button...

I hope this time you understood me :/
13  Discussions / Miscellaneous Topics / Re: Holiday to US and EU on: 2010-01-13 14:18:35
Hey overkill, i visited baden baden and bad wilbad last year, this is beautiful ^^

For me, I'm in france, in Blois, we have lots of beautiful castles (loire castles)..
14  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2010-01-11 20:01:31
Pffff, i'll never solve it..  Undecided


Here is an exemple:

class DoodeVert:


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
public class DoodeVert implements MouseListener{



public int CoorX=0;
public int CoorY=0;
public Container contenu2;
public JButton DoodeVert = new JButton ("",new ImageIcon("DoodeImages/vert.gif"));



public DoodeVert(){
      System.out.print("doode crée ");
      contenu2.add(DoodeVerta);
      DoodeVerta.setBounds(15,15,650,75);
      DoodeVerta.setFocusPainted(false);
      DoodeVerta.setBorderPainted(false);                  
      DoodeVerta.setContentAreaFilled(false);
      DoodeVerta.addMouseListener(this);


public void mouseReleased(MouseEvent f) {
      Object source = f.getSource();  

      if(SwingUtilities.isRightMouseButton(f)) {
         CoorX=f.getX();
         CoorY=f.getY(); }
}
}}


class jeu:


public class Jeu extends DoodeVert implements MouseListener, ActionListener{


   JFrame frame;


   public Jeu (){
      
      JPanel contenu2;


      frame = new JFrame("Doode - Jeu");
      frame.setLayout(null);
      
      contenu2 = new JPanel();
            
      contenu2.addMouseListener(this);
      
       frame.setContentPane(contenu2);





      contenu2.setLayout(null);
      Image image = Toolkit.getDefaultToolkit().createImage("DoodeImages/map5.jpg");// nouveau JLabel backgound
      fond.setIcon(new ImageIcon(image));

      
      
      DoodeVert DoodeVert = new DoodeVert();
DoodeVert DoodeVert2 = new DoodeVert();

 }}
      



Please explain me what is wrong and what I have to fix. Cry

If you think I should have to use another library, say it to me.. (but only core please =)   )


Thank you...
15  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2010-01-05 19:17:11
Yes, thank you!!

But I can't add my "}" after my "public void mouseReleased(MouseEvent e) { "

This error appear: "void is an invalid type for the variable mouseReleased"

...


So, I can close my class just before it, but it's dumb because JButtons won't react to user's input.
16  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2010-01-04 22:22:55
No problem..

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: 
   void is an invalid type for the variable mouseReleased
   Syntax error on token "(", ; expected
   Syntax error on token ")", ; expected

   at DoodeVert.<init>(DoodeVert.java:89)
   at Jeu.<init>(Jeu.java:23)
   at Menu.actionPerformed(Menu.java:85)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)
17  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2010-01-04 21:05:31
My class is finished!!! But dont work -___-'

It crash :S

code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
import java.awt.Container;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;


public class DoodeVert {


   public int ClickX = 0;
   public int ClickY =0;
   public int CoorX=0;
   public int CoorY=0;
   public byte nombreDeDoodeVert=0;  
   public byte nombreDeDoodeBleu=0;
   public byte nombreDeDoodeRouge=0;
   public byte nombreDeDoodeJaune=0;
   public byte nombreEnnemis=75;
   public int nombreDeDoode=nombreDeDoodeVert+nombreDeDoodeBleu+nombreDeDoodeRouge+nombreDeDoodeJaune;
   public int doowatt=500;
   public int nourriture=500;
   public short geleeNoire=0;
   public short nombreEnnemisTues=0;
   public String pseudo;
   public Container contenu2;
   public JButton igmenu = new JButton("", new ImageIcon("DoodeImages/menu.gif"));;
   public   JLabel fond = new JLabel();
   public JComboBox choix = new JComboBox();
   public JButton doodah = new JButton("", new ImageIcon("DoodeImages/doudah.png"));
   public String Selected="rien";
   public String Selected2="rien";
   public boolean champioqp = false;
   public boolean doodahexist = false;
   public boolean btdoodah1=false;
   
   
   public JButton barre1 = new JButton("", new ImageIcon("DoodeImages/barredoode.png"));   //affichage barre doodes
  public JLabel BarreVert = new JLabel();
   public JLabel BarreBleu = new JLabel();
   public JLabel BarreRouge = new JLabel();
   public JLabel BarreJaune = new JLabel();
   
   
   public JButton BarreNourriture = new JButton("", new ImageIcon("DoodeImages/nour.png"));   //affichage barre nourriture
  public JLabel Bdoowatt = new JLabel();
   public JLabel Bnoire = new JLabel();
   public JLabel BBouffe = new JLabel();
   
   
   
   public JLabel champ1 = new JLabel(new ImageIcon("DoodeImages/champ.png"));   //affichage décor
  public JLabel champ2 = new JLabel(new ImageIcon("DoodeImages/champ.png"));
   public JLabel champ3 = new JLabel (new ImageIcon("DoodeImages/champ2.png"));
   public JButton rive = new JButton("", new ImageIcon("DoodeImages/riviere.gif"));
   public JButton arbre = new JButton ("", new ImageIcon ("DoodeImages/arbre.gif"));
   public JLabel arbre2 = new JLabel (new ImageIcon ("DoodeImages/arbre2.gif"));
   
   
   
   public JButton DoodeVert = new JButton ("",new ImageIcon("DoodeImages/vert.gif"));  //doode vert
  public JButton DoodeVert2 = new JButton ("",new ImageIcon("DoodeImages/vert.gif"));

   
   
   
   
   public JButton CreerDoodah = new JButton ("",new ImageIcon("DoodeImages/btdd.png"));



   Image saut = Toolkit.getDefaultToolkit().createImage("DoodeImages/2 - Copie.png");
   Image normal = Toolkit.getDefaultToolkit().createImage("DoodeImages/vert.gif");



public DoodeVert(){

System.out.print("doode crée");




public void mouseReleased(MouseEvent e) {
   Object source = e.getSource();  

   if(SwingUtilities.isRightMouseButton(e)) {
     
   
      CoorX=e.getX();
       CoorY=e.getY();
       
       
   
     
       if(source == DoodeVert & doodahexist==false){
             
             Selected2="DoodeVert";
         
       }
       
       
       
       
       
       
       
     
       
       
       
     
         
      if (source == fond & Selected == "DoodeVert"){
          DoodeVert.setBounds(CoorX-15,CoorY-25,52,65);
          DoodeVert.setIcon(new ImageIcon(normal));
          Selected2="rien";
          }
         
         
         
          if (source == champ1 & Selected == "DoodeVert"){
             
             DoodeVert.setBounds(1025,308,105,128);
             DoodeVert.setIcon(new ImageIcon(saut));
             Selected2="champ1";
             
          }
         
              if (source == champ2 & Selected == "DoodeVert"){
                   
                   DoodeVert.setBounds(425,555,105,128);
                   DoodeVert.setIcon(new ImageIcon(saut));
                   Selected2="champ2";
               
             
          }
             
             
              if (source == champ3 & Selected == "DoodeVert"){
                   
                   DoodeVert.setBounds(943,270,105,128);
                   DoodeVert.setIcon(new ImageIcon(saut));
                   Selected2="champ3";
                   
               
             
          }
             
              if (source == rive & Selected == "DoodeVert"){
                 DoodeVert.setIcon(new ImageIcon(normal));
                   DoodeVert.setBounds(140,CoorY,52,65);
                   Selected2="rive";
     
             
              }
              if (source == fond & Selected == "DoodeVert2"){
                   DoodeVert2.setBounds(CoorX-15,CoorY-25,52,65);
                   DoodeVert2.setIcon(new ImageIcon(normal));
                   Selected2="rien";
                   }
                   
                   
                   
                   if (source == champ1 & Selected == "DoodeVert2"){
                     
                      DoodeVert2.setBounds(1025,308,105,128);
                      DoodeVert2.setIcon(new ImageIcon(saut));
                      Selected2="champ1";
                     
                   }
                   
                       if (source == champ2 & Selected == "DoodeVert2"){
                           
                            DoodeVert2.setBounds(425,555,105,128);
                            DoodeVert2.setIcon(new ImageIcon(saut));
                            Selected2="champ2";
                       
                     
                   }
                       
                       
                       if (source == champ3 & Selected == "DoodeVert2"){
                           
                            DoodeVert2.setBounds(943,270,105,128);
                            DoodeVert2.setIcon(new ImageIcon(saut));
                            Selected2="champ3";
                       
                     
                   }
                       
                       if (source == rive & Selected == "DoodeVert2"){
                          DoodeVert2.setIcon(new ImageIcon(normal));
                            DoodeVert2.setBounds(140,CoorY,52,65);
                            Selected2="rive";
                           
                           
                            }
               
                     }}}


public void go(){
   BarreVert.setText(""+nombreDeDoodeVert);
   BarreBleu.setText(""+nombreDeDoodeBleu);
   BarreRouge.setText(""+nombreDeDoodeRouge);
   BarreJaune.setText(""+nombreDeDoodeJaune);
   BBouffe.setText(""+nourriture);
   Bdoowatt.setText(""+doowatt);
   Bnoire.setText(""+geleeNoire);

}


                         class affiche implements Runnable{




                           
                            public void run() {      // la runnable qui permet tout !

                               go();  

                            }}}


   
18  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-31 01:39:14
thank.. im so dumb !
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public Jeu (){
     
      JPanel contenu2;


      frame = new JFrame("Doode - Jeu");
      frame.setLayout(null);
     
      contenu2 = new JPanel();
           
      contenu2.addMouseListener(this);
     
       frame.setContentPane(contenu2);

         

Now, all is working fine thanks to you!!

You'r a great man !!! Grin
19  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-31 00:47:13
Don't worry, it was good joke..  Grin

But, I resolved most of problem of change "extends JFrame" by "Jframe frame; ...."

But It stay ONE problem...


setCursor(HAND_CURSOR); dont work now..

frame.setCursor(HAND_CURSOR); ? no.
container.setCursor(HAND_CURSOR); ? no.
grrr..



rectification...

eclipse show me zero red cross, zero errors, but when i launch the game it crash =(

I'll hang myself... All seems good.. Cry

I'll post all my code in few moments if I dont find the problem.. Cry



EDIT: ok, good, i resolved it, but, when I lauch my game, nothing appear, just a frame =))

I know its a container problem... so , this is my container code:

   public Jeu (){
1  
2  
3  
4  
5  
6  
7  
8  
      
      frame = new JFrame("Doode - Jeu");
      frame.setLayout(null);
     
      Container contenu2 = new Container();  
     
      contenu2.addMouseListener(this);
     

20  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-30 23:41:54
Nice !!!


Thanks for all !

Now, my code is more clearer , and more efficient x)

p.s: Who doesn't ? hum.. good answer  Huh everybody is loving you !

21  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-30 22:58:23
I dont understand where to make variable "Jframe frame;"

I dont understand how Jframe can work without extends class with, but i'll search it on google because i think you are bored about me  Undecided


Thanks you anyway, and if you are interested by my project, say me, i'll give you game project jar  Smiley
22  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-30 21:40:13
yes yes, thank you , i know that, but my problem is to extends JFrame and Doode class...

My doode class can be an interface?
23  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-30 20:57:50
Ok, thank you guy !

Hum... anyway, you use actionPerformed with an implementation of Mouselistener ^^
 
(My code is using Mouselistener because i want to differentiate right,middle and left click....)


So, my class "jeu" should extends my superclass "Doode"... but Jeu class already extends JFrame class.... Dumb problem...
but anyway, thanks a lot !!! Grin



Love you all JGO members !   Roll Eyes
24  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-29 21:15:17
Hem, nobody understood my asking...  Undecided

So, I know how to make a Jbutton, I know it, but.... imagine this jbutton:

(this is an example,,its normal if I forgot some lines)



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public class Doode implements Mouselistener{


public Doode(){

Jbutton Doode = new Jbutton("Doode");

container.add("Doode");
Doode.setVisible(true);
Doode.setBounds(500,500,50,50);




   public void mouseEntered(MouseEvent p) {

object source = p.getSource;
if (source == Doode){
system.out.print("test");

   }



So, i want that everytime I call this constructor in main class with : Doode d = new Doode(); 
, it create a Jbutton, with a different name, as Doode,Doode2,Doode3,Doode4...

If you dont understand, I can give you the zip file with the project of my game.   Wink



25  Game Development / Newbie & Debugging Questions / Re: Class organisation - Jbutton constructor on: 2009-12-29 11:05:14
Thank you, but I know that..
 I just want to create a class constructor wich create a Jbutton everytime we call this constructor by a: Doode d = new Doode();   Tongue

I wish all the buttons created by this constructor obey to the same rules ...

I hope you understand me.



26  Game Development / Newbie & Debugging Questions / Class organisation - Jbutton constructor on: 2009-12-28 19:39:46
Hello,

While programming my game "Doode" I realized that the code was confusing, tangled, and I do not know how or where to start

I want to first create a constructor method that creates as many times wanted a JButton, which itself will react to user input ...

Because in fact, right now, my code was creating multiple constiste JButton "DoodeVert1", "DoodeVert2" ... and this is the wrong solution if I want to create 50 (especially the part's name, nothing should change.)

So, here is my project:

A "Jeu" class extending Jframe, implementing Mouselistener :



public class Jeu extends JFrame implements MouseListener{


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public Jeu (String titre) {             
     
                setTitle (titre);
      Container contenu2 = getContentPane();  
      contenu2.addMouseListener(this);
     
      contenu2.setLayout(null);
      Image image = Toolkit.getDefaultToolkit().createImage("DoodeImages/map5.jpg");         //background
     fond.setIcon(new ImageIcon(image));


}




And a "Doode" class wich create Jbutton everytime we call her  = Doode d = new Doode(){   
These Jbuttons have to react about user inputs.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
public class Doode implements Mouselistener{

public Doode(){

Jbutton Doode = new Jbutton("Doode");


public void mouseClicked(MouseEvent o) {   // quand on clique sur le fond

   }






   public void mouseEntered(MouseEvent arg0) {


   }


   public void mouseExited(MouseEvent arg0) {


   }


   public void mousePressed(MouseEvent e) {
     
      if(SwingUtilities.isRightMouseButton(e)) {
         Object source = e.getSource();
         
            }

   }






   public void mouseReleased(MouseEvent e) {
      Object source = e.getSource();  
      if ( SwingUtilities.isLeftMouseButton(e) ) {
         
         
         if (source == "Doode"){
         
system.out.print("Doode!!!");
         
}


This is for example... Is this type of system realizable? Why mine dont work! If you see something wrong, or something like that, please help me..

Im very bad with architectural developpement... please explain me what is the right way to organize classes...  Cry







}
27  Game Development / Newbie & Debugging Questions / eclipse - create jar on: 2009-12-22 14:58:02
hi all !

I made a little game but when i export it into jar, it wont work...

(When I mount it for testing, it work)

So, i choose :

Export: Jar file > I check src and DoodeImages (image folder) boxes , but it dont work when i launch it. Undecided

Plz give me tips.
28  Game Development / Newbie & Debugging Questions / Slick + Eclipse on: 2009-12-13 22:28:15
Hey!

Hello all, i have a little problem, i want to use Slick with eclipse, but this tutorial dont help me, i think i made an error when importing lwjgl.jar and slick.jar..

I made import in JRE system library in my projet folder, and choose = import

General > Archive file and selected lwjlg and slick jars.. but it don't work.. Undecided
29  Game Development / Newbie & Debugging Questions / Re: Few questions to organize my game(How to create RTS?) on: 2009-12-10 22:15:05
So, now, my frame is ok..

I want to create a "void" wich create an object everytime I click on a button...

Is that good ?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
         private void DoodeVert(){
           
            JButton DoodeVert = new JButton("",new ImageIcon("vert.gif"));
            DoodeVert.setBounds(100,100,90,90);
             DoodeVert.setFocusPainted(false);
            DoodeVert.setBorderPainted(false);                  // ces trois lignes enelvent la bordure du boutton
           DoodeVert.setContentAreaFilled(false);
            DoodeVert.addMouseListener(this);
            contenu2.add(DoodeVert);
              DoodeVert.setVisible(true);

           
         
         }

DoodeVert();

         
         


thanks for all you made for me...
30  Game Development / Newbie & Debugging Questions / Re: Few questions to organize my game( JScroll bar with backgound) on: 2009-12-08 19:00:39
Thanks !!! Ill try to understand it before test it.....   persecutioncomplex

thanks a lot


hoho, im losin.. Code dont work, I dont see any new thing and I understand 3/4 of text..

 Undecided
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (22 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (54 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!