Java-Gaming.org Hi !
 Featured games (88) games approved by the League of Dukes Games in Showcase (681) Games in Android Showcase (196) games submitted by our members Games in WIP (744) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
 1 Discussions / Miscellaneous Topics / Re: What's your favorite game. on: 2012-11-10 12:59:43 - Donkey Kong Country 2 (SNES) - Zelda Ocarina of Time (N64) - Chrono Cross (PS1) - Castlevania: Symphony of the Night (PS1)
2  Game Development / Game Mechanics / Re: Rotating rectangles for collisions? on: 2012-08-15 03:46:33
no, This is all with a standard Rectangle() class. And yes, for collisions, i'm using rectangle.intersects.

Try this:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15 `         int degree = 90; //desired degree         int rectX = 100, rectY = 100, rectWidth = 150, rectHeight = 100;         Shape rect = new Rectangle(rectX, rectY, rectWidth, rectHeight); //creating the rectangle you want to rotate         Rectangle rect2 = new Rectangle(400, 100, rectWidth, rectHeight); //creating other rectangle to check intersection         AffineTransform transform = new AffineTransform();         //rotate or do other things with the rectangle (shear, translate, scale and so on)         transform.rotate(Math.toRadians(degree), rectX + rectWidth /2, rectY + rectHeight /2); //rotating in central axis         //rect receiving the rectangle after rotate         rect = transform.createTransformedShape(rect);         g2d.draw(rect); //Graphics2D object drawing the rectangle on the screen         //and then check the intersection        if(rect.intersects(rect2)){           //Do something...        }`
 3 Game Development / Game Mechanics / Re: Rotating rectangles for collisions? on: 2012-08-14 04:51:42 cubemaster21, what are you using to check the standard collisions, shape.intersects()? How are you drawing the rectangle, using the Rectangle2D class?
 4 Game Development / Newbie & Debugging Questions / Re: Background for different resolutions how to do it? on: 2012-08-05 00:58:38 Ultroman, here --> http://www.java-gaming.org/topics/2d-sprites-and-screen-resolution/23787/msg/239845/view.html#msg239845Take a look at my last post, and to the other before written by Eli Delventhal.
 5 Games Center / WIP games, tools & toy projects / Re: BOUNCE - 2D Platformer w/ destructable terrain on: 2012-08-03 17:44:58 EDIT:Yes and No. I first tried with particles, sound and textures ON and after i tried setting all OFF. I've got the same problem. Another thing, i don't know if it is purposeful, but if i fall and die in level 1 level 0, the game let me go to the level 2 level 1.
 6 Games Center / WIP games, tools & toy projects / Re: BOUNCE - 2D Platformer w/ destructable terrain on: 2012-08-03 17:32:48 The game idea is cool, i really liked the youtube vĂ­deo. Anyway, I had a problem, sometimes when i'm stuck between the blocks, if i hold UP+LEFT or UP+RIGHT the ball pass through the blocks and go insane through the level (in level 1 it happened). Another thing, i think it's consuming too much CPU for a "simple" game,  in level 1 for example is about 25% on my core i5 2.6 GHZ. Maybe a problem with the gameloop.
