Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
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  Discussions / General Discussions / Re: Microsoft to buy Mojang for $2 billion? on: 2014-09-11 01:34:24
The bean-counter in my head can't come up with an equation where 2b makes sense.  There'd need to be some secret plan to make more than that back that isn't insane wishful thinking.  While it's true that some web calendar thing sold for a couple hundred mill in the 90s....but that was the 90s when everything tech was nuts.

A secret plan, Like make Minecraft subscription based and, Shut down bukkit/forge servers? That would be the ultimate cash in, In my opinion anyways.
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [LibGDX] Memory leaks are killing me...... on: 2014-09-08 18:09:28
Have you tried the debugger to narrow down the block(s) of code that it breaks at?
3  Game Development / Newbie & Debugging Questions / Re: Moving player tile-to-tile (A* Pathfinding finally done) on: 2014-09-07 22:56:42
Indeed it is, I have already accomplished that though.

I'm now at the stage where I possess a list that contains every tile that was generated to be walked upon to this path.

I now need to choose the fastest path out of all the tiles by tracing the ending tiles children all the way back to the starting tile.

That is the question I posted above ^__^

Thanks for replying, all help/feedback's appreciated.

Sorry for any misunderstanding, But why do you need to choose the fastest path. Shouldn't the result from the path finding be that of the fastest path?
4  Game Development / Newbie & Debugging Questions / Re: Moving player tile-to-tile (A* Pathfinding finally done) on: 2014-09-07 22:41:14
How would I go about writing a method with a Tile given as a parameter, and have it return a list of every child / childs child until point A (No more children) is reached?

Thanks again Grin

Isn't that the purpose of pathfinding in the first place?
5  Games Center / WIP games, tools & toy projects / Re: Project X [RPG] on: 2014-09-07 06:15:48
Yep, I took yet another break from completing my Grass Tiles. This time I've added a Mouse class to handle mouse clicks an such. There was a minor hiccup as some JGO members may have witnessed. But, The matter has been resolved and, A updated zip of the project can be found in the original post. There's not much you can do right now, Other than just walk around. From here, I plan on finishing the Grass Tiles and, Further developing the entity classes.
6  Game Development / Newbie & Debugging Questions / Re: Player Movement based on Mouse Clicked on: 2014-09-07 03:35:55
If it works, it works.
Hopefully, as you gain experience, you will see your code evolve from "pile of hacks" to elegance. Happens with any skill.

I agree and, I'm thankful for the suggestions an time you put into helping everyone here. Unfortunately, This was a bug that was unforeseen and, I chose to make a work around. Rather than rewrite a bunch of code. Like you said, The code will evolve over time to something a lot better.
7  Game Development / Newbie & Debugging Questions / Re: Player Movement based on Mouse Clicked on: 2014-09-07 03:24:20
If you want to try the working "as is" demo, The link to download it is posted below;

Project X v1.1.zip
8  Game Development / Newbie & Debugging Questions / Re: Player Movement based on Mouse Clicked on: 2014-09-07 03:01:39
@BurntPizza - It breaks my original player movement class and, breaks my collision system.

/Edit: I found a work around, Not the greatest hack ever. But, It does the trick. I implemented a variable called jitter, which is equal to 16 currently. So when the mouse is clicked and, The x coordinate or y coordinate is less than the jitter variable. The condition in the if statement that tells the player to move is set to false. In Java this is what it looks like:

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  
        if (mouseX > x) { // Move Right
            int xDir = 1;
            int xVariation = mouseX - x;
            if (xVariation > jitter) {
                Display.getPlayer().right = true;
                Display.playerMoved = true;
                Player.playerDirection = 2;
            }
        } else if (mouseX < x) { // Move Left
            int xDir = 2;
            int xVariation = x - mouseX;
            if (xVariation > jitter) {
                Display.getPlayer().left = true;
                Display.playerMoved = true;
                Player.playerDirection = 1;
            }
        }
       
        if(mouseY > y) { // Move Down
            int yDir = 0;
            int yVariation = mouseY - y;
            if (yVariation > jitter) {
                Display.getPlayer().down = true;
                Display.playerMoved = true;
                Player.playerDirection = 0;
            }
        } else if (mouseY < y) { //Move Up
            int yDir = 3;
            int yVariation = y - mouseY;
            if (yVariation > jitter) {
                Display.getPlayer().up = true;
                Display.playerMoved = true;
                Player.playerDirection = 3;
            }
        }
