Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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: OutOfMemoryError, how to catch? on: 2006-12-16 22:43:40
well... like i said, in reality there shouldnt be any reason for the person to try to load a image that size...
Is there some way I can scan the file before it loads it into the system?

Like a way to view the size of the file, and if it is over the heap size, dont allow the user to upload the file?

Is there a way to call -Xmx from within the program, or does this have to be done at the batch file before the program starts?
2  Game Development / Newbie & Debugging Questions / OutOfMemoryError, how to catch? on: 2006-12-16 02:56:48
In my application, whenever I load this one file I always get a OutOf MemoryError, java heap space...

I know why, its becasue the image is 4000pixels by 4000pixels...

Which i know i have no real reason to load this, but how would i catch this error so that i can keep the program running smoothly?
3  Game Development / Newbie & Debugging Questions / Re: Character animation on: 2006-08-15 01:32:14
I would like to know this as well!
4  Game Development / Newbie & Debugging Questions / Re: Idea for serverless gaming network on: 2006-07-13 03:35:55
Another idea, you could do the peer to peer networking thing. Everyone connects to each other, and each client holds the server database information... that way if one person drops, everyone else stil has the data, and they disconnect from that one person while still being connected to everyone else. And if someone cheats and changes values on the fly, you could check the values that are recieved by the other clients and... well correct them. Yay for BITTORRENT, i think that system can be very useful in games as well as just transfering large files.
5  Game Development / Newbie & Debugging Questions / JPasswordField.getText() deprecated on: 2006-06-15 03:02:07
the method .getText() for a JPasswordField is deprecicated in Java 5.0, my question is, since that way is no longer used, how are you supposed to retrieve what the user types into the program?
6  Game Development / Newbie & Debugging Questions / Re: Explorer.exe on: 2006-06-11 17:08:10
im wanting to make a new windows explorer... something that looks different from the norm, and easier to skin, without having to install software that is packed with adware to make your theme look different. But i know there are things on windows that only explorer has access too, like whose logged in and stuff like that, mabye if i know how to access that information, that would be cool. or is explorer only made up of a file traversal and displaying the taskbar?

I know this isnt a gaming question, but this is the only forum i know of wsith people as helpful and knowledgebal as you guys here.
7  Game Development / Newbie & Debugging Questions / Explorer.exe on: 2006-06-10 19:54:11
is there any way to extend the windows Explorer in java, i am wanting to make my own version of windows explorer, but dont know how you would deal with showing the different windows and getting the current running tasks, is this even possible with java? all explorer is is a GUI and doesnt have anything really important to the stability of windows so its safe to shut it off.
8  Game Development / Newbie & Debugging Questions / Re: how to monitor loading of ressources on: 2006-05-30 19:08:02
Use a implementation of MediaTracker for your image loading, when MediaTracker notifies that its done loading, then show the game.

here's a forum link for it
http://www.java-gaming.org/forums/index.php?topic=13420.0

api
http://java.sun.com/j2se/1.5.0/docs/api/index.html

tutorials
http://www.google.com/search?q=mediatracker%20tutorials&svnum=100&hl=en&lr=&safe=off&sa=N&tab=iw
9  Game Development / Newbie & Debugging Questions / Re: brightening a circle in a BufferedImage? on: 2006-05-30 07:07:50
what does it mean to have a vector type manipulation mode?

and what exactly do you mean by store the operation to build the component, do you mean like, make a class that does the draw, and then store it in an array, and then call a drawSelf(Graphics2D g2d); whenever im ready to draw the thing to the picture? or something else?

sorry havnt replied sooner, busy busy with graduation hehe, *tired too*
10  Game Development / Newbie & Debugging Questions / Re: brightening a circle in a BufferedImage? on: 2006-05-27 00:08:54
interesting cylab, didnt think about having a transparent image and doing that...

