Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (289)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  player becomes slow  (Read 208 times)
0 Members and 1 Guest are viewing this topic.
Offline 002-Sy

Senior Newbie





« Posted 2012-11-27 01:06:31 »

good day, guys.
Sorry for my bad english, i am beginner yet.  Undecided
i have one doubt.

I decided create a shooter game like "Mushihime-Sama", not really identic that this but similar, the problem is in the test of paint elements in canvas, paint bullets in a continuous manner causes the player to move slow.

I use bufferstrategy for the level and bufferimage for the elements how the player, background, bullets and enemies. This problem only pass in ubuntu. In windows, the processor work much.

When i painted much elements in canvas, the player will move most slow?

what is the right way to paint In This Case?

PD. sorry if this doubt is already repeated.

CODE:
paint bullets:
1  
2  
3  
4  
5  
6  
7  
public void paintBullets(Graphics2D g){
        if(bullets.size()>0){
        for(int q=0; q<bullets.size(); q++){
            bullets.get(q).paint(g);
        }
        }
    }


1  
2  
3  
4  
5  
public void paint(Graphics2D g){
            if(life>0){
            g.drawImage(img.get(num)[currentFrame], x,y, null);
            }
        }


load img
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public void setSpriteNames(String[] names) { 
      spriteNames = names;
      height = 0;
      width = 0;
                colecImg= new BufferedImage[names.length];
      for (int i = 0; i < names.length; i++ ) {
        BufferedImage image = cargador.getSprite(spriteNames[i]);
        height = Math.max(height,image.getHeight());
      width = Math.max(width,image.getWidth());  
                colecImg[i]=image;
      }
                img.add(colecImg);
   }


CARGADOR
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
protected Object loadResource(URL url) {
      try {
         return ImageIO.read(url);
      } catch (Exception e) {
         System.out.println(" "+url);
         System.out.println("Error"+e.getClass().getName()+" "+e.getMessage());
         System.exit(0);
         return null;
      }
   }
   
   public BufferedImage createCompatible(int width, int height, int transparency) {
      GraphicsConfiguration gc =  GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
      BufferedImage compatible = gc.createCompatibleImage(width,height,transparency);
      return compatible;
   }
   
   public BufferedImage getSprite(String name) {
      BufferedImage loaded = (BufferedImage)getResource(name);
      BufferedImage compatible = createCompatible(loaded.getWidth(),loaded.getHeight(),Transparency.BITMASK);
      Graphics g = compatible.getGraphics();
      g.drawImage(loaded,0,0,this);
      return compatible;
   }
Pages: [1]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (60 views)
2013-05-17 21:29:12

alaslipknot (69 views)
2013-05-16 21:24:48

gouessej (99 views)
2013-05-16 00:53:38

gouessej (96 views)
2013-05-16 00:17:58

theagentd (107 views)
2013-05-15 15:01:13

theagentd (98 views)
2013-05-15 15:00:54

StreetDoggy (144 views)
2013-05-14 15:56:26

kutucuk (166 views)
2013-05-12 17:10:36

kutucuk (165 views)
2013-05-12 15:36:09

UnluckyDevil (175 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.151 seconds with 20 queries.