Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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]
1  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-30 03:09:10
you can see my flickering problem here...
http://rct3nerds.eblah.com/soc/game/SecretsofCelebrindal.htm
2  Game Development / Newbie & Debugging Questions / Re: Input Box and output box - applet on: 2005-03-28 05:07:46
Sorry for the not replying sooner.

I've tried making a custom component, through lsitening for Character keys instead of the other keys. And it worked. Except I don't know how to code the backspace, to erase the last character.  I tried to sue JTextFiedl but, what the problem is, is what you explained. the text field is taking al lthe key input. I looekd up the class/api, but couldn't find anything on making it unfocused. Also, JTextfield is drawn under my GUI, which is drawn in update(). So when every I type, the gui flikers, and I can't see what I'm writing.

Is there any other way to accomplish this? www.miragesource.com ... I'm trying to immatate this.  Its written in VB6, thats how they do it, they have controels with all sorts of fancy stuff, but I don't have enoguh money fro vb6, and I'd rather have cross platform and more powerfull thing. If you can help me easier in lvie chat, my AIM is tr00p3er, and my MSN is ryancapote@hotmail.com

3  Game Development / Newbie & Debugging Questions / Re: Input Box and output box - applet on: 2005-03-26 15:34:43
Sorry if my question is un-understanable...

I ment, how do I do a box, and still have my gui images behind it. ALSO implement things like backspace, unless you can use JTextField. The only problem with using jtext field is that the controels get messed up, so maby I need to look into the JTextField class more. But, if I do use JTextField, how do I get it to be transparent, so my GUI image can show behind it?
4  Game Development / Newbie & Debugging Questions / Movement animation on: 2005-03-26 04:26:28
Sorry about all these questions but I have one more.

I have this sprite sheet were the first three imaegs are the animaton for the guy walking up, then thenext 3 are of him walking down etc. I have figured out how to do this animation, but for some reason, my code doesn't want my guy to "walk"

In my KeyPeessed It moves the character and trigers it to change frames by setting the varaible walking to true...

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  
            //Check arrows for character movement
     if(e.getKeyCode() == keyUp){
            player_y = player_y - 3;
            walk = true;
            walking = true;
            dir = 1;
            repaint();
      } else if (e.getKeyCode() == keyDown){
            player_y = player_y + 3;
            walk = true;
            walking = true;
            dir = 2;
            repaint();
      } else if (e.getKeyCode() == keyLeft){
            player_x = player_x - 3;
            dir = 3;
            walk = true;
            walking = true;
            repaint();
      } else if (e.getKeyCode() == keyRight){
            player_x = player_x + 3;
            dir = 4;
            walk = true;
            walking = true;
            repaint();
      }


Then in the KeyRelease method, I make he animation stop by turning off walking.....

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public void keyReleased(KeyEvent e){ 

      if(e.getKeyCode() == keyUp){

            walking = false;

      } else if (e.getKeyCode() == keyDown){

            walking = false;

      } else if (e.getKeyCode() == keyLeft){


            walking = false;

      } else if (e.getKeyCode() == keyRight){

            walking = false;

      }


      }


Then what does the animation is in my very own drawAvatar method..... READ THE NOTES IN THE CODE

[code]
     public void drawAvatar(Image avatar,int x,int y,int sprite,int frame,Graphics g){
           int sprite2;
           int up = 0;
           int down = 96;
           int left = 192;
           int right = 288;
     
           sprite2 = sprite * 32;
           //The following IF statements is suppos to trigger the animation....
           if(walk==true){
                 up = 0;
                 down = 96;
                 left = 192;
                 right = 288;

                         //if walking == true, then keep doing the animations, else stop. If you take away the if statement and keep walk = false, the animation will play indefinatly, that is my problem. The animation won't play because of if walking = true

           if(walking == true){
                       walk = false;
                 } else {
                       walk = true;
                 }
                       
           }else if(walk==false){
                 up = 32;
                 down = 128;
                 left = 224;
                 right = 320;
                 walk = true;
           }
           
     
           
           switch(frame){
           
                 case 1:
                       //Up
     
                       g.drawImage(avatar,x,y,x+32,y+32,up,sprite2,up + 32,sprite2+32,this);
                       repaint();
                 break;
                 
                 case 2:
                       //Down
                       g.drawImage(avatar,x,y,x+32,y+32,down,sprite2,down + 32,sprite2+32,this);
                       repaint();
                 break;
                 
                 case 3:
                       //Left
                       g.drawImage(avatar,x,y,x+32,y+32,left,sprite2,left + 32,sprite2+32,this);
                       repaint();
                 break;
                 
                 case 4:
                       //Right                            x    y       x           y
                       g.drawImage(avatar,x,y,x+32,y+32,right,sprite2,right + 32,sprite2+32,this);
                       repaint();
                 break;
           }
     }