9  Game Development / Newbie & Debugging Questions / Re: Player Movement based on Mouse Clicked on: 2014-09-07 02:46:47
The problem I'm having now, Is that when I click directly left of the player. The player moves left and, up or down according to the position I clicked. I'm trying to get the player to move left and, Have it's y travel reflect the variation in the mouse click.

Like if the player is at x50 y50 and, I click at x1 y45. Obviously I want the player to move to x1, But currently it will try to goto y1 as well. Because it magnifies the y coordinate for some reason.
10  Game Development / Newbie & Debugging Questions / Re: Player Movement based on Mouse Clicked on: 2014-09-07 02:25:53
Well, if you've separated the axes, you can still adapt a similar method:

if there is a destination:
    move towards it at speed, but don't surpass it
    if at destination, remove destination


This is the working code I have right now, Except it only moves the player diagonally.

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  
package project.x;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class Mouse implements MouseListener, MouseMotionListener {

    private static int mouseX = -1;
    private static int mouseY = -1;
    private static int mouseB = -1;
    private static int x = Display.getPlayer().get_playerX();
    private static int y = Display.getPlayer().get_playerY();
    private static String xDir, yDir;
   
    public void mouseClicked(MouseEvent e) {
         
    }    


    public void mousePressed(MouseEvent e) {
        mouseB = e.getButton();
        mouseX = e.getX();
        mouseY = e.getY();
       
        if (mouseX > x) { // Move Right
            int xDir = 1;
            Display.getPlayer().right = true;
            Display.playerMoved = true;
            Player.playerDirection = 2;
        } else if (mouseX < x) { // Move Left
            int xDir = 2;
            Display.getPlayer().left = true;
            Display.playerMoved = true;
            Player.playerDirection = 1;
        }
       
        if(mouseY > y) { // Move Down
            int yDir = 0;
            Display.getPlayer().down = true;
            Display.playerMoved = true;
            Player.playerDirection = 0;
        } else if (mouseY < y) { //Move Up
            int yDir = 3;
            Display.getPlayer().up = true;
            Display.playerMoved = true;
            Player.playerDirection = 3;
        }
    }

    public void mouseReleased(MouseEvent e) {
            Display.getPlayer().left = false;
            Display.getPlayer().right = false;
            Display.getPlayer().up = false;
            Display.getPlayer().down = false;
            Display.playerMoved = false;
    }

    public void mouseEntered(MouseEvent e) {
   
    }

    public void mouseExited(MouseEvent e) {
   
    }

    public void mouseDragged(MouseEvent e) {
        mouseX = e.getX();
        mouseY = e.getY();
    }

    public void mouseMoved(MouseEvent e) {
        mouseX = e.getX();
        mouseY = e.getY();
    }

    public static int getX() {
        return mouseX;
    }
   
    public static int getY() {
        return mouseY;
    }
}
11  Game Development / Newbie & Debugging Questions / Re: Player Movement based on Mouse Clicked on: 2014-09-07 02:03:53
How is it unfit for use may I ask?

It's hard to explain, Easier to show you. Below you'll find two classes that handle the player movement, Along with keyboard input. I'm adding the mouse listener similar to the key listener.