I did find a solution last night though ! =D w00t, so it works perfectly, thanks for everyones help (will post code to solution, its not refactored yet so its kinda hard to follow, but heres the solution)


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  
//g is graphics
//img is the square circle will be in
//value the sacle is multiplied, (1 for brighter, -1 for darker)
//filter the colors if they go over 255 or under 0
public void paint(Graphics2D g){
      ImageBrightener.effectCircle(g, img, 1, true, 0, 0, 50, 50);
}
public class ImageBrightener {
public static void effectCircle(final Graphics2D g2, final BufferedImage image,
      final int value, final boolean filter, final int x, final int y, final int width, final int height){

   int[][] t = getRBGS(image, width, value, filter);
}
//scans circle finder array
//changes rbg values of image via the circlefinder array
static int[][] getRBGS(BufferedImage img, int radii, int value, boolean filter){
   
   int[][] testbythis = CircleFinder.findCircle(radii, radii);
   int[][] colors = new int[radii][radii];
   for(int x=0;x<img.getWidth();x++){
      for(int y=0;y<img.getHeight();y++){
         if(testbythis[x][y] != 0){
            int rgb = img.getRGB(x, y);
           
            int alpha = ((rgb >> 24) & 0xff);
            int red = ((rgb >> 16) & 0xff);
            int green = ((rgb >> 8) & 0xff);
             int blue = ((rgb ) & 0xff);
               
                //System.out.println("Value: "+value);
                //System.out.println("Test: "+testbythis[x][y]);
                //System.out.println("Calc: "+testbythis[x][y]*value);
                //System.out.println("Color: "+red);
                //System.out.println("New C: "+(red+(testbythis[x][y]*value)));
                //System.out.println("Color: "+green);
                //System.out.println("New C: "+(green+(testbythis[x][y]*value)));
                //System.out.println("Color: "+blue);
                //System.out.println("New C: "+(blue+(testbythis[x][y]*value)));
               
               
                red+= (testbythis[x][y] * value);
                green+= (testbythis[x][y] * value);
                blue+= (testbythis[x][y] * value);
               
                if(filter){
                   if(red > 255)
                      red = 255;
                   if(green > 255)
                      green = 255;
                   if(blue > 255)
                      blue = 255;
                   if(red < 0)
                      red = 0;
                   if(green < 0)
                      green = 0;
                   if(blue < 0)
                      blue = 0;
                }
               
                rgb = (alpha << 24) | (red << 16) | (green << 8) | blue;
               
                img.setRGB(x, y, rgb);
         }//else
            //colors[x][y] = -100;
      }
   }
   return colors;
}

//create a buffered image, draw black rect on it
//draw 5 circles different colors, giving the circle a fade effect
//scan the rbg of the new image, if the color is the blue, put the respective number in the array
//return array
public class CircleFinder {
   public static int[][] findCircle(int w, int h){
      BufferedImage bi = new BufferedImage(w, h, Transparency.BITMASK);
      Graphics2D g = bi.createGraphics();
      g.setColor(Color.BLACK);
      g.fillRect(0,0,w,h);
      //g.setColor(Color.RED);
      //g.fillOval(0,0,w,h);
      int color = 255;
      for(int i=0;i<5;i++){
         Color c = new Color(0,0,color);
         g.setColor(c);
         int x = i*2;
         int y = i*2;
         int wi = w-(i*4);
         int hi = w-(i*4);
         g.fillOval(x,y,wi,hi);
         color-=20;
      }
      //Test t = new Test(bi);
     
      int[][] p = new int[w][h];
      int multi = 1;
      for(int x=0;x<w;x++){
         for(int y=0;y<h;y++){
            int rgb = bi.getRGB(x, y);
            int red = ((rgb >> 16) & 0xff);
            int blue = ((rgb ) & 0xff);
           
            switch(blue){
            case 255:
               p[x][y] = 1;
               break;
            case 255-20:
               p[x][y] = 2;
               break;
            case 255-40:
               p[x][y] = 3;
               break;
            case 255-60:
               p[x][y] = 4;
               break;
            case 255-80:
               p[x][y] = 5;
               break;
            default:
               p[x][y] = 0;
            }
            //if(red == 255){
            //   p[x][y] = 0;
            //}else
            //   p[x][y] = 1;
         }
      }
     
      return p;
   }
11  Game Development / Newbie & Debugging Questions / Re: brightening a circle in a BufferedImage? on: 2006-05-26 03:31:39
well i dont know what color the circles will be (background color is random based on user interaction), but i just had an idea

what about creating a two dimensional array that is the size of the circle i want, and putting 0 in the positions i dont want to change and 1 in the positions i do, then request a square raster from the location on the image, run it through a filter that will change the pixels marked with a 1 to a brighter color... essentially making a circle, but scanning a square?

that good or any other idea's out there?

p.s.

thanks for the wonderful code fletcher! sparked that idea in my head =D
12  Game Development / Newbie & Debugging Questions / brightening a circle in a BufferedImage? on: 2006-05-25 22:43:21
I have my image, its the background, and i want to brighten up circles on the image, randomly placed circles (like stars), rescaleOp doesnt work because it does the whole image, (or a square if i get a subimage)

can anybody help? or give links to resources?
13  Game Development / Newbie & Debugging Questions / Re: My color changes when i change alpha... help? on: 2006-05-13 07:30:54
SOLUTION:

my values for getRed(), getGreen(), getBlue() were wrong, its

getRed(), getBlue(), getGreen()
14  Game Development / Newbie & Debugging Questions / My color changes when i change alpha... help? on: 2006-05-13 06:57:51
This is what i got, a gui screen with a viewing panel and a sidebar that has sliders for (size, opacity, flow)

size is the size of the square that is drawn on the panel
opacity is its alpha
and flow is how far its alpha extends from the original square

the problem i have is when flow is up high, and the opacity is quite low (below 100), it decides to draw different colors than the color i have choosen (brown), i dont understand why my color changes when all i change is its alpha, heres my code snippet

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public CustomPainter(information b, Graphics2D g){
      this.b = b;
      paint(g);
   }
   public void paint(Graphics2D g){
      g.setColor(b.getColor());
      g.fillRect(b.getLoc().x, b.getLoc().y, b.getSize(), b.getSize());
      paintFlow(g);
   }
   public void paintFlow(Graphics2D g){
      int flow = b.getFlow();
      Color c = b.getColor();
      for(int i=1;i<=flow;i++){
         Color n = new Color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()/i);
         g.setColor(n);
         g.fillRect(b.getLoc().x-(i*2), b.getLoc().y-(i*2), b.getSize()+(i*2)+(i*2), b.getSize()+(i*2)+(i*2));
      }
   }
15  Game Development / Performance Tuning / Re: Slowdown when rendering large images... on: 2006-05-13 06:42:07
well... its the frame rate

image.getCapabilities().isAccelerated() returns false

even when i launch through commandline with the forced ram, i even altered my program to use a volatile image instead of a buffered, still had performance loss...

BUT regardless of all that I have solved the problem ! W00T!!!!!!!!!!!, i went looking at my cache class that i was using, and noticed that before it returned the image to my main application, it decided to create a graphics class, and draw the image... then it passed the image to my program, i commented that out and there is no noticable performance loss now =D
16  Game Development / Performance Tuning / Re: Slowdown when rendering large images... on: 2006-05-13 06:22:11
it still has the lag, im guessing its mabye just the fact the comp only has 256mb ram and windows xp... but somehow i doubt thats the case... mabye painting it too many times



EDIT: i played around witht he settings a bit, and its defenently not my loop laggin it.
17  Game Development / Performance Tuning / Re: Slowdown when rendering large images... on: 2006-05-13 05:25:21
Use the VM option -Dsun.java2d.ddforcevram=true to stop this.


I got plenty of memory, but acceleration is pushed off from anti-aliasing and transparency, so how do i do the VM option thingy?

Memory: 130243840
Memory: 130211072
Memory: 130211072

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
BufferedImage img = cache.getImage("Background", 1000, 700);// returns image from hashmap if exists, if not, creates a //compatible bufferedimage with 1000x700
      Graphics2D imageDrawer = img.createGraphics();
      if(!imgcreated){
         imageDrawer.setColor(Color.WHITE);
         imageDrawer.fillRect(0,0, img.getWidth(), img.getHeight());
         imgcreated = true;
      }
      System.out.println("Memory: "+GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getAvailableAcceleratedMemory());
      //System.out.println("Accellerated: "+img.getCapabilities(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()).isAccelerated());
      //draw stuff to the image
18  Game Development / Performance Tuning / Slowdown when rendering large images... on: 2006-05-13 04:54:12
Hello... in my program i have a background (1000x700), it considerably lags my machine when my BufferedImage is this large, i even have it loaded into a HashMap cache, it works great when its 400x400 or less, is there any reason as to why it may be lagging, is there a way to speed it up? (ill post code if needed)
19  Game Development / Newbie & Debugging Questions / Re: Library jar into executable jar on: 2006-05-12 18:01:06
Can you explaine in a bit more detail? Is there a specialized tool for doing that?

Okay, found a way to go about converting your batch file into an executable

http://www.abyssmedia.com/quickbfc/index.shtml

theres to link to a program that does it (dunno if it cost money) if it does, just do a google search for "batch compilers"

good luck =D
20  Game Development / Newbie & Debugging Questions / Re: Library jar into executable jar on: 2006-05-11 23:21:25
one thing you could do is when you figure out how to launch correctly at command line, create a batch file they can double click, or make and executablet hat does that (however you do that lol) thats what eclipse and azureus and other java made applications work.
21  Game Development / Newbie & Debugging Questions / Re: Implementing zoom >.< on: 2006-05-04 19:04:06
Hehe your right Jeff, i dont fully understand it, but thats why im doing this =) to learn.

