Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 / Game Mechanics / Re: Following a bitmapped wall on: 2006-03-12 03:38:46
Well, I think there might some confusion in that I have no bounding box and it's just one pixel in the middle of vanessa. Because of the verlet, that pixel can traverse through a lot of black in a single frame at top speed.

We want the pixel to stay in the white and keep spped when it hits a black region, changing direfction if necessary.
2  Game Development / Game Mechanics / Following a bitmapped wall on: 2006-03-09 10:21:22
I'm not sure where to put this exactly, but this forum seems to be the most appropriate.

I'm making a clone/update to the classic game Qix. The thing I've added is that when drawing, the player has simple verlet-based physics, so he slides around and makes curves and neat stuff like that. When not drawing however, the player is restricted to the outline of the shape he's drawn. I keep the drawn area as a bitmap, so the more general problem is I want to keep the player in an area defined by a bitmap and allow for the player to slide along the edge of the area.

I've got an example below. The player - represented by the lovely Vanessa - moves downwards towards the black-off-limits area. She's working under standard physics and accelerating as she goes (I'm still pushing the button). When she hits the black area, I want her to follow the curve (red arrow). I can get her to stop dead, but I can't figure out how to get her to follow the curve.

Have any of you worked on a similar problem and can offer some help? This one puzzle's had me stumped for a month or so.

Thanks,
Del.
3  Java Game APIs & Engines / Java 2D / Re: Loading a separate alpha channel on: 2005-06-21 07:28:09
Nevermind. I r smart. S-M-R-T.
Wrong image type on the alpha mask. That's what I get for using copy/paste on everything.
4  Java Game APIs & Engines / Java 2D / Re: Loading a separate alpha channel on: 2005-06-20 10:45:33
Rise From Your Grave

I found this thread and would like to use this method for a Qix clone, but I'm having a little trouble on my implementation. Here's my terrible code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
try{
            src = ImageIO.read(new File(victim));
            img = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
            img.getGraphics().drawImage(src,0,0,null);
            imgalpha = f**k.getAlphaRaster();
           
            alpha = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
            alpha.getGraphics().setColor(Color.white);
            alpha.getGraphics().fillOval(25, 25, 100, 400);
            fimgalpha.setDataElements(0, 0, alpha.getRaster());
           
 } catch (Exception e)  {
               System.out.println("YOU FAILURE.");
            e.printStackTrace(System.out);
}

Which - to my newbie eyes - looks like your code above, but it gives unexpected results.

The alpha looks like it's being distorted. The white circle is where the alpha should be.

edit: almost forgot, trying this with any other image type (like TYPE_INT_ARGB) doesn't seem to work at all, though I can't understand why.
5  Java Game APIs & Engines / Java 2D / Re: I think I might be going about this the wrong on: 2004-02-10 17:35:39
Quote
Depends what you mean by 'character'... Are you talking about just a single sprite?  All animation frames? The actual in-game representation including all statistical information?

Uh... well, characters are multi-part, so all the sprites for it. There's a 3D skeleton and animations I haven't factored in yet, but it's miniscule compared to the sprites. If you have to know, I'm working on voxelmaps. I've got to be nuts.
6  Java Game APIs & Engines / Java 2D / Re: I think I might be going about this the wrong on: 2004-02-10 02:33:53
Quote
This code snippet shows how to get a int[] array (buffer) from the writable raster so you can just manipulate the array.

I gave this code a shot, and it does speed things up. I can't tell if anything is changing, within the for(p) loop. I guess I'll have to code more up for real to see.

On an semi-unrelated note, is 2-3MB in memory too big for a character to take up?
7  Java Game APIs & Engines / Java 2D / I think I might be going about this the wrong way. on: 2004-02-09 17:47:07
Some advice would be appreciated.

What I'm trying to do is draw to the screen based on a calculated/stored imagemap in an array. I can do it just fine, but it's painfully slow: 4FPS on this machine. I'd pre-create my images, but the memory required would be too large for ny tastes.

Maybe I'm just doing something wrong in my code, but it might be that the whole thing might have to be re-thought.

Here's my test code I whipped up, just in case it is me messing up.
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  
import java.awt.*;
import java.awt.image.*;
import javax.swing.JFrame;

class map
{
      public int[] pixels;
      public int width, height;

      public map()
      {
            width=height=100;
            pixels=new int[width*height];
            for(int i=0;i<width*height;i++)
                  pixels[i]=(int)(Math.random()*1073741823);
      }

      public void draw(BufferStrategy bs, int x, int y)
      {
            Graphics g=bs.getDrawGraphics();

            //draw
           BufferedImage bi=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
            WritableRaster wr=bi.getRaster();
            for(int p=0;p<200;p++)
            {
                  for(int row=0;row<height;row++)
                  {
                        for(int col=0;col<width;col++)
                        {
                              wr.setSample(row,col,0,pixels[(row*width)+col]);
                        }
                  }
                  g.drawImage(bi,x,y,null);
            }
            bs.show();
      }
}

class drawtest extends JFrame
{
      private static long ctm, cnt;

      public drawtest()
      {
            super("DrawTest");
      }
      public static void main(String[] args)
      {
      JFrame.setDefaultLookAndFeelDecorated(true);
            drawtest frame = new drawtest();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(250,250);
            frame.setVisible(true);

            frame.createBufferStrategy(2);
            BufferStrategy bs=frame.getBufferStrategy();

            ctm=System.currentTimeMillis();
            cnt=0;

            map bm=new map();

            while(true)
            {
                  bm.draw(bs, 100,100);
                  cnt++;
                  if((cnt%100==0) && ((System.currentTimeMillis()-ctm)>2000))
                        System.out.print("Framerate: " + (cnt/((System.currentTimeMillis()-ctm)/1000)) + " Time: " + ((System.currentTimeMillis()-ctm)/1000) + "\n");
            }

      }
}


Thanks in advance.
8  Game Development / Newbie & Debugging Questions / Stupid newbie questions about 2D on: 2004-02-06 19:45:10
Hey all, two Q's:

1) I follow the "BufferStrategy" link in the wiki and it leads to the Fullscreen tutorial. Do I have to use fullscreen mode to use BufferStrategy, or am I able to use it for windowed apps?