Player.class (http://pastebin.com/jzYXKQRa)
Keyboard.class(http://pastebin.com/bFuuuLmF)

Sorry if I skipped any conventions Sad
12  Game Development / Newbie & Debugging Questions / Re: Player Movement based on Mouse Clicked on: 2014-09-07 01:44:41
Vectors, yo.

I posted about this problem yesterday I believe it was.
Run this code, then check out Player.update()
http://pastebin.java-gaming.org/c78fb8263001d

While that's probably the best solution, It's also the least appropriate given my position. I guess I'm stuck on figuring this out on my own. Thanks for trying.
13  Game Development / Newbie & Debugging Questions / [Solved] Player Movement based on Mouse Clicked on: 2014-09-07 00:57:40
Hey guys, I've been experimenting with moving my player based on Mouse Clicked. But, It always ends up performing in a undesirable manner. I would post my code, But I've cycled through so many different variations. That I can't post them all.

A common problem I've noticed is that the player never moves in a straight line. So, If someone who has already written their own implementation of player movement based on mouse clicked could give me a push in the right direction. It would be greatly appreciated, thanks in advance.
14  Game Development / Newbie & Debugging Questions / Re: flashing screen with paint() on: 2014-09-06 23:41:38
Are you double buffering? If not, Look it up. Smiley
15  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac : My Stupid Interval Bug on: 2014-09-06 22:07:37
Oh, okay! That actually makes sense. Thanks guys! But what I don't understand is why now that i've done this, the ball is jittering and enormous speeds and bouncing all of the walls xD

Well, First off, Does it act erratic right from the start or, does it misbehave once the score = 5?
16  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac : My Stupid Interval Bug on: 2014-09-06 21:38:38
What does the '%' operator actually contain? What is the difference between this operator and the bit, gang?  Smiley

So, Basically if you do;

1  
if (rallyScore % 5 == 0)


That's like saying, If rallyScore can be divided by five and, The result is zero. Then the condition is true. If the result is anything other than 0, the condition is false. You can assign 5 to your rallyInterval to change it in the future.
17  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac : My Stupid Interval Bug on: 2014-09-06 20:55:27
Ok, you could of edited your post, it's misleading since the snippet differs from the rest of the code.

It's in the pastebin link, As I took the time to format his entire class. I may have broke his code accidentally in the process. But, The fix is in there. Sorry for misleading Sad
18  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac : My Stupid Interval Bug on: 2014-09-06 20:48:42
Change the '&' to a '%'

That's exactly what I put in the code I provided him with. :/
19  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac : My Stupid Interval Bug on: 2014-09-06 20:46:29
I tried the code you provided and the ball spazzed out and jolted around the screen repeatedly, bouncing off the walls, hitting the paddle 169 times

You didn't expect me to write the final code for you, Did you?
20  Game Development / Newbie & Debugging Questions / Re: [SOLVED] Return int from Method (derped) on: 2014-09-06 20:34:16
If you havent already, make yourself familar with a debugger and place breakpoints on all locations where the value is written and inspect the value of the variable. The value will not magically change,  so you have some buggy code changing the value somewhere.  Should be easy to find with a debugger.

If you find spelling mistakes you can keep them this time Wink Or you can show me your german spelling typing on a phone...

If you would have read my post, You would have noticed I mentioned using "System.out.println()". I had these nested inside my if statements to debug where my code was failing. I resolved the issue, Marked the topic Solved. 
21  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac: First game String drawing issues on: 2014-09-06 20:00:52
First, You need to set the position where the rallyScore is rendered dynamically. Based on your GUI height/width. Then "offset" it in a if/else statement, Where "if (rallyScore == doubledigits )":

1  
2  
3  
4  
5  
6  
7  
8  
guiWidth = 800;
guiHeight = 600;

if (rallyScore.length() > 1) {
   g.drawString(rally, (guiWidth / 2) - (rallyScore.length() / 2), guiHeight / 2);
} else {
   g.drawString(rally, guiWidth / 2, guiHeight / 2);
}


Hope this makes sense, You'll have to adjust the values to position the score according to how you want it.
22  Game Development / Newbie & Debugging Questions / Re: Noob Questions From Nickropheliac : My Stupid Interval Bug on: 2014-09-06 19:36:10
I would give you some pseudo code but my computer is acting up right now, Look at your rallyInterval variable which is defined at the beginning of your class.

1  
rallyInterval = rallyScore & 5;


/Edit 2: Additionally you could do something like this @ http://pastebin.com/6xbQ7Kve (Fixed)
23  Game Development / Newbie & Debugging Questions / Re: Return int from Method on: 2014-09-06 19:01:14
Now enough chitchat, have you figured out your problem yet?

Negative. Like I previously said, The map is defined by two variables of levelWidth an levelHeight. The map renders properly, Only the Mouse Listener class can't grab the complete value of levelHeight.
24  Game Development / Newbie & Debugging Questions / Re: Return int from Method on: 2014-09-06 18:50:24
While you can do what you want, it might be a good idea to adhere to some nameing conventions like having classnames start uppercase and use propper named getters and setters for accessing properties. Simple for the fact, that IDEs support refactoring and code navigation then. Also there are templating, scripting and component libraries/frameworks that use reflection to access properties and might rely on the fact that getters and setters are named as expected.

Also I don't know if being ignorant qualifies as OCD Tongue


I'll just be nice and, Recommend you work on your spelling.
25  Game Development / Newbie & Debugging Questions / Re: Return int from Method on: 2014-09-06 01:57:27
Is it possible that since you're accessing it via Display.getLevel() (static method call) it's returning the wrong instance of the object (EDIT: Or the instance of the object before the proper height is set) at that moment the mouse listener is requesting it?

I looked into that, The Mouse Listener is initialized in the init() method of Display. The map is loaded prior to the Display class and, Is passed to it. Either way, It's only ever null or, 800.

It's practically implemented the same as my Keyboard Listener class.
26  Game Development / Newbie & Debugging Questions / Re: Return int from Method on: 2014-09-06 01:50:48
In addition, your method naming convention is different from the standard one - take a look at camelCase naming convention, especially if you will want to write library or open source project in the future. Smiley

Some conventions never outweigh OCD. If I'm ever in a position to release a open source project, The chumps using it will have to suffer as do I.

is there any code inside the "Level" class that deals with LevelHeight? It's possible you're accidentally setting it to 8 somewhere.

Is it always the first digit, or is it always 8? If you change
private int levelHeight = 800;
to 700, does it output 7, or still 8?


Well, Truth be told, levelHeight is defined in a xml file. Which is then loaded into the level class. So what I don't get is why my level loads at the appropriate height, But when I try to access it from my Mouse Listener class all I get is the number 8.
27  Game Development / Newbie & Debugging Questions / Re: Return int from Method on: 2014-09-06 01:15:01
How do you know it's returning 8? Is that from a print, or what?


Yea, I put the following line of code in the mouse listener methods and, It returned 8.

1  
System.out.println("Level Height = " + Display.getLevel().get_LevelHeight());
28  Game Development / Newbie & Debugging Questions / [SOLVED] Return int from Method (derped) on: 2014-09-06 01:09:18
Hey all, I'm implementing a MouseListener and, I'm trying to retrieve my maps height. But, For whatever reason I'm only getting the first digit when using a return method in my map class from my Mouse Listener class.

These are the three sections of code;

Level aka Map Class
1  
2  
3  
4  
5  
private int levelHeight = 800;

public int get_LevelHeight() {
      return levelHeight;
}


Mouse Listener Class
1  
h = Display.getLevel().get_LevelHeight(); // Returns 8 not 800


If anyone has any idea on what's happening here I would greatly appreciate a hint Smiley
29  Game Development / Newbie & Debugging Questions / Re: Simple walkTo(x, y) method for starter game. on: 2014-09-05 23:57:31
Try something like this, It'll stop you from going past your destination. But, Let you go as fast as possible.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
// If a destination has been flagged.
      if (walkToX != -1 && walkToY != -1) {
         int xVelocity = 5;
         int yVelocity = 5;
         
         // Handle our y.
         for (int i = 0; i < yVelocity; i++) {
            if (playerY < walkToY && playerY + yVelocity <= walkToY) {
               playerY += yVelocity;
            } else if (playerY < walkToY) {
               playerY += 1;
            }
         }

         // Handle our x
         for (int i = 0; i < xVelocity; i++) {
            if (playerX < walkToX && playerX + xVelocity <= walkToX) {
               playerX += xVelocity;
            } else if (playerX < walkToX) {
               playerX += 1;
            }
         }
      }


/Edit2: Fixed

This seems to work, but it only lets me go right/down XD
I'll see if I can get it working :c
Thanks ^____^

That's probably due to the for loops, I don't think they're necessary in that code. But, Left them there for you to debug Wink
30  Game Development / Newbie & Debugging Questions / Re: Simple walkTo(x, y) method for starter game. on: 2014-09-05 23:40:30
Try something like this, It'll stop you from going past your destination. But, Let you go as fast as possible.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
// If a destination has been flagged.
      if (walkToX != -1 && walkToY != -1) {
         int xVelocity = 5;
         int yVelocity = 5;
         
         // Handle our y.
         for (int i = 0; i < yVelocity; i++) {
            if (playerY < walkToY && playerY + yVelocity <= walkToY) {
               playerY += yVelocity;
            } else if (playerY < walkToY) {
               playerY += 1;
            }
         }

         // Handle our x
         for (int i = 0; i < xVelocity; i++) {
            if (playerX < walkToX && playerX + xVelocity <= walkToX) {
               playerX += xVelocity;
            } else if (playerX < walkToX) {
               playerX += 1;
            }
         }
      }


/Edit2: Fixed
Pages: [1] 2
 
Riven (847 views)
2019-09-04 15:33:17

hadezbladez (5795 views)
2018-11-16 13:46:03

hadezbladez (2603 views)
2018-11-16 13:41:33

hadezbladez (6211 views)
2018-11-16 13:35:35

hadezbladez (1499 views)
2018-11-16 13:32:03

EgonOlsen (4734 views)
2018-06-10 19:43:48

EgonOlsen (5793 views)
2018-06-10 19:43:44

EgonOlsen (3276 views)
2018-06-10 19:43:20

DesertCoockie (4175 views)
2018-05-13 18:23:11

nelsongames (5501 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04: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!