7  Game Development / Newbie & Debugging Questions / Re: How do you read an int from a txt file. on: 2012-08-02 15:48:47
I wrote something a couple days ago. I don't know if i'll use this method to store values (i guess i'll use xml). Anyway, the point is getting a value from a variable in the String type, and then convert it to integer or another type. The method read and search in the txt file for the "<"+"variable name" + "=", so i named this string as "beforeValue", and another String called "afterValue" (just what i have after the value, including the variable to identify the block, in this case the ";"+variable+">").

I have to wrote something like this in my txt file: <x=10;x>  The method will return the "10" in String, and then i convert it to integer.

Code:

 1  2  3  4  5 `    //Data class constructor    public Data() {        int x = Integer.parseInt(readValue("C:/myTxt.txt", "x")); //txt path and the variable you're looking for the value.        System.out.println("The variable value is "+ x); //write 10;    }`

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20 `    //Read method                                       public String readValue(String txtPath, String variable) {        String value = "0", contents = "", beforeValue = "<" + variable + "=", afterValue = ";" + variable + ">";        boolean found = false;        try {            BufferedReader read = new BufferedReader(new FileReader(txtPath));            while((contents = read.readLine()) != null && !found){                if (contents.contains(beforeValue)) {                    value = contents.substring(contents.indexOf(beforeValue) + beforeValue.length(), contents.indexOf(afterValue));                    found = true;                }            }        } catch (Exception ex) {            System.out.println(ex.getMessage());        }        return value;    }`

Obs: The txt file content also works in sequence:

E.g1 (same line): <x=10;x> <y=30;y> <z=50;z>
E.g2 (line breaking): <x=10;x>
<y=30;y>
<z=50;z>
8  Java Game APIs & Engines / Java 2D / Re: 2D-sprites and screen resolution on: 2012-07-31 21:12:40

....

So that would be like this:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20 `public static final int NORMAL_WIDTH = 1024;public static final int NORMAL_HEIGHT = 768;private float scale; public void calculateScale(){    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();    scale = Math.min( (float)d.getWidth() / NORMAL_WIDTH, (float)d.getHeight() / NORMAL_HEIGHT );} public void draw(Graphics g){    AffineTransform transform = ((Graphics2D)g).getTransform();    ((Graphics2D)g).scale(scale,scale);     drawAllMyCrap(g);     ((Graphics2D)g).setTransform(transform);}`

Thank you very much Eli Delventhal, that code helped me a lot.

For those who don't want to keep the same scale for width and height, just change the code a little bit. Like this:

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20 `public static final int NORMAL_WIDTH = 1024;public static final int NORMAL_HEIGHT = 768;private float scaleWidth, scaleHeight; public void calculateScale(){    scaleWidth = (float)Toolkit.getDefaultToolkit().getScreenSize().width / NORMAL_WIDTH;     scaleHeight = (float)Toolkit.getDefaultToolkit().getScreenSize().height / NORMAL_HEIGHT;} public void draw(Graphics g){    AffineTransform transform = ((Graphics2D)g).getTransform();    ((Graphics2D)g).scale(scaleWidth, scaleHeight);     drawAllMyCrap(g);     ((Graphics2D)g).setTransform(transform);}`

You can also implement a HierarchyBoundsListener to the JFrame, and realize some tests changing the size of it to see what happens with all the drawing stuff. Like this:

 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 `    //JFrame class implementing the HierarchyBoundsListener interface (to detect when the jframe resizes).    ....    @Override    public void ancestorResized(HierarchyEvent e) {        //'game' is the object to access a class extending Canvas or JPanel (where you're drawing the stuff).        game.setSize(getWidth(), getHeight()); //just resizing a JPanel or Canvas to the same JFrame size.        game.scaleWidth = (float)this.getWidth() / NORMAL_WIDTH;        game.scaleHeight = (float)this.getHeight() / NORMAL_HEIGHT;     }    // and then the Game class extending Canvas (or Jpanel)    ...    //The Game class draw method using Canvas and BufferStrategy    public void draw()   {        Graphics2D g2d = (Graphics2D) bufferStrategy.getDrawGraphics();        AffineTransform transform = g2d.getTransform();        g2d.scale(scaleWidth, scaleHeight);        g2d.clearRect(0, 0, getWidth(), getHeight());        //Draw all the stuff        ...                g2d.setTransform(transform);        g2d.dispose();        bufferStrategy.show();    }    `

Really simple and newbie, but i hope it may help someone...
9  Game Development / Articles & tutorials / Re: Game loops! on: 2012-07-31 17:29:57
Quote from: Gingerious
So I noticed when I added 15 instead of 10 to the sleep on the variable timestep, it didn't error out on me.  Did it error out on anyone else?

The error was that the time to sleep was a negative value, but it look like it's only for the first time the loop runs.  Every time after that it's between 8 and 10.  Any ideas?

I think i solved that error just adding Math.abs(); to the Thread.sleep calculation (making the result be always positive):

 1 `Thread.sleep(Math.abs(lastLoopTime - System.nanoTime()) / 1000000 + 10);`

For now i didn't have any problems, but i really don't know if my solution is the correct one, and if it affects the logic behind the variable timestep loop. Maybe someone could tell me if i'm doing something stupid...

 10 Games Center / Showcase / Re: My Little Dungeon - LD23 Game on: 2012-07-24 08:56:28 thank you, i'll take a look.
 11 Games Center / Showcase / Re: My Little Dungeon - LD23 Game on: 2012-07-23 12:53:00 Hey Bach, a different kind of game, cool btw. I liked the bgm.I have one question... what method do you used to resize the game? Because when we change the size of the window, all the stuff inside changes and keep the proportion (images, texts), and i want to do the same for my game (keep the proportion for all screen resolutions). I don't know anything about the libGdx library, i'm not using libraries (except for music and sound), so can it be a native function of the library or something like that?Thanks.Ps: Sorry for any english mistakes, i'm in the language learning process.
 12 Java Game APIs & Engines / Java Sound & OpenAL / Re: Need a really simple library for playing sounds and music? Try TinySound. on: 2012-07-20 11:51:26 kuusisto, i'm here to give my feedback about the library. Well, i was looking for a simple library, and when i say "simple", means simple functions, easy and at the same time powerful for my purpose. I tried the "Easy OGG" library, it's a very good library, but in my case i was looking specifically for sound effects, and with the easy ogg library i had no success, cause in sound effects for games we often need to play fast sequences (like a shooter game for example), and the easy ogg isn't good for this (correct me if i'm saying something wrong). Well, in this case, your library covered everything i needed. At the moment it's working good, no problems or bugs. For sound effects using the .ogg format, is the best that i found. Thank you very much.
 Pages: [1]
 CopyableCougar4 (46 views) 2016-06-25 16:56:52 Hydroque (82 views) 2016-06-22 02:17:53 SwampChicken (83 views) 2016-06-20 13:22:57 SwampChicken (83 views) 2016-06-20 13:22:49 SwampChicken (78 views) 2016-06-20 13:22:26 Hydroque (122 views) 2016-06-15 08:22:50 Hydroque (116 views) 2016-06-13 06:40:55 DarkCart (234 views) 2016-05-29 02:30:33 Hydroque (197 views) 2016-05-26 14:45:46 Mac70 (185 views) 2016-05-24 21:16:33
 Spasi 49x theagentd 45x NegativeZero 39x KaiHH 30x LiquidNitrogen 23x princec 19x CoDi^R 15x ags1 13x ra4king 13x kingroka123 11x Opiop 10x purenickery 9x Hydroque 8x Archive 8x SHC 8x Ecumene 7x
 Making a Dynamic Plugin Systemby Hydroque2016-06-25 00:13:25Java Data structures2016-06-13 21:22:09Java Data structures2016-06-13 21:20:42FPS Camera Tutorialby Hydroque2016-05-22 05:40:58Website offering 3D Models specifically for games for freeby vusman2016-05-18 17:23:09Website offering 3D Models specifically for games for freeby vusman2016-05-09 08:50:56Website offering 3D Models specifically for games for freeby vusman2016-05-06 11:10:21Website offering 3D Models specifically for games for freeby vusman2016-04-29 12:56:17
 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