2) What's the best way to draw pixels from an array/calculated in code to the screen/buffer in real-time? I don't have to do this every frame, but I have to do it sometimes.
9  Java Game APIs & Engines / Java 2D / Re: Tell me I'm crazy: pretending I'm in 3d using on: 2003-06-03 20:15:50
Thanks, guys.

I wanted to keep with sprites because I can blt source images together to form a customized character. Though this works well and good for cylindrical limbs, the torso looks different from any given angle, so I might look into cel-shading/edge drawing for that.
10  Java Game APIs & Engines / Java 2D / Re: Tell me I'm crazy: pretending I'm in 3d using on: 2003-05-29 20:09:18
Wow. Thanks! How portable is LWJGL? I assume the end-users have to download it too?
11  Java Game APIs & Engines / Java 2D / Tell me I'm crazy: pretending I'm in 3d using 2d on: 2003-05-29 17:59:33
Hey guys.

I'm working on a game where the characters are composed of a physics skeleton in 3d-space. What I want to do is map 2d sprites to parts of the skeleton, and rotate/scale them to match the orientation of the part of the skeleton they represent. The reason I want to do this is to keep a cartoony feel and allow a maximum of character customization (players do not control the characters directly, so customization during the results "show" keeps the link to the character alive).

I have 4 questions about this:

1) Is AffineTransform quick enough to be doing around 20 changes like this per character? I'm thinking of having a max of 8 characters like this, so that's around 160 changes.

2) How would I go about setting up a draw system for this? I was thinking of making a "view" class that gives the "body part" a translated graphics object to blt onto, since every body part has to figure out its own orientation.

3) How does this affect caching of images ("Automatic Images")? I have to turn and squish every frame; does this change kill the cache abilities? Does it even matter? I'd like to run in a window, so it might be moot to be worrying about it anyway.

4) Am I completely out of my gourd?

12  Java Game APIs & Engines / Java 2D / Re: Loading a BufferedImage on: 2003-03-14 18:20:16
Ok, I think I fixed it. Dumbass me wasn't passing a proper component. (I told you that variable name was revealing :P)

Is there any way I can do a similar loading without actually having some component to wait on? Or do I at least have to pass through a dummy component to the media tracker?

Thanks for all your help.
13  Java Game APIs & Engines / Java 2D / Re: Loading a BufferedImage on: 2003-03-13 02:04:28
Okay... maybe not.

I modified my code the get the width and height from thr Just loaded image, but now it gives ma a runtime error that says width and height are -1.

Now, width and height are -1 if they are "not yet known", or so the API spec says. Is my image loaded or not? I kind of need those values Tongue
14  Java Game APIs & Engines / Java 2D / Re: Loading a BufferedImage on: 2003-03-12 18:44:03
Quote


try this, i don't know is this the right answer or not but i think you create the image from unfinished read image
so wait the image loaded first using mediatracker



Yep, that was it. Thanks a lot!
15  Java Game APIs & Engines / Java 2D / Loading a BufferedImage on: 2003-03-10 19:03:11
Im trying to load a image as a buffered image since I am going to rotate it around and other fun stuff like that.

The problem is I'm not loading it into the buffered image properly. When I try and draw it to my frame, all i get is a suitably sized black box. Tongue

Anyway, if you're willing to take a look at my loading code....

[CODE]
   private BufferedImage loadBI(String filename)
   {
       Image img=Toolkit.getDefaultToolkit().getImage(filename); //works
       int w = 512; // img.getWidth(this);
       int h = 384; // img.getHeight(this);
       BufferedImage newbi = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);  //variable name gives too much away Wink
       newbi.createGraphics().drawImage(img,0,0,this);
       return newbi;
   }
[/CODE]
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.

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

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

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

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

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

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

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

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

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

Riven (50 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!