hrmm... well i got it working perfectly last night, i could zoom, anddraw on my buffered image and everything, with no performance issues (that i saw)

but my way of doing it might be a bad design...

what i do currently is i put my bufferedImage into a HashMap, then i call it from the hashmap, use "bufferedimage.createGraphics()" to get the Graphics2D, then i tell my brush class to draw itself on the image given the Graphics2D, since i have different brushes i figured creating a class for each brush implementing a brush interface would work for that. after the brush is finished doing its thing, the main loop just paints it to the scrollpane.

so what would be better for drawing, setRBG/Raster, or just using the graphics2d class to draw ? (it seems it would be easier to implement flow and opacity using the Graphics2D class than using rasters/setrbg, or am i wrong?)
22  Game Development / Newbie & Debugging Questions / Re: Implementing zoom >.< on: 2006-05-03 22:09:28
ive done some research into drawing on a buffered image and came up with some hits *yay for google*

basically you create the buffered image, use that to create a graphics, then draw on that, then you draw the image

but i still need to know where to draw new pixels and stuff....

what about still keeping my aray of pixels, but whenever i draw them to the image, remove them from the array, that way im only computing the newest pixels into the image.? doesnt sound that clean but cleaner that what i have atm lol
23  Game Development / Newbie & Debugging Questions / Re: Implementing zoom >.< on: 2006-05-03 21:52:22
Are you sure representing the image with an array of rectangles is the easiest way? just use a BufferedImage.