[code[
5  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-26 03:50:40
the only thin that is flickering is the drawStrings that make up my GUI. thats the only thing that is flickering. The gui doesn't work in the paint method, but it works in the updated method. I'll keep playing with it, and I'll post if I get it.
6  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-25 22:23:03
PArden my noobness but, what does that mean? lol
7  Game Development / Newbie & Debugging Questions / Input Box and output box - applet on: 2005-03-25 20:50:09
If you have played Runescape, you know at the bottom how yuo can enter text in and It would send it to everyone in the game. And it shows the text that other people say below it. How do I accomplish this in my applet? I have tryed keyTyped, but you can erase using backspace ect. And I've Tried using JTextField, but then I can't controle my character. Any Ideas?
8  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-25 19:18:33
Okay, what I did was put the part were it creates the buffer in the paint method, now I don't have the exception anymore.But the gui still doesn't want to work through paint() wich makes it flicker a lot. But drawing the map and the character in the paint() method, flixed that flickering.
9  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-25 18:56:36
ok, heres my 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  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
323  
324  
325  
326  
327  
328  
329  
330  
331  
332  
333  
334  
335  
336  
337  
338  
339  
340  
341  
342  
343  
344  
345  
346  
347  
348  
349  
350  
351  
352  
353  
354  
355  
356  
357  
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;


public class SecretsofCelebrindal extends JApplet implements KeyListener,MouseListener,Runnable {
      //-----------------------------------------
     //Variables
     //-----------------------------------------
     
      int app_width,app_height,tiles_y,tiles_x,map_x,map_y,y,x,i,tiles,player_x,player_y, menu_item,dir,sprite;
      public boolean map_created,walk,walking;
      Graphics bgraphics;
      player player;
      gui gui;
      Image grass,sprites,gui1,gui2,buffer,map;
      String name,command;
      char key;
      public Thread th;
      static int keyUp = 38;
      static int keyDown = 40;
      static int keyLeft = 37;
      static int keyRight = 39;
     
     
      //-----------------------------------------
     //Misc. Functions
     //-----------------------------------------
     
      //-----------------------------------------
     //For the map, draw a row - TEMPORARY
     public void makeRow(int mx,int my,Graphics g){
                       
                        for(mx = 0; mx< 640; mx = mx + 32){
                                               
                              g.drawImage(grass,mx,my,this);
                              tiles++;
                             
                              if(mx == 800){
                              map_created = true;
                                          break;
                                    }
                                   
                              }
                             
                       
                  }
           
      //-----------------------------------------
     //Checks if a menu item has been clickd
     
      public boolean socButton(int y,MouseEvent m){
            boolean clicked;
            if(m.getX() > 650 && m.getX() < 700 && m.getY() > y && m.getY() < y+15){
                  clicked = true;
            } else {
                  clicked = false;
            }
            return clicked;
      }
     
      //-----------------------------------------
     //For futer browser functionality
     public String getAppletInfo() {
            //You can replace this with your own message, but leave SOC Source Written by Ryan Capote
         return "Secrets of Celebrindal V1.0 Written by Ryan Capote. SOC Source V 1.0 Written by Ryan Capote.";
      }
     
      //-----------------------------------------
     //A small function to load the images. Help keeps the code clean
           public void loadImages(){
            //load the images
           grass = getImage(getCodeBase(),"gfx/grass.GIF");
            sprites = getImage(getCodeBase(),"gfx/Sprites.GIF");
            gui1 = getImage(getCodeBase(),"gfx/gui1.gif");
            gui2 = getImage(getCodeBase(),"gfx/gui2.gif");
      }

     
      //-----------------------------------------
     //Initialization
     //-----------------------------------------
     public void init() {
            //do variable stuff
           app_width  = 640;
            app_height = 480;
            tiles_x = 0;
            tiles_y = 0;
            map_x = 32;
            map_y = 32;
            player_y = 64;
            player_x = 64;
            addKeyListener(this);
            addMouseListener(this);
            walk = true;
            walking = false;
            sprite = 198;
           
      }
      //-----------------------------------------
     //When the game starts
     //-----------------------------------------
     public void start() {
           
            //create player
           player = new player();
           
            //create GUI
           gui = new gui();
           
            //Load images
           loadImages();
           
            th = new Thread(this);
            th.start();
           
      }
     
      //------------------------------------------
     //Controles
     //------------------------------------------
     public void keyPressed(KeyEvent e){
            walking = true;
            //Check arrows for character movement - TO BE UPDATED - NEEDS ANIMATION
     if(e.getKeyCode() == keyUp){
            player_y = player_y - 3;
            walk = true;
            dir = 1;
            repaint();
      } else if (e.getKeyCode() == keyDown){
            player_y = player_y + 3;
            walk = true;
            dir = 2;
            repaint();
      } else if (e.getKeyCode() == keyLeft){
            player_x = player_x - 3;
            dir = 3;
            walk = true;
            repaint();
      } else if (e.getKeyCode() == keyRight){
            player_x = player_x + 3;
            dir = 4;
            walk = true;
            repaint();
      }
     
           
      }
     
      public void keyReleased(KeyEvent e){
      if(e.getKeyCode() == keyUp){
            walk = false;

      } else if (e.getKeyCode() == keyDown){
            walk = false;
      } else if (e.getKeyCode() == keyLeft){
            walk = false;
      } else if (e.getKeyCode() == keyRight){
            walk = false;
      }
      }
     
      public void keyTyped(KeyEvent e){
      //      key = e.getKeyChar();
     //      command = command + key;
     }
     
      public void mouseClicked(MouseEvent m){
            //Inventory
           
             if(socButton(455,m) == true){
                   menu_item = 1;
             }
             
             //Equipment
            if(socButton(470,m) == true){
                   menu_item = 2;
             }
             
             //Magic
            if(socButton(485,m) == true){
                   menu_item = 3;
             }
             
             //Stats
            if(socButton(500,m) == true){
                   menu_item = 4;
             }
             
             //Options
            if(socButton(515,m) == true){
                   menu_item = 5;
             }
             
             
      }
     
      public void mousePressed(MouseEvent m){ }
     
      public void mouseReleased(MouseEvent m){ }
     
      public void mouseEntered(MouseEvent m){      }
     
      public void mouseExited(MouseEvent m) { }
     
      //-----------------------------------------
     //game loop
     //-----------------------------------------
     public void run(){
             Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
             
            while(true){
                        repaint();
                 
                 
                  //-----------------------------------------
                  //Checks to see if the user exits the room - BLOCK OF CODE = TEMPORARY
                  //WILL BE USED TO TELEPORT FROM ONE MAP TO ANOTHER
                  //-----------------------------------------
                 if(player_y + 32 > 480){
                        player_y = 0;
                        repaint();
                  }
                 
                  if(player_y < 0) {
                        player_y = 448;
                        repaint();
                  }
                 
                  if(player_x < 0){
                        player_x = 640 - 32;
                        repaint();
                  }
                 
                  if(player_x + 32 > 640){
                        player_x = 0;
                        repaint();
                  }
                  //-----------------------------------------
                 
                                   
                  try{

                  th.sleep(20);

                 
                  } catch(InterruptedException ex){
                       
                  }
           
               
            }
             
      }
     
     
      //-----------------------------------------
     //Buffer, to stop flickering
     //------------------------------------------
     public void update(Graphics g){
     
           
            //create buffer
           if(buffer == null){
                  buffer = createImage(app_width,app_height);
                  bgraphics = buffer.getGraphics();
            }

           
           

           
           
            bgraphics.setColor(getBackground());
            bgraphics.fillRect(0,0,640,480);
           
           
     
            //draw gui
           gui.drawGUI(g,gui1,gui2);
            gui.drawStats(g,25,20,1025,5);
            gui.drawMenu(g);
           
            //Draws the appropiate menu that the user clicked
           switch(menu_item){
                  case 0:
                  //do nothing
                 break;
                                   
                  case 1:
                  gui.drawInventory(g);
                  repaint();
                  break;
                 
                  case 2:
                  gui.drawEquipment(g);
                  break;
                 
                  case 3:
                  gui.drawMagic(g);
                  break;
                 
                  case 4:
                  gui.drawMStats(g);
                  break;
                 
                  case 5:
                  gui.drawOptions(g);
                  break;
            }
           
            paint(bgraphics);

                 
            g.drawImage(buffer,0,0,this);
     
      }
     
      //Draw the Screen
     public void paint(Graphics g){
           

           

           
            //re-draw map + character
                  for(y = 0; y < 480; y = y + 32){
                         bgraphics.drawString("Cirdan",player_x-5,player_y - 15);
                        makeRow(0,y,g);
                        player.drawAvatar(sprites,player_x,player_y,sprite,dir,g);

                  }
           




           
      }
     
           
      //------------------------------------------
     //ending
     //------------------------------------------
     public void stop(){
           
      }
     
      public void destroy() {
           
      }
}
10  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-25 17:53:56
line 311 and 312 =

which is in update()

1  
2  
bgraphics.setColor(getBackground());
bgraphics.fillRect(0,0,640,480);


Then on line 248:
which is in my game loop

1  
2  
3  
247      try{
248
249      th.sleep(20);


my current update()
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  
public void update(Graphics g){
     
           
            //create buffer
           if(buffer == null){
                  buffer = createImage(app_width,app_height);
                  bgraphics = buffer.getGraphics();
            }

           
           

            //draw gui
           gui.drawGUI(g,gui1,gui2);
            gui.drawStats(g,25,20,1025,5);
            gui.drawMenu(g);
           
            //Draws the appropiate menu that the user clicked
           switch(menu_item){
                  case 0:
                  //do nothing
                 break;
                                   
                  case 1:
                  gui.drawInventory(g);
                  repaint();
                  break;
                 
                  case 2:
                  gui.drawEquipment(g);
                  break;
                 
                  case 3:
                  gui.drawMagic(g);
                  break;
                 
                  case 4:
                  gui.drawMStats(g);
                  break;
                 
                  case 5:
                  gui.drawOptions(g);
                  break;
            }
           
           
            bgraphics.setColor(getBackground());
            bgraphics.fillRect(0,0,640,480);
           
           

           
            paint(bgraphics);

                 
            g.drawImage(buffer,0,0,this);
     


my current game loop....

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  
            while(true){
                        repaint();
                 
                 
                  //-----------------------------------------
                  //Checks to see if the user exits the room - BLOCK OF CODE = TEMPORARY
                  //WILL BE USED TO TELEPORT FROM ONE MAP TO ANOTHER
                  //-----------------------------------------
                 if(player_y + 32 > 480){
                        player_y = 0;
                        repaint();
                  }
                 
                  if(player_y < 0) {
                        player_y = 448;
                        repaint();
                  }
                 
                  if(player_x < 0){
                        player_x = 640 - 32;
                        repaint();
                  }
                 
                  if(player_x + 32 > 640){
                        player_x = 0;
                        repaint();
                  }
                  //-----------------------------------------
                 
                                   
                  try{

                  th.sleep(20);

                 
                  } catch(InterruptedException ex){
                       
                  }
           
               
           

11  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-25 17:12:49

Here they are...

http://www.christiangaming.org/graphics/users/Trooper/exception.jpg
http://www.christiangaming.org/graphics/users/Trooper/exception2.jpg
12  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-25 15:42:30
Okay, I changed my code. Every thing is drawin in the paint() and the buffer clears the screen throguh the update() But, my gui code won't draw throguh the paint() I get this exception. But if I draw my gui in the update() method, it works, but the text flickers. Any idea?

my draw gui 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  
public void drawGUI(Graphics g,Image gui1,Image gui2){
            g.drawImage(gui1,640,0,this);
            g.drawImage(gui2,0,480,this);

            //Draw Stats
           
      }
     
      public void drawStats(Graphics g,int hp,int mp,int xp,int level){
            //Set font Color
           g.setColor(Color.white);
           
           
            //Draw the infomation
           g.drawString("HP: " + hp,650,100);
            g.drawString("MP: " + mp,650,115);
            g.drawString("Experience: " + xp,650,130);
            g.drawString("Level: " + level,650,145);
      }
     
      public void drawInventory(Graphics g){
            // y =187
           g.drawString("Inventory",685,200);            
           
      }
     
      public void drawMagic(Graphics g){
            // y = 187
           g.drawString("Magic",700,200);
      }
     
      public void drawOptions(Graphics g){
      g.drawString("Options",695,200);      
      }
     
      public void drawEquipment(Graphics g){
            g.drawString("Equipment",685,200);
      }
     
      public void drawMStats(Graphics g){
            g.drawString("Stats",700,200);
      }
     
      public void drawMenu(Graphics g){
            //y = 437
           
            g.drawString("Menu",700,450);
            g.drawString("Inventory",650,465);
            g.drawString("Equipment",650,480);
            g.drawString("Magic",650,495);
            g.drawString("Stats",650,510);
            g.drawString("Options",650,525);
      }
13  Discussions / General Discussions / Re: Christian Gaming on: 2005-03-25 03:14:18
http://www.christiangaming.org - Christian Gaming Clan
14  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-25 03:10:32
Sorry for the long time no reply. I got the code working perfectly, now I wish to fix the flickering issue...

Heres my Update()

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  
public void update(Graphics g){
            player.drawAvatar(sprites,player_x,player_y,sprite,dir,g);
           
            //create buffer
           if(buffer == null){
                  buffer = createImage(app_width,app_height);
                  bgraphics = buffer.getGraphics();
            }
            repaint();
           
            bgraphics.setColor(getBackground());
            bgraphics.fillRect(0,0,app_width,app_height);
            repaint();
           
            //Draw Gui
           gui.drawGUI(g,gui1,gui2);
            gui.drawStats(g,25,20,1025,5);
            gui.drawMenu(g);
            bgraphics.setColor(getForeground());
            repaint();
            player.drawAvatar(sprites,player_x,player_y,sprite,dir,g);
            //Draws the appropiate menu that the user clicked
           switch(menu_item){
                  case 0:
                  //do nothing
                 break;
                                   
                  case 1:
                  gui.drawInventory(g);
                  repaint();
                  break;
                 
                  case 2:
                  gui.drawEquipment(g);
                  break;
                 
                  case 3:
                  gui.drawMagic(g);
                  break;
                 
                  case 4:
                  gui.drawMStats(g);
                  break;
                 
                  case 5:
                  gui.drawOptions(g);
                  break;
            }
           
           
            //re-draw map + character
                  for(y = 0; y < 480; y = y + 32){
                         g.drawString("Cirdan",player_x-5,player_y - 15);
                        makeRow(0,y,g);
                        player.drawAvatar(sprites,player_x,player_y,sprite,dir,g);
                        repaint();
                  }
           
           
      }
     
      public void paint(Graphics g){
           
            repaint();
      }


and heres my game loop...

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  
while(true){
                        repaint();
                 
                  if(walk == true){
                        walk = false;
                  } else if(walk = false) {
                        walk = true;
                  }
                 
                 
                  //-----------------------------------------
                  //Checks to see if the user exits the room - BLOCK OF CODE = TEMPORARY
                  //WILL BE USED TO TELEPORT FROM ONE MAP TO ANOTHER
                  //-----------------------------------------
                 if(player_y + 32 > 480){
                        player_y = 0;
                        repaint();
                  }
                 
                  if(player_y < 0) {
                        player_y = 448;
                        repaint();
                  }
                 
                  if(player_x < 0){
                        player_x = 640 - 32;
                        repaint();
                  }
                 
                  if(player_x + 32 > 640){
                        player_x = 0;
                        repaint();
                  }
                  //-----------------------------------------
                 
                                   
                  try{

                  th.sleep(20);

                 
                  } catch(InterruptedException ex){
                       
                  }
           
15  Java Game APIs & Engines / Java 2D / Re: Sprite Sheet on: 2005-03-21 17:42:38
Quote
Use this drawImage method.

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Graphics.html#drawImage(java.awt.Image,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20java.awt.image.ImageObserver)

It allows you to specify a subpart of an image to be drawn on a specified place on another image.

On a side note, it's common to load and chop up the tilesets in small images when the game, level or something similar is initialized and then just paint the choped pics.


Okay thankyou! Now, I made a function to make the ground, which draws a bunch of 32x32 grass tiles over the ground. then after that, it draws the character sprite. now I've coded it so every game loop, it moves right.(x++;) Now, that character sprite flickers, but the ground doesn't. Every loop it draws a 1000 tiles over a 800x600 area. then after it does that, it draws the character sprite, and then refreshes the screen for buffer. but the character sprite flickers but not the ground tiles. could it be because of drawing all the tiles slows it down?

Also, is there a way to draw an image iunto a createImage() variable?
Also can you explain that drawImage code you posted. And is it true I can only have a heightxwidth of 256
16  Java Game APIs & Engines / JOGL Development / Newbie looking JOGL infomation on JOGL on: 2005-03-21 17:33:22
I tried using the standard graphics that java came with it it was too slow. So I've decided to use opengl....

1) Can someone point me to a jogl tutorial that teaches 2D


thankyou!
17  Game Development / Newbie & Debugging Questions / what does this error mean? on: 2005-03-21 03:44:36
I tried to run my applet, but it fails to load it, and I get this error in the java consol...


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
java.lang.NoClassDefFoundError: SecretsOfCelebrindal (wrong name: SecretsofCelebrindal)
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at sun.applet.AppletClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.applet.AppletClassLoader.loadClass(Unknown Source)


      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.applet.AppletClassLoader.loadCode(Unknown Source)
      at sun.applet.AppletPanel.createApplet(Unknown Source)
      at sun.plugin.AppletViewer.createApplet(Unknown Source)
      at sun.applet.AppletPanel.runLoader(Unknown Source)
      at sun.applet.AppletPanel.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)


here is my game 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  
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;

public class SecretsofCelebrindal extends JApplet implements KeyListener,Runnable {
      //-----------------------------------------
     //Variables
     //-----------------------------------------
     
      int app_width,app_height,tiles_x,tiles_y,map_x,map_y;
      Image buffer,map;
      Graphics bgraphics;
      public Thread th;
     
     
     
      //-----------------------------------------
     
     
     
      //-----------------------------------------
     //initialization
     //-----------------------------------------
     public void init() {
            //do variable stuff
           app_width  = this.getSize().width;
            app_height = this.getSize().height;
            tiles_x = 25;
            tiles_y = 24;
            map_x = 0;
            map_y = 0;
           
           
      }
     
      public void start() {
             th = new Thread(this);
            th.start();
           
           
           
            if(map == null){
                  map = createImage(app_width,app_height);
            }
           
           
           
      }
     
      //------------------------------------------
     //Controles
     //------------------------------------------
     public void keyPressed(KeyEvent e){
            //Check the controles for gameplay related.
     }
     
      public void keyReleased(KeyEvent e){
            //check when the user stops running, or walking.
           
      }
     
      public void keyTyped(KeyEvent e){
            //For chat and other input with text.
           
      }
     
      //-----------------------------------------
     //game loop
     //-----------------------------------------
     public void run(){
             Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
            while(true){
                  repaint();
                 
                  try{
                 
                  th.sleep(20);
                  } catch(InterruptedException ex){
                       
                  }
                 
            }
             //Thread.currentThread().setPriority(Thread.MAX_PRIORITY);;
     }
     
     
      //-----------------------------------------
     //drawing the screen
     //------------------------------------------
     public void update(Graphics g){
            //create buffer
           if(buffer == null){
                  buffer = createImage(app_width,app_height);
                  bgraphics = buffer.getGraphics();
            }
           
      }
     
      public void paint(Graphics g){
            g.drawString("This is SecretsofCelebrindal Applet!",100,100);
      }
     
           
      //------------------------------------------
     //ending
     //------------------------------------------
     public void stop(){
           
      }
     
      public void destroy() {
           
      }
}
18  Java Game APIs & Engines / Java 2D / Sprite Sheet on: 2005-03-21 03:02:18
Hello, I have a sprite sheet, were every 32x32 height wise is a different sprite. Wdith wise is each frame of animation. How do I only get a 32x32 block from the big sprite sheet?
19  Game Development / Newbie & Debugging Questions / Setting Up Controles on: 2005-03-19 19:59:25
Hello, I've been looking all over hte palce to figure out how to use KeyEvent and KeyListener to controle my character. The only problem I have is figuring out if the player used the arrowkeys.
20  Game Development / Newbie & Debugging Questions / Re: Java2D or Seperate Library on: 2004-09-09 22:48:06
okay, Thanks for the replys!!!
21  Game Development / Newbie & Debugging Questions / Java2D or Seperate Library on: 2004-09-09 16:36:41
I"m looking into starting Java Game Development. Should I use Java2D, Or a seperate graphics libarary?
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

TehJavaDev (15 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (34 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (20 views)
2014-08-16 06:20:21

Tekkerue (30 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (43 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!