Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  Game Development / Artificial Intelligence / Re: java area (outline) to polygon / array (x, y) on: 2009-12-05 08:31:14
working  Cool
ty Cheesy
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
       mask_tmp = new Polygon();
       
       PathIterator path = a.getPathIterator(null);
        while (!path.isDone()) {
            toPolygon(path);
            path.next();}

       return mask_tmp;}
   
     private static void toPolygon(PathIterator p_path) {
          double[] point = new double[2];
          if(p_path.currentSegment(point) != PathIterator.SEG_CLOSE)
             mask_tmp.addPoint((int) point[0], (int) point[1]);}
2  Game Development / Artificial Intelligence / Re: java area (outline) to polygon / array (x, y) on: 2009-12-05 08:04:02
yepp, thank u v much. it's a simple algorithm. after defining your bg-colour (white or transparent) an observer is following the bounding-rect ( top_left to bottom_left, ...), checks for the 1st pix != bg-col (row/column) and stores the pos in an area. i repeat that cycle 4 times, varying the starting corner. after that i get the intersection of all areas Smiley. (i also used a contrast filter) works fine for simple surfaces + it is quite fast because it is linear
linked to my sprite-class i get a dynamic collision model (each frame gets it's mask).
3  Game Development / Artificial Intelligence / java area (outline) to polygon / array (x, y) on: 2009-12-04 21:55:25
i wrote a program which traces an image's outline. therefore i used java area to use methods such as subtract, add, ... well, it wasn't that difficult to write an collision detection script but the matter is that i don't have any idea how to get an outline polygon (area to outlinepoly) -> x1,y1; x2,y2 ....
is there any help? or shld i write my own subtract method / area script?Huh
 Shocked
ty
 Smiley
4  Java Game APIs & Engines / Java 2D / Re: swing + doublebuffer on: 2008-06-04 12:01:39
it is working fine now

thank you!!!

sQ
5  Java Game APIs & Engines / Java 2D / swing + doublebuffer on: 2008-06-04 07:43:57
hey, i am quite new to java.
prob is: java doesn't display swing button1
perhaps u know any gd solution

thanks sQ


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  
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.VolatileImage;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

public class Window
{
    private boolean run = true;
       
    public Window()
    {    
        JFrame f = new JFrame("LevelCreator");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(800, 600);
        f.setVisible(true);
        f.setResizable(false);
       
        final Icon icon2 = new ImageIcon(  
                Window.class.getResource( "/pattern/block.png" ) );
               
              final JButton button1 = new JButton( icon2 );
              button1.setLocation(200,200);
              button1.setDoubleBuffered(true);
              button1.setVisible(true);
              f.add( button1 );
       
        Main main = new Main(f);
       
        Map<RenderingHints.Key, Object> config = new HashMap<RenderingHints.Key, Object>();
        config.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        config.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
        config.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
        config.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
        config.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
        config.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
        config.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        config.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        config.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
           
        f.addKeyListener(new KeyListener()
                {

            public void keyPressed(KeyEvent e)
            {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                {
                   run = false;
                    System.exit(0);
              }
            }

            public void keyReleased(KeyEvent arg0) {}

         public void keyTyped(KeyEvent arg0) {}
             
                });
           
        int fps_counter = 0;
        long t_start = System.currentTimeMillis();
        long t_current = 0, fps = 0;
       
       Graphics2D buffered = (Graphics2D) f.getGraphics();
       buffered.setRenderingHints(config);
       
       VolatileImage img = f.createVolatileImage(Statics.width, Statics.height);
       Graphics2D g = (Graphics2D) img.createGraphics();
       g.setRenderingHints(config);
   
       while(run)
       {
          g.setColor(Color.BLACK);
           g.fillRect(0, 0, Statics.width, Statics.height);

          if(t_current > t_start + 1000)
          {
             t_start = System.currentTimeMillis();
             fps = fps_counter;
             fps_counter = 0;
          }
           
          ++ fps_counter;
         
          main.paint(g);
         g.setColor(Color.red);
         g.drawString("fps: " + fps, 100, 200);
         
          buffered.drawImage(img, 0, 10, f);
          t_current = System.currentTimeMillis();
       }
    }
       
    public static void main(String[] args)
    {
       try
       {
          new Window();
       }
      catch(Exception e ) {System.exit(0);}
    }
}
6  Game Development / Game Play & Game Design / Re: game menu on: 2008-04-22 21:11:30
i suppose it is caused by using voliateImage...? but i am not that sure because i am a so called newbie

- edit: maybe ur pc doesnt support 800x600 pix @brackeen - i set the config to 800x600pix
i gonna fix that bug aswell Wink thanks

btw: does anybody know how to get a list of supported video modes?
7  Game Development / Game Play & Game Design / Re: game menu on: 2008-04-22 20:04:59
have no webspace for that. do u know any gd free webspace sites?

sQ
8  Game Development / Game Play & Game Design / Re: game menu on: 2008-04-22 18:23:10
[urlhttp://rapidshare.com/files/109747209/asteroid.jar.html[/url]

i disabled the fps mode. data/config.ini -> fps=true

any suggestions?

greets sQ
9  Game Development / Game Play & Game Design / game menu on: 2008-04-21 15:37:46
hi, i am currently developing a java 2D game.
just started designing an interface.

what are your benchmarks (in fps)?

http://rapidshare.com/files/109263653/asteroid.jar.html
10  Java Game APIs & Engines / Java 2D / Re: java volatile img on: 2008-04-17 14:33:38
i found this:

VolatileImage: This image type was created in JDK 1.4 as a means of creating and managing accelerated image memory. One of the problems with hardware acceleration for images is that, on some platforms, accelerated memory can be deleted out from under you at any time. This is obviously not what you want for your typical image data. To work around that, the  VolatileImage API was created to provide a notification mechanism so that you know when an image must be re-rendered due to data loss.  VolatileImage objects are not loaded from image data, but are just created as empty pixel buffers (much as the initial BufferedImage objects were (see above)); to load image data into a VolatileImage, applications must load the image data through some non-Volatile means, get the Graphics object for the VolatileImage, and then copy the data into the Graphics

 Cool

 
11  Java Game APIs & Engines / Java 2D / java volatile img on: 2008-04-16 22:18:28
hey guys. just getting started with java.
i have got a question: i coded a source-loader class and a sprite class using simple images (Image x).
would i achieve to increase fps by using volatile images instead of simple images even if the back-buffer is of type volatile?

my current game speed (100 sprites) @ 1280x1024 pix: 1003 fps

thank you

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  
import java.awt.Color;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.ImageObserver;
import java.awt.image.VolatileImage;
import java.util.HashMap;
import java.util.Map;

public class FullScreen
{
    final GraphicsEnvironment gE = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice gDevice = gE.getScreenDevices()[0];
    final GraphicsConfiguration gc = gDevice.getDefaultConfiguration();
    final Dimension  screen = Toolkit.getDefaultToolkit().getScreenSize();
       
    private Frame display = new Frame(gc);
    private Map<RenderingHints.Key, Object> config = new HashMap<RenderingHints.Key, Object>();
    private Main main;
       
    public FullScreen()
    {    
        display = new Frame(gc);
        display.setUndecorated(true);
        display.setIgnoreRepaint(true);
        display.setResizable(false);
        display.enableInputMethods(false);
        gDevice.setFullScreenWindow(display);
       
        main = new Main(display);
           
        config.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        config.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
        config.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
        config.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
        config.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
        config.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
        config.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
        config.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
        config.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
           
        display.addKeyListener(new KeyListener()
                {

            public void keyPressed(KeyEvent e)
            {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                {
                    display.setVisible(false);
                    display.dispose();
                    System.exit(0);
                 }
            }

            public void keyReleased(KeyEvent arg0) {}

         public void keyTyped(KeyEvent arg0) {}
             
                });
           
        int fps_counter = 0;
        long t_start = System.currentTimeMillis();
        long t_current = 0, fps = 0;
           
        DisplayMode dm = new DisplayMode(screen.width, screen.height, 32, DisplayMode.REFRESH_RATE_UNKNOWN);
        gDevice.setDisplayMode(dm);
        Graphics2D buffered = (Graphics2D) display.getGraphics();
        buffered.setRenderingHints(config);
           
        ImageObserver io = display;
        VolatileImage img = display.createVolatileImage(screen.width, screen.height);
        Graphics2D g = (Graphics2D) img.createGraphics();
        g.setRenderingHints(config);
           
        while(true)
        {
            g.clearRect(0, 0, screen.width, screen.height);

            if(t_current > t_start + 1000)
            {
                t_start = System.currentTimeMillis();
                fps = fps_counter;
                fps_counter = 0;
            }
               
            ++ fps_counter;
           
            main.paint(g);
           
            g.setColor(Color.RED);
            g.drawString("fps: " + fps, 10, 20);
               
            buffered.drawImage(img, 0, 0, io);
            t_current = System.currentTimeMillis();
        }
    }
       
    public static void main(String[] args)
    {
        new FullScreen();
    }
}
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.

Dwinin (29 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (78 views)
2014-09-10 06:39:09

Tekkerue (38 views)
2014-09-09 02:24:56

mitcheeb (58 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (35 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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!