hehe as i just figured out it isnt (starts to lag incredibly after about 100 squares)
ive looked at bufferedimage api and i didnt know you could create something that you could draw on, how do you do that?

i got my zoom working perfectly thank youCaptainJester! =D
24  Game Development / Newbie & Debugging Questions / Re: Implementing zoom >.< on: 2006-05-02 19:14:31
that works nicely, but what about snapping the squares to grid, like you cant overlap them cause their the size of the pixel just inlarged? im guessing its time for math? if so i can figure that out.
25  Game Development / Newbie & Debugging Questions / Re: Implementing zoom >.< on: 2006-05-02 02:30:38
well... thats great if im wanting to zoom in on an image, but im working with an array of rectangles (the pixels that are drawn)

or should i convert that arraylist of rectangles to a jpg somehow, and just draw ontop of the jpeg (great except when they erase and area)

question: should i just figure out the size of my image, and do some math with that + the zoom ratio and then size the rectangles accordingly? or is there a easier way.

heres my code:

Main Class
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  
package version01;

import java.awt.*;
import java.awt.image.*;
import javax.swing.*;

public class SeqyPaint{
   JFrame frame;
   JPanel panel;
   
   public SeqyPaint(){
      frame = new JFrame("Seqy Paint");
      frame.setSize(100,100);
      //panel = new JPanel(new FlowLayout());
      addWidgets(frame.getContentPane());
      //frame.getContentPane().add(panel);
      //frame.pack();
      frame.setSize(500,500);
      frame.setVisible(true);
   }
   public void addWidgets(Container container){
      DrawingArea drawing = new DrawingArea(this);
      container.add(drawing);
   }
   public static void createAndShowGUI(){
      SeqyPaint sp = new SeqyPaint();
   }
   public static void main(String[] args){
      javax.swing.SwingUtilities.invokeLater(new Runnable(){
         public void run(){
            createAndShowGUI();
         }
      });
   }
}


