Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (593)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
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 Play & Game Design / Re: Handling RPG Inventory on: 2013-10-19 23:10:45
Making separate files rather than classes seems like a much better idea and I'm glad I took a moment to consider it. I've pretty much decided on going for an XML structure for this now.

Thanks for the input!
2  Game Development / Game Play & Game Design / Handling RPG Inventory on: 2013-10-19 17:09:57
I'm working on a RPG engine and I'm considering on how to build the item classes. So far I have an abstract superclass called Item and I am creating new classes for each item that extends that class. I don't think it's a good idea though so I'm considering keeping the same Item class and saving items as XML files which can then be loaded when needed. XML would also allow for the items to be implemented outside of the source code and during run time.

I'm using XML as an example here but it's most likely going to be my choice unless someone can suggest a better method?

3  Game Development / Newbie & Debugging Questions / Re: Fog on: 2012-12-20 17:17:10
Thanks! Smiley

Checking out the GLSL tutorials from the link you gave me. I just don't want to move directly to that yet though so I'll probably take my time with it. Some really impressive looking stuff on heroku, too!
4  Game Development / Newbie & Debugging Questions / Re: Fog on: 2012-12-20 17:11:02
I'm basically trying to get a 'misty' look on top. Maybe zoom in/out features will be added later so if I can create a nice effect that fades things in/out - that would be pretty cool.
5  Game Development / Newbie & Debugging Questions / Fog on: 2012-12-20 16:54:26
I'm thinking about trying to create fog for my game but I'm not sure how to go about it.
It's only a 2D game that I'm experimenting with and so far I've been looking into OpenGL Fog but I haven't been able to get that working just yet.

I basically followed this tutorial: just I'm unsure how to get that to work with 2D alongside SpriteBatches (Using LibGDX) and things.

Example of how I'm currently trying to achieve this:
public void drawFog(){
      float fogDensity = 0.3f;
      float fogColour[] = {0.5f, 0.5f, 0.5f, 1f};
      gl.glEnable (gl.GL_DEPTH_TEST);
      gl.glFogf(gl.GL_FOG_MODE, gl.GL_EXP2);
      gl.glFogfv(gl.GL_FOG_COLOR, fogColour, 0);
      gl.glFogf(gl.GL_FOG_DENSITY, fogDensity);
      gl.glHint(gl.GL_FOG_HINT, gl.GL_NICEST);

public void render(float delta){

      gl.glClearColor(0f, 0f, 0f, 1f);
      gl.glViewport((int) glViewport.x, (int) glViewport.y, (int) glViewport.width, (int) glViewport.height);
      for(int i = 0; i < entities.size(); i++){
6  Games Center / WIP games, tools & toy projects / Re: Angel's Destiny WIP - Open Source Java Final Fantasy 2 based RPG - another story on: 2012-11-30 10:59:30
The controls were a little sticky for me and the animations are waaaay too fast. Needs a lot of work and it would be good to see some original graphics instead of stolen/place holder ones.

I hope you continue working on it, I'm a fan of RPGs like this but yeah, the engine needs a bit of work :p I wish you good luck with it and looking forward to more!
7  Game Development / Newbie & Debugging Questions / Re: Bullet Collision Loop on: 2012-05-22 11:55:41
Have you tried profiling it? How many bullets are we talking about?

You could probably save a *lot* of time if you didn't create two new Rect objects to test for each intersection. Either do the math manually or just create some Rects earlier and reuse them.
That was just some sloppy code on my behalf, I didn't think it would have affected the performance that much though? (I'll smooth it out a bit now)
And well bullets... uhm, can be around 20 maximum at any one time I think, by which time they leave the screen and get removed from the ArrayList. That's just for the player bullets minus any additional ones from enemies (which I have yet to add).
Edit: Nope, no profiling - yet.

Is this collision method run for each entity?  Because that seems wrong to me. Also just use an arraylist just like enemies.

But a short fix is to perform a distance check before collision (avoid sqrt)
I run that method for every enemy ship in the enemy ArrayList.
Like this:
         for (int i = 0; i < enemyList.size(); i++){
            Enemy enemy = enemyList.get(i);
            if (enemy.getDestroyed()){
               propList.add(new GameExplosion(enemy.x,enemy.y));

The bullets original ArrayList is held within the player object, and I just pass it to each enemy every step. If that's a bad idea how otherwise would I get each enemy to check for collisions against bullets?

Edit 2:
Thanks for the suggestion about creating the Rects early on and reusing them. Got a noticeable performance boost. I don't detect any lag unless I fill the screen up with about 40 enemies - the actual game won't get that half as many enemies on the screen at once.
8  Game Development / Newbie & Debugging Questions / Bullet Collision Loop on: 2012-05-22 09:42:38
I'm looping through an ArrayList to check if an enemy is colliding with one of the player's bullets. It runs smoothly with only a few enemies on the screen but when there's a bunch of them then the game starts to lag because every enemy is looping through every bullet.

   public void checkCollision(ArrayList<ShipBullet> bullets){
      for (int i = 0; i < bullets.size(); i++){
         ShipBullet bul = bullets.get(i);
         Rect rect1, rect2;
         rect1 = new Rect(bul.x,bul.y,bul.x+1,bul.y+4);
         rect2 = new Rect(x, y, x+graphic.getWidth(), y+graphic.getHeight());
         if (rect1.intersect(rect2)){
            destroyed = true;

Is there any better way of doing this? I was thinking of pooling the bullets but I'm not familiar with pooling just yet (pretty much just found it on Google). Just wondering if there are other methods that I can try.

The method is checked every frame and there can be up to 10~ bullets on the screen from the player alone. And it starts lagging when 6 or so enemies are present. Not to mention I'm working on a cheap Android device but I'd still like to optimize it.

9  Game Development / Newbie & Debugging Questions / Re: Getting the angle of an object relative to another on: 2012-05-13 16:50:29
Why negate then subtract from 360? Just add 360 to it and that's all Tongue

Also why don't you want negative degrees? The work fine everywhere AFAIK Wink
Hey, it works. That's all I need xD Now I'm curious... Let's try changing it! (Darn you!)
10  Game Development / Newbie & Debugging Questions / Re: Getting the angle of an object relative to another on: 2012-05-13 15:52:15
I'm sorry if I am not answering your question correctly, but from what I understand you are having domain/range restriction issues (I cannot remember which is the correct one)?

in order to determine if the restriction is obscuring the correct answer, check the x value, if the x value is negative then you have to add or subtract 180 to get what would have been the correct angle.

e.g, if you have a x change of -sqrt(2)/2 (I'm keeping it on the unit circle for simplicity), and a y value of sqrt(2)/2 then you have atan ((sqrt(2)/2)/(-sqrt(2)/2))

this will give you -pi/4 (or -45 degrees) because of the domain restrictions, but you know that it is wrong because the x value is negative, so you simply add/subtract 180 degrees (or pi whichever) to get 3pi/4 or -5pi/4 ( 135 or -225 degrees)

I apologize if the math makes no sense or the notation is ugly (typing math really sucks), but the main gist is this:

if you have a negative x change value (so the bottom part of your tan value) then you must add or subtract(completely preference which you choose) pi/2 (180 degrees) from your final angle to compensate for the restriction.

hope this helps, I apologize if I am completely off-base I am a little fried from studying Tongue,


What you said is basically what I've managed to do now Tongue
I knew the negativity would be a problem but it had to be there for the object to take the direction relative from its position.
The only other thing to do was reverse the Y as computers have it mirrored from what we learn in class. Nothing tricky though.

The finished result:
         //Get the input x/y and make it relative to the objects position and centre
         xx = inX - x - 32;
         yy = (inY - y - 32)*-1;
         //Calculate the direction and convert to degrees
         direction = Math.atan2(yy, xx)/Math.PI*180;
         //If the direction is negative, then normalise it
         if (direction < 0){
            direction = direction*-1;
            direction = 360 - direction;

Works fine all around, 0 to 360 degrees.

And I really should be revising maths too but I'm tired. Ironic that my way of having a break involves more maths. (Curse you sine and cosine rules)

Thanks though Cheesy
11  Game Development / Newbie & Debugging Questions / Re: Getting the angle of an object relative to another on: 2012-05-13 14:34:25
Math.toDegrees(Math.atan2(yy, xx));
Thanks, solved half the problem. Got me to 0 to 180 and -180 to 0 all the way around.
Just had to normalize the negativity and subtract from 360 and all works fine now Tongue
12  Game Development / Newbie & Debugging Questions / Getting the angle of an object relative to another on: 2012-05-12 11:58:51
Wasn't sure which board to post this in but nevertheless. If it needs moving, move it.

I'm working on a game and I need help with some math.
What I'm trying to do is get the angle (direction) of the mouse cursor relative to the object checking the angle.

I've applied what I have learned from class but I'm not sure if I'm doing it quite right here.

boolean direction = Math.atan(yy/xx)/Math.PI*180;

This works mostly as I get an angle returned, and in degrees not radians.
Only the angle passes from 0 to 90 and 0 to -90. Repeating itself at certain angles that would otherwise be something like 200 degrees.
The other problem is xx and yy can be negative, because the values are relative to the object on the screen.

boolean xx = input.x - x;
boolean yy = input.y - y;

I tried by forcing the values to always be positive but the angles were still messed up.

But don't get me wrong, this all works from 0 to 90 degrees flawlessly. Although if I go to around where 360-270 degrees should be, it shows 0 to -90 degrees instead.
It's like a sine wave all the way around: 0 to 90, 90 to 0, 0 to -90, -90 to 0.

I'd just rather this go from 0-360 all the way around. If anyone can help I'll be most thankful Smiley
13  Games Center / Archived Projects / Re: Build & Defend -- A Tale of Survival on: 2012-04-10 12:11:42
Give us a demo already, it's teasing me Cheesy It looks awesome!
14  Discussions / General Discussions / Re: Thank you guys, it's been great on: 2011-12-06 11:52:03
The part about the girl made me laugh. It sounded like it was going so well and you were about to say how this girl changed your life, then suddenly!
I was very careful and managed to fix the computer by replacing the damaged PSU and when Klara got home we enjoyed some gaming together. That was the first step of my path towards becoming a geek.

Brought a tear to my eye xD

I'm a newbie to Java still and I've only been learning on and off over the past few months. Before Java I used Game Maker which I've used for 2-3 years and still continue to play with it so I can kinda relate to you there.
You've actually gave me the motivation to make a visual novel - better than Pong right? Tongue

Anyhow, you're right, the people here are amazing! I've learned a lot during my short time here and I'll be sticking around.
15  Game Development / Newbie & Debugging Questions / Re: Library Question on: 2011-12-05 13:41:33
Well I seem pretty satisfied with learning LWJGL so far, plenty of tutorials which are short and sweet Smiley.
Do keep in mind that LWJGL is mostly just a low level binding to raw c libraries (like OpenGL, OpenAL, OpenCL), so to get to a point where you'll be able to write 2d games with it you'll have to write your own framework code, various boilerplate code and use various utility libraries (unless you write your own) to handle stuff like texture and sound loading. Once you're done you'll end up with something very similar to Slick2D (or similar libraries) thus having reinvented the wheel. However its fine if your into just learning stuff and/or building your own tools before starting to work on the actual game.
That's my intention. Not that I plan to make my own library like Slick, else I would just simply use Slick to begin with. I just want to understand as much as possible.
16  Game Development / Newbie & Debugging Questions / Re: Library Question on: 2011-12-05 13:00:59
Hah, I'm not the only one!
I feel a little happier inside.

Well I seem pretty satisfied with learning LWJGL so far, plenty of tutorials which are short and sweet Smiley.
17  Game Development / Newbie & Debugging Questions / Re: Library Question on: 2011-12-05 12:35:24
I guess I worded it wrong when I said that it was broke lol, as my problems were never exactly related to Java2D.
I didn't do any development with applets with it either.

No issues in terms of graphics though.

Everything else was just required a little extra work, for example playing sounds or getting form focus as it seemed to have different results from machine to machine for some reason.
I never managed to successfully get sound to work on Linux though, I was forced to reload every sound file I wanted to use because they would only play once, yet in Windows they would play infinite amount of times.

I guess I just forced my issues onto Java2D since I expected it to relate to everything else such as sound, input, etc... Which I was obviously wrong.
Heck, could just be my bad code. :p
18  Game Development / Newbie & Debugging Questions / Re: Library Question on: 2011-12-05 11:57:40
JOGL is probably too low level for your requirements. You should have a look at the Slick2D library, it has all the bells and whistles that a 2d games library needs and as you already know Java2D you won't have much of a problem moving over as the API's are very similar.

In any event there is probably a way to flip the coordinates in LibGDX and as you are already invested in it, you should probably look up how to do that first.
Thanks, I found a way to flip the coordinates in libGDX from Google, so I have something else I need to look into more. :p (Cameras)
Taking a little look into Slick anyhow and I might have a try with LWJGL too and see how that goes.

Define broke? I have my own gripes with java2d. But so far things have worked on all targets (windows, linux,mac, sun). My biggest problems have been high end performance. But i wouldn't call that broke.
It did work fine for me, just I was spending too much time looking around for solutions to why something wouldn't work on another operating system.
Felt like dealing with IE6 all over again in terms of web development lol.
19  Game Development / Newbie & Debugging Questions / Library Question on: 2011-12-05 10:59:07
I've been using the built in Java 2D libraries during my time learning Java but it really is a pain trying to get my program to work cross platform. I could test my game in Windows which would work fine; move to Linux and suddenly the whole thing is broke.

I was looking at libgdx which I grew fairly fond of, because you know, it just 'works'. My only problem with it is the reversed y coordinates which does my head in.
Now I'm taking my time learning JOGL but all I want to focus on is 2d graphics, not entirely focusing on 3d just yet.
Right now I'm unsure what to do (Stick with JOGL or is it overkill?) because I just want something that works without all the hassle of getting it to work on multiple platforms, or at least less problems than what the native Java libraries provide.

Would be helpful if anyone could give me a run-down on this.

20  Game Development / Newbie & Debugging Questions / Re: Key Detection not working on laptop on: 2011-11-16 14:34:44
I have experienced that problem with my JDoodle Jump, several people told me they can't control with the keyboard. The solution: requestFocusInWindow() Smiley

EDIT: LibGDX is an OpenGL library. You were using AWT. Two completely different graphics systems. It is best to learn the low levels of OpenGL instead of jumping to a really high level library like LibGDX that does everything for you behind the scenes Wink
Honestly I have to say - I love you.
It worked. lol
Thanks a bunch Smiley

Now I can finally continue programming games in work when I have nothing else better to do.
I'm still looking into LibGDX but I think I'll learn better where I can actually play around with things and relate to. I didn't go straight for OpenGL because I thought that it only deals with 3D stuff? (Feel free to put me straight)
21  Game Development / Newbie & Debugging Questions / Re: Key Detection not working on laptop on: 2011-11-16 11:01:57
Yup, my canvas is definitely focused.
I mean it works fine on my desktop and for everybody else, so why only does it not work on my laptop? :/

Both on Windows btw.
I originally started with Linux but that just had a complete mind of its own in terms of Java so I moved back to Windows.

I'm going to try out some small Java games around here and see if it happens with them too.

Okay, I pretty much give up. Java has annoyed me constantly on how a simple program can act completely different on other OSs and computers.
I just started looking into libgdx and I'm fairly impressed by it, so I think I'll be sticking with it. Was a little scary at first making the jump but it's easier than I thought! Tongue
22  Game Development / Newbie & Debugging Questions / Key Detection not working on laptop on: 2011-11-16 10:33:41
I followed the tutorial on pretty much line for line but I have this weird bug I just can't fix.
My little program runs fine on my computer and I can move things around on the screen, but when I move to my laptop with the same program - everything works fine except the key detection.

I've tried debugging it like so and nothing happens at all.
   public void keyPressed(KeyEvent e) {

This problem only exists on my laptop and works fine on other computers.
My laptop has JDK/JRE up to date and now I have no other solutions to try but to post here.
23  Game Development / Newbie & Debugging Questions / Re: Multiple Timers on: 2011-10-21 00:00:18
Or just use ActionEvent.getSource()?

public void actionPerformed(ActionEvent e)
    if (e.getSource() == timer1)
    else if (e.getSource() == timer2)

That has actually simplified things so much for me, thanks!
However, I've already migrated to the game loop, but knowing that this method exists will make things hell of a lot easier in the future.
24  Game Development / Newbie & Debugging Questions / Re: Multiple Timers on: 2011-10-15 20:12:32
A solution that tracked elapsed time using the game loops update method would probably be a much better way to do timers in a game.

If you want to use javax.swing.Timer anyway then don't have Player implement ActionListener but instead make a separate class that does and then pass a new instance of it to your Timer instead.
Thanks I'll just go with managing it in the game loop instead.
25  Game Development / Newbie & Debugging Questions / Re: Multiple Timers on: 2011-10-15 19:37:39
Yeah but how I would tell it what method to run?
Like the first timer initiates this method but I created another timer and it just ran the same thing, how would I change that?
public void actionPerformed(ActionEvent arg0) {
26  Game Development / Newbie & Debugging Questions / Multiple Timers on: 2011-10-15 19:17:40
How would I implement multiple timers into one class? The code below only shows one timer that I'm using but I wish to add another one. I did try earlier on but I never quite figured out how I would have a separate method for it.
Is it possible? Thanks.
import javax.swing.Timer;

        public Player(){
                timer = new Timer(150 , this);

   public void actionPerformed(ActionEvent arg0) {
      //Timer Code
27  Game Development / Newbie & Debugging Questions / Re: Viewport on: 2011-10-14 02:43:23
Do you mean getting a scrolling screen working? A "viewport" can refer to a lot of different things, like the OpenGL viewport for example.
You know the view in the game, uhhm like a sidescroller view but in all directions.

Like this:

Yep, you'd have the viewports x/y, and the worlds x/y seperately. Thats all there is to it.
Alright, thanks. I'll see if I can get something to work.
28  Game Development / Newbie & Debugging Questions / Viewport on: 2011-10-14 00:25:13
How would I go about making a viewport? I don't need any code examples or anything, just how would it work in theory?
I've had one idea like having everything on the same global x/y along with it's local x/y but not sure if that's an efficient way of doing it.
Pages: [1]
Riven (16 views)
2015-07-03 11:22:16

deepthought (43 views)
2015-06-30 15:39:44

deepthought (47 views)
2015-06-30 15:39:09

deepthought (57 views)
2015-06-30 15:36:52

Za\'Anzabar (27 views)
2015-06-29 05:44:54

TritonDreyja (43 views)
2015-06-24 17:10:40

CopyableCougar4 (43 views)
2015-06-23 00:34:45

BurntPizza (46 views)
2015-06-21 20:36:46

cookiecompiler (88 views)
2015-06-11 15:42:53

cookiecompiler (51 views)
2015-06-11 15:41:14
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 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‑
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!