Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (526)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
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 / Newbie & Debugging Questions / Re: converting java to "C" or "Unity" on: 2014-05-22 02:56:34
Well Unity allows for C# scripts which is almost syntactically identical to Java.

Also, Microsoft has an article showing what you'd do in Java and how to do it in C#.

http://msdn.microsoft.com/en-us/library/ms228358(v=vs.90).aspx
2  Discussions / General Discussions / Re: where to post my WIP game on: 2014-05-19 20:28:21
http://www.java-gaming.org/boards/wip-games-tools-toy-projects/78/view.html
3  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Removing game objects on: 2014-05-12 01:39:53
Awesome! Thank you guys.
4  Game Development / Newbie & Debugging Questions / [LibGDX][solved] Removing game objects on: 2014-05-12 01:23:39
I was wondering if there were any better ways of removing game objects in my game programmatically by hand. Essentially, once the player collides with the enemy, I want to dispose of the entity entirely.

Is there any better way to do this except for moving the enemy off screen and allowing Javas's garbage collector to flush it's memory usage when I dispose of the current screen/move to a different level?

5  Game Development / Newbie & Debugging Questions / [LibGDX] [solved] Logic error - colliding with blocked tiles in TiledMap on: 2014-05-09 16:04:33
Fixed it.


Hi JGO,

I'm having an issue with my collision system in terms of my player colliding with the tiles properly. Almost everything works except when the player moves up or down against a wall that's not on the very perimeter of the level.


The player is the Minotaur walking up onto the wall which he should have collided against.

This bug only occurs when the player faces directly head on to the wall tile that it SHOULD collide with, and walks into it. The collision works in everything but these instances.

The code below is the code I use to check for collisions with the TileMap Tile. All of the tiles that are walls have been given the property "blocked" which is what the code checks for.

Essentially, this method is called with the player's current x and y position as the parameters. Then it checks to see if it coincides with a blocked tile's x & y position.

1  
2  
3  
4  
    public boolean isBlocked(float x, float y) {
        TiledMapTileLayer.Cell cell = collisionLayer.getCell((int) (x / collisionLayer.getTileWidth()), (int) (y / collisionLayer.getTileHeight()));
        return cell != null && cell.getTile() != null && cell.getTile().getProperties().containsKey(blockedKey);
    }


This code is the context in which this method is used to check for collision when the player moves.

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  
// Rest of the movement controls omitted for brevity. These are the only statements that seem to be faulty in checking collision
        else if(Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
            currentSprite = playerSprites[0];
            float step = 0;

            if(!isBlocked(x, y + step)) {
                this.y -= speed * Gdx.graphics.getDeltaTime();
            } else {
                this.y -= 0 * Gdx.graphics.getDeltaTime();
            }

        }
        else if(Gdx.input.isKeyPressed(Input.Keys.UP)) {
            currentSprite = playerSprites[1];
            float step = 32;

            if(!isBlocked(x, y + step)) {
                this.y += speed * Gdx.graphics.getDeltaTime();
            } else {
                this.y+= 0 * Gdx.graphics.getDeltaTime();
            }


        }
    }


I'll try to upload a demo executable jar ASAP if needed.

Thanks!
6  Games Center / WIP games, tools & toy projects / Labyrinth on: 2014-05-08 04:24:24
What's up, JGO?

I've recently gotten into game development and after making a simple Pong clone, I decided to branch out and make something a little bit more complex: Labyrinth.
I don't have every single detail ironed out, and it's very early in the development process. I just wanted to practice and learn game development and some pixel art skills as necessary. Both of which I am a novice at!


Essentially, its a maze crawler game where you play as the Minotaur from the Greek story about the Labyrinth and you hunt down and eat/kill the tributes sent into the labyrinth.


To Do list:
  • Improve the collision system/iron out bugs
  • Create more tiles for level generation
  • Decide what gameplay mechanics will be in the game. Puzzle or Roguelike


Anyways, I'll be updating this post itself periodically with fresh screenshots and updates on my progress as I make the game. This way I'll be able to track my progress and motivate myself to fully complete this project.

I can post source code somewhere if requested.
7  Games Center / WIP games, tools & toy projects / Re: Mazer on: 2014-05-07 02:22:21
Any ideas for Alpha 1.3?

A main menu where you can load all the maps/txt map files and play whatever level you want without having to rewrite the level.
8  Discussions / General Discussions / Re: New feature: topic labels [solved] on: 2014-05-06 22:14:54
I think that these are quite attractive labels, I must say.
9  Discussions / Miscellaneous Topics / Re: What do you develop your games on? on: 2014-05-05 13:21:32
i5 4670 @ 3.4GHz
8gb RAM
MSI 7870 2gb GHz Edition
23" Acer IPS monitor
Windows 8.1
1tb Seagate Barracuda @ 7200rpm

I built it for gaming but it's also quite proficient at developing.
10  Games Center / WIP games, tools & toy projects / Re: Mazer on: 2014-05-05 03:39:13
When using the W, A, S, D controls, it's possible to move on top of a wall tile by moving up.

This bug only presents when using W, A, S, D controls and once on top of the wall tile the only place it seems I can move is back onto the grass.
11  Games Center / WIP games, tools & toy projects / Re: Mazer on: 2014-05-04 19:48:18
I'm assuming you're reading the level design from that text file which names wall tiles, grass tiles, spike tiles, etc. Wouldn't this just allow the player to edit that textfile and form the level to what he or she wants/exploit this to beat harder levels?
12  Games Center / WIP games, tools & toy projects / Re: Mazer on: 2014-05-04 19:19:37
Mazer 1.1 has been released!

All I have done is done some internal stuff, and added some music provided by New Grounds! Suggestions would be gladly accepted, as would anything. I will not include the source code from now on, because of personal reasons. However, I will still continue to give out the files for the game, but not the source code. The download link for the game is below.

Change log:

- Added Music (Disclaimer: I do not own the music.)

- Added graphics for hearts and (spoiler) zombie cows.

- Better Mazes! (However, it's still just one map  Sad )

DOWNLOAD:

https://www.dropbox.com/s/3fpzwor8l9wm30f/MazerAlpha.zip

Just extract all the files into a directory, and run the .jar file

I ran the .jar file but the player character doesn't show up on my screen.
13  Game Development / Newbie & Debugging Questions / Re: [LibGDX] move between screens on: 2014-05-04 15:52:42
I'm pretty new, but based on what I saw in the Simple Game Tutorial from LibGDX and the Breakout game I'm working on, it's fairly simple.

Essentially, your main class for the project will manage everything you need and you can pass an instance of it to your screens so that they can use everything from that one class and still remain lightweight and functional.

I've omitted all of the code that doesn't pertain so you can see what I've done.
In my case, the main class is BreakOutGame:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public class BreakOutGame extends Game {
   
   @Override
   public void create() {      
     
      this.setScreen(new MainMenuScreen(this)); // This is the code that actually sets the first screen of your game.
     
   }

   @Override
   public void render() {
      super.render(); // Don't forget to use super.render();
   }
}


Notice in the onCreate(); method is the code for switching the screens. That's where you would create a class to serve as one of your screens, such as MainMenuScreen in my case.

Create a class and implement Screen, then generate the methods it needs.

Use a constructor to serve as your onCreate() method with a parameter of the instance of the game. In my case:

1  
2  
3  
4  
5  
6  
7  
public class MainMenuScreen implements Screen {

public MainMenuScreen(BreakOutGame bog)
   {
      this.bog = bog;

   }


Hope it helps!
14  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Basic Pong clone - just a few questions on: 2014-05-03 17:25:06
Quote from: UprightPath
Pong physics depends on how you want to do it. You can have something like the center being a more elastic than the edges (When you hit in the center, the total delta of the pong ball doesn't go down, or perhaps even increases slightly) and less so at the edges (If you hit at an edge the ball slows down or stays at the same speed.) Or you can do it the other way around! A lot of it is dependent on how you want to do it.
I think I may implement that just to tie up loose ends before moving onto a more complicated project to learn new things. Thanks for clearing that up for me!

Quote from: UprightPath
When it comes to debugging the lagging issues having the source code available is more helpful than the .jar.

I noticed that some Java applications haven't been exiting correctly on my system (Which is what the killing the JVM would have to do with). A couple of the LD entries did it to me.

Source code.

That's all the code I wrote, it's an incredibly basic game so all of my code is just in that main class. I've put everything in the  dispose() method that implements the disposable interface, which is only the ShapeRenderer object. Aside from that it's my understanding that LibGDX should clean everything else up unless there's something I'm missing.
15  Game Development / Newbie & Debugging Questions / [LibGDX] Basic Pong clone - just a few questions on: 2014-05-03 16:25:13
Hi, thanks for stopping by. I had posted to this forum previously after making a really dumb, basic asteroids game without understanding much. So after learning quite a bit more about LibGDX itself instead of snippets of tutorials for how to achieve specific things, I have returned! Since I'm new to game programming and development, I thought it best if I started at the very basics. After reading up on the LibGDX github, I've created a 2 player Pong clone.

Pong clone
SOURCE CODE

It works, but I feel like it was pretty lazily made. I got a little excited and wanted to see if I could knock this project out in a few hours, so I feel as though I've cut some corners. You can find the whole code here, it's pretty basic. Anyways, I just wanted to post my code to see if there is any criticism to how I can improve.

Things that I've noticed:
  • The first problem I have with it, is that the ball's vertical trajectory (e.g., when it moves in a diagonal fashion) is subject to pure chance and probability. It is in no way related to what part of the paddle collides with the ball. I'm honestly not sure what the true gameplay mechanic is in the actual game Pong. If I wanted to improve this, my course of action would be to make three rectangles to serve as collision boxes and depending on where the ball hits (top 1/3 - move the ball up, middle 1/3 - send it straight across, or bottom 1/3 send it downwards). See lines 129-137 and 182-199 for the code that handles this probability.
  • The second problem is, I don't feel as though I'm handling system resources correctly. I've tried to add everything that I could to the dispose() method that I can, which for now is just the ShapeRenderer, and I think that when I stop and run the game over and over it starts to lag my system and I have to kill the JVM. I'm not sure if this is a result of my code and bad resource handling and it's creating memory leaks or not. Thoughts?

Again, thanks for reading the long post.

edit: You can download the runnable JAR here
16  Game Development / Newbie & Debugging Questions / Re: LibGDX - Collisions using Rectangles inside ArrayLists with Iterator on: 2013-09-19 23:35:06
Special thanks to drabla, and thanks for everyone else who's been contributing thus far you guys are great.

I used the loop approach and I think it would work but there's just one snag, the shots nor the asteroids are moving anymore.

The rectangle overlap loop looks like so, and it was also supposed to control the downward or upward movement of the asteroid or the shot respectively. Should I be controlling their movement another way?


EDIT: Thank you all, I've fixed the issue. The problem with the objects not moving was simply me overlooking a logic error.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
      Iterator<Rectangle> asteroidIter = asteroids.iterator();
      while(asteroidIter.hasNext()) {
         Rectangle asteroid = asteroidIter.next();
         asteroid.y -= 200 * Gdx.graphics.getDeltaTime();
         if(asteroid.y < -64 || asteroid.overlaps(playerShip)) {
            asteroidIter.remove(); continue;
         }
         Iterator<Rectangle> shotIter = shots.iterator();
         while(shotIter.hasNext()) {
            Rectangle shot = shotIter.next();
            shot.y += 500 * Gdx.graphics.getDeltaTime();
            if(shot.y > 600) {
               shotIter.remove(); continue;
            }
            if(asteroid.overlaps(shot)) {
               shotIter.remove();
               asteroidIter.remove();
               break;
            }
         }
      }
17  Game Development / Newbie & Debugging Questions / Re: LibGDX - Collisions using Rectangles inside ArrayLists with Iterator on: 2013-09-19 22:30:29
I get a runtime error and the game crashes when I try to do that.
I'm sure you didn't, else you would have most certainly posted the error.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.Error: Unresolved compilation problem: 
   The method overlaps(Rectangle) is undefined for the type ArrayList<Rectangle>

   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: java.lang.Error: Unresolved compilation problem:
   The method overlaps(Rectangle) is undefined for the type ArrayList<Rectangle>

   at com.connorkuehl.blasteroids.PlayScreen.render(PlayScreen.java:162)
   at com.badlogic.gdx.Game.render(Game.java:46)
   at com.connorkuehl.blasteroids.BlasteroidsGame.render(BlasteroidsGame.java:31)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:207)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
18  Game Development / Newbie & Debugging Questions / Re: LibGDX - Collisions using Rectangles inside ArrayLists with Iterator on: 2013-09-19 13:05:08
I get a runtime error and the game crashes when I try to do that.
19  Game Development / Newbie & Debugging Questions / LibGDX - Collisions using Rectangles inside ArrayLists with Iterator on: 2013-09-19 03:16:10
Hello all, thanks for taking the time to help me out.

I'm trying to make a top down space shooter where you shoot asteroids as you fly through space.

I'm using a similar method as in the LibGDX tutorial for making the 'Drop' game for generating asteroids and having them fall down the screen, as well as adding the asteroids to an ArrayList to keep track of all of them as well as remove them if necessary.

I'm using that same method for keeping track of the shots that the player fires.

The problem isn't in when the asteroids collide with the player, but having the asteroids collide with the bullets.

This is the first part of the approach that I'm taking to this, the iterator: my problem is that I'm unable to say
1  
if(asteroid.overlaps(shot)) { iter.remove(); }
because the shots and asteroids are declared locally in their spawn methods...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
      Iterator<Rectangle> iter = asteroids.iterator();
      while(iter.hasNext()) {
         Rectangle asteroid = iter.next();
         asteroid.y -= 200 * Gdx.graphics.getDeltaTime();
         if(asteroid.y < -64) {
            iter.remove();
         }
         if(asteroid.overlaps(playerShip)) {
            //
            iter.remove();
         }

        }
     
      Iterator<Rectangle> shotIter = shots.iterator();
      while(shotIter.hasNext()) {
         Rectangle shot = shotIter.next();
         shot.y += 500 * Gdx.graphics.getDeltaTime();
         if(shot.y > 600) {
            shotIter.remove();
         }

      }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
   public void fire() {
      Rectangle shot = new Rectangle();
      shot.x = playerShip.x + 26;
      shot.y = playerShip.y + 32;
      shot.width = 32;
      shot.height = 32;
      shots.add(shot);
      lastFired = TimeUtils.nanoTime();
     
   }
   
   public void spawnAsteroid() {
      Rectangle asteroid = new Rectangle();
      asteroid.x = MathUtils.random(600 - 64);
      asteroid.y = 320;
      asteroid.width = 64;
      asteroid.height = 64;
      asteroids.add(asteroid);
      lastAsteroid = TimeUtils.nanoTime();
   }


Are there any suggestions or should is there another beginner-friendly way to manage collisions like this?

I know it's messy but I'm very new to Java game development (but not to Java itself)
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.

toopeicgaming1999 (73 views)
2014-11-26 15:22:04

toopeicgaming1999 (62 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (27 views)
2014-11-24 19:59:16

trollwarrior1 (40 views)
2014-11-22 12:13:56

xFryIx (78 views)
2014-11-13 12:34:49

digdugdiggy (56 views)
2014-11-12 21:11:50
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!