Drawing canvas
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  
package version01;

import javax.swing.JComponent;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class DrawingArea extends JComponent implements MouseListener{
   SeqyPaint controller;
   ArrayList pixels;
   public DrawingArea(SeqyPaint controller){
      this.controller = controller;
      pixels = new ArrayList();
      addMouseListener(this);
   }
   public void paintComponent(Graphics g){
      g.setColor(Color.BLUE);
      g.fillRect(0,0,getWidth(), getHeight());
      g.setColor(Color.GREEN);
      g.drawRect(0,0,100,100);
     
      drawPixels(g);
   }
   public void drawPixels(Graphics g){
      for(int i=0;i<pixels.size();i++){
         Pixel t = (Pixel)pixels.get(i);
         g.setColor(new Color(t.R, t.B, t.G));
         g.fillOval(t.p.x, t.p.y, 10, 10);
      }
   }
   public void addPixel(MouseEvent e){
      Pixel t = new Pixel();
      t.R = 100;
      t.G = 255;
      t.B = 45;
      t.p = e.getPoint();
      pixels.add(t);
   }
   public void mouseEntered(MouseEvent e){}
   public void mousePressed(MouseEvent e){}
   public void mouseReleased(MouseEvent e){}
   public void mouseClicked(MouseEvent e){
      addPixel(e);
      repaint();
   }
   public void mouseExited(MouseEvent e){}
}


Pixel (the rectangle)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
package version01;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Pixel{
   int R, B, G;
   Point p;
   
   public Pixel(){
   }
   
}
26  Game Development / Newbie & Debugging Questions / Implementing zoom >.< on: 2006-05-01 19:21:48
I have a question on implementing zoom on my paint program. I dont understand how exactly it would be done.

you have your canvas, and you can draw each pixel (a fillRect with 1 pixel x 1 pixel) well, i want to be able to zoom in, so you can see each individual pixel and do pixel art, but this zoom also needs to be in a scroll pane.

So how exactly would i go about doing this?
27  Game Development / Newbie & Debugging Questions / Re: Packaging external libraries with your jar on: 2006-04-27 19:09:44
finally fixed the problem and got it to work.. seems i had to package the jar files seperate from my applications jar file... anyways, works now, thanks for the help guys!
28  Game Development / Newbie & Debugging Questions / Re: Packaging external libraries with your jar on: 2006-04-27 00:08:46
I am using webstart for my application. I cant seem to package my XStream.jar file with my programs jar file, and it use it..

I tried just copying everything in the XStream.jar and put it along with it, still doesnt work.
29  Game Development / Newbie & Debugging Questions / Packaging external libraries with your jar on: 2006-04-26 04:17:57
Okay, ive googled, and ive tried everything i can think of but i still am not having any luck

I have my program, in a package "v.two.zero" and its in a jar

it uses XStream API, and i cant seem to get this packaged with it

nothing i do gets the compiler to see it as part of the classpath, even if i have it a seperate jar file and the JNLP downloads each jar seperately... can anyone please help me out ?
30  Game Development / Newbie & Debugging Questions / Re: Getting an external resource on persons computer and saving to it on: 2006-04-26 03:53:51
well see, that was my question in the very begginng

HOW DO I PUT IT NEXT TO THE JAR FILE?

i relaly never wanted to go the registry way, but everyon keeps saying too, and now you say to do what im asking , how od i do it?
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.

Longarmx (50 views)
2014-10-17 03:59:02

Norakomi (39 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (35 views)
2014-10-15 16:18:58

TehJavaDev (66 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!