Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (574)
Games in Android Showcase (154)
games submitted by our members
Games in WIP (620)
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 3 ... 9
1  Game Development / Newbie & Debugging Questions / Re: Fill in 2d array on: 2015-03-13 19:21:45
Did get it working, but still bug when corridor crosses through a room...will get it fixed hopefully!
2  Game Development / Newbie & Debugging Questions / Re: Where to start for something like this on: 2015-03-13 14:20:15
Hi,

I've done many years of Java coding and done quite a few games - just working on a random dungeon generator which is going ok, was just
interested if the game in question uses random dungeons or just maps drawn using something like tiled?

Thanks,
Steve
3  Game Development / Newbie & Debugging Questions / Re: Fill in 2d array on: 2015-03-13 13:25:27
Exceptions will be tidied up later - yes Array index out of bounds ones.

Start points of the paths are the centre of the rooms.  Good suggestion though.

PS - how do you embed images in here?
4  Game Development / Newbie & Debugging Questions / Re: Fill in 2d array on: 2015-03-13 10:29:21
Paths are created by taking a room say room 1 which then connects to room 2, room 2 connects to room 3 etc.
I take the center x,y of each room and draw horizontal and vertical paths.

This is the code to do the corridors:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
// Create a vertical corridor
   private void create_v_tunnel(int y1, int y2, int x) {
      int amount = Math.max(y1 - y2, y2 - y1);
      int yy1 = Math.min(y1, y2);
      for (int y = 0; y <= amount; y++) {
         tilesArray[x][yy1 + y].visible = false;
         tilesArray[x][yy1 + y].name = "V Corridor";
         tilesArray[x][yy1 + y].texture = this.floor1;
      }
   }

   // Create a horizontal corridor
   private void create_h_tunnel(int x1, int x2, int y) {
      int amount = Math.max(x1 - x2, x2 - x1);
      int xx1 = Math.min(x1, x2);
      for (int x = 0; x <= amount; x++) {
         tilesArray[xx1 + x][y].visible = false;
         tilesArray[xx1 + x][y].name = "Hz Corridor";
         tilesArray[xx1 + x][y].texture = this.floor2;
     
      }
         
   }


and called from:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
   // Carve out corridors - connect rooms to other rooms
   private void drawCorridors() {
      for (int i = 0; i < rooms.size(); i++) {
         Room r01, r02;
         try {
            r01 = rooms.get(i);
            r02 = rooms.get(i + 1);
         } catch (Exception ex) {
            return;
         }

         Random r = new Random();
         try {
               this.create_h_tunnel(r01.centerX, r02.centerX, r02.centerY);
               this.create_v_tunnel(r01.centerY, r02.centerY, r01.centerX);
         } catch (Exception ex) {
         }
      }
   }


Thanks,
Steve
5  Game Development / Newbie & Debugging Questions / Where to start for something like this on: 2015-03-12 20:32:17
This is a nice dungeon game, where the best place to start to do something similar?

https://www.youtube.com/watch?v=V271ua-Twe0

Thanks,
Steve
6  Game Development / Newbie & Debugging Questions / Re: Fill in 2d array on: 2015-03-12 16:26:47
Many thanks :-)

I'm just struggling now with putting doors where corridors would connect...The corridors go to the centre of the rooms (x,y) they are connecting too, some corridors go
straight through a room as a room it is connecting to is on the other-side of another room, can you see my dilema?

Any advice is appreciated.  Please see screenshot here: https://sites.google.com/site/dungeonplanetlite/

I need to remove corridors from within rooms and then place doors...

Thanks,
Steve

PS: this is the article I followed and coded it in Java : http://gamedevelopment.tutsplus.com/tutorials/create-a-procedurally-generated-dungeon-cave-system--gamedev-10099
7  Game Development / Newbie & Debugging Questions / Re: Fill in 2d array on: 2015-03-12 14:00:17
Hi,

Unfortunately, the array is one big array but filled in at diiferent x,y and different sizes, many of them are created so cannot initialize as you show.

Yeah, I know what you mean about the x,y but guess it is the way my brain works, lol.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
private void drawRooms() {
      for (Room rm : rooms) {
         for (int y = rm.y1; y <= rm.y1 + rm.height; y++) {
            for (int x = rm.x1; x <= rm.x1 + rm.width; x++) {
               try {

                  // We should really store texture x,y position - THIS WILL NEED DOING!!!
                  if(x==rm.x1 || x== rm.x2 || y == rm.y1 || y == rm.y2 )
                     tilesArray[x][y].texture = this.wallEdge;
                  else
                     tilesArray[x][y].texture = this.pathTexture;            
                  tilesArray[x][y].visible = true;
                  tilesArray[x][y].name = "Room:" + rm.roomNo;
               } catch (Exception e) {
               }
            }
         }
      }
   }


The above fills in my tilesArray at various positions - the tilesArray is of type Tile which has a texture associated with it (will need to put texture x,y in here at
some point instead of having lots of separate textures in lots of files).  What the code does is put walls around the rooms which are all procedurally generated.  What
I need to work out now is to place doors where the corridors connect the rooms!

Thanks,
Steve
8  Game Development / Newbie & Debugging Questions / Fill in 2d array on: 2015-03-12 13:28:02
Hi,

The 2d int array below:

1  
int testArray[][] = new int[4][5];   


I want filling with the following:
      
      1111
      1001
      1001
      1001
      1111
      
What's the best way to go about this? 

Obviously this is how to simply fill in with 1's:

1  
2  
3  
4  
5  
6  
for(int y=0; y<5; y++)
{
   for(int x=0; x<4;x++) {
      testArray[x][y] = 1;
   }
}


I came up with this, but doesn't look the best:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
private void makeRoom(int[][]testArray, int w, int h, int tileOuterId, int tileInnerId) {
      for(int y=0; y<h; y++)
      {
         for(int x=0; x<w;x++) {
            if(x==0 || x==w-1 || y==0 || y==h-1)
               testArray[x][y] = tileOuterId;
            else
               testArray[x][y] = tileInnerId;
         }
      }
   }


Just would like a method which takes in the dimensions of the array and the outer side of it is filled with 1's if you know what I mean?

Thanks,
Steve
9  Game Development / Newbie & Debugging Questions / Dungeon game on: 2015-03-10 14:16:34
Hi,

I've created a randomly generated dungeon - rooms are interlinked via corridors, scrolling is 8-way.  Using LibGdx to render the 'cruddy' gfx.

The rooms at the moment are just carved out of the map as can be seen in this link : https://sites.google.com/site/dungeonplanetlite/home  (the green is the whole map zoomed out)

Rooms are stored in a dynamic structure but no real information about them - was wondering what would be best way to store rooms and to have designs in them (tables, bricks etc)?

My map is stored in a 2d array of type Tiles:

1  
2  
   Tile[][] tilesArray = new Tile[(MyGdxGame.AMOUNTSCREENSX * MyGdxGame.SCREENWIDTH)/MyGdxGame.TILEWIDTH]
                      [(MyGdxGame.AMOUNTSCREENSY * MyGdxGame.SCREENHEIGHT)/MyGdxGame.TILEHEIGHT];


and Tile is:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
abstract class AbstractTile {
   protected String name;   // type of tile - corridor for instance, wall
   protected float x, y;
   protected boolean visible;

   protected Texture texture;

   abstract void loadTexture();
}

class Tile extends AbstractTile {
   public Tile(String name) {
      this.name = name;
      visible = true;
   }
}


Loop to draw the map:

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  
   public void drawMap(SpriteBatch batch, Texture img, Texture corridorImg,
         float width, float height) {

      int camX = (int) camera.position.x - MyGdxGame.SCREENWIDTH / 2;
      camX /= MyGdxGame.TILEWIDTH;
      int endX = MyGdxGame.SCREENWIDTH / MyGdxGame.TILEWIDTH + camX;

      int camY = (int) camera.position.y - MyGdxGame.SCREENHEIGHT / 2;
      camY /= MyGdxGame.TILEHEIGHT;
      int endY = MyGdxGame.SCREENHEIGHT / MyGdxGame.TILEHEIGHT + camY;

      if (!MyGdxGame.bDebug) {

         // Optimized loop - we only draw what we can see, that is just one
         // screen
         for (int y = camY; y < endY + 1; y++) {
            for (int x = camX; x < endX + 1; x++) {
               if (tilesArray[x][y].visible) {
                  // batch.setColor(1, 0, 0, 1);

                  batch.draw(img, tilesArray[x][y].x, tilesArray[x][y].y,
                        width, height);
               } else {
                  // this a corridor - horrible way of doing this, needs
                  // to change!
                  if (tilesArray[x][y].name.contains("orridor")) {
                     batch.draw(corridorImg, tilesArray[x][y].x,
                           tilesArray[x][y].y, width, height);
                  }
               }
            }
         }
      } else {  // draw the whole map! Only used when debug is turned on
         for (int y = 0; y < MyGdxGame.ROWS; y++) {
            for (int x = 0; x < MyGdxGame.COLS; x++) {
               if (tilesArray[x][y].visible) {
                  // batch.setColor(1, 0, 0, 1);
                  batch.draw(img, tilesArray[x][y].x, tilesArray[x][y].y,
                        width, height);
               }
            }
         }

      }
   }



If visible is false, a tile is not drawn - this is what makes up a room.

I need a way of now drawing rooms where the invisible tiles are, any good advice on this?  I was thinking of having another structure which had the room positions, width, height
and the type of room it is.

Thanks,
Steve
10  Game Development / Newbie & Debugging Questions / Re: 2d libgdx - drawing only what camera sees on: 2015-03-07 17:33:49
The if condition checks if the tile is visible, if so it gets drawn - the visible isn't a property if it is visible to the camera :-)

Anyone done any dungeon's where the screens are loaded from the hard drive at certain points - basically remove those screens
that are far away out of the 2d array and then load new ones in - almost giving infinite amount of screens.

Thanks,
Steve
11  Game Development / Newbie & Debugging Questions / Re: 2d libgdx - drawing only what camera sees on: 2015-03-06 16:06:38
Hi, blocky transition :-)

I guess it is a matter of getting the distance of how the tiles are from the player and setting the setColor method?

Thanks
12  Game Development / Newbie & Debugging Questions / Re: 2d libgdx - drawing only what camera sees on: 2015-03-06 14:37:08
Thank you,

Yes I've done parallax scrolling before using Cocos2D on iPhone, guess just draw random ones that move across the screen now and then.

I've done the code to just draw what camera sees, was quite easy, basically: (so now draws a maximum of just 64*48 tiles each frame)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
      int camX = (int)camera.position.x - MyGdxGame.SCREENWIDTH / 2;
      camX /= MyGdxGame.TILEWIDTH;
      int endX = MyGdxGame.SCREENWIDTH / MyGdxGame.TILEWIDTH + camX;
     
      int camY = (int)camera.position.y - MyGdxGame.SCREENHEIGHT / 2;
      camY /= MyGdxGame.TILEHEIGHT;
      int endY = MyGdxGame.SCREENHEIGHT / MyGdxGame.TILEHEIGHT + camY;
     
      for (int y = camY; y < endY; /*MyGdxGame.ROWS;*/ y++) {
         for (int x = camX; x < endX; /*MyGdxGame.COLS;*/ x++) {
            if(tilesArray[x][y].visible)
               batch.draw(img, tilesArray[x][y].x, tilesArray[x][y].y, width, height);
         }
      }


Although, I suspect the if condition above could be removed somehow...


I'd like to implement some form of lighting on the dungeon map - thus, tiles that are say 4 tiles away from player are darker, is this some sort
of texture lighting?  Sorry, not got a lot of openGL experience.  Maybe the setColor in SpriteBatch could be used?

Thanks,
Steve
13  Game Development / Newbie & Debugging Questions / Re: 2d libgdx - drawing only what camera sees on: 2015-03-06 13:40:03
Updated to use 2d array instead of a list collection, a lot easier.

Just to put in the code so we only draw what we can see and not the whole map!

Thinking of having a layer of clouds above the dungeon map, is it possible to add a layer and allow it to scroll slower than the map below?

Thanks again,
Steve
14  Game Development / Newbie & Debugging Questions / Re: 2d libgdx - drawing only what camera sees on: 2015-03-06 12:18:32
Thanks guys,

The List<Tile[]> is I guess quite slow, prob best as Tile[][] - going convert to that. 

As always, great help and great advice :-)
15  Game Development / Newbie & Debugging Questions / 2d libgdx - drawing only what camera sees on: 2015-03-06 11:07:55
Hi,
I've created some code that draws a random procedurally generated dungeon - all good, can scroll around etc.  Problem is my drawMap method:

1  
2  
3  
4  
5  
6  
7  
8  
9  
public void drawMap(SpriteBatch batch, Texture img, float width,
         float height) {
      for (Tile[] t : tiles) {
         for (Tile tt : t) {
            if (tt.visible)
               batch.draw(img, tt.x, tt.y, width, height);
         }
      }
   }


Tiles is defined as:    
1  
public List<Tile[]> tiles;


It just draws the whole map, now I have a camera and it's position, thus must be a way of just drawing what it sees.  The screen width is 1024/16 tiles and 768/16 tiles high so
really should just be drawing that amount. Huh Huh

Any help is appreciated.

Thanks,
Steve
16  Game Development / Newbie & Debugging Questions / Random 2d map for scroller (like terraria) on: 2015-02-25 21:06:49
Hi,

I've used LWJGL for a 3d minecraft game a couple years ago, now was wanting to do some 2d game like a lot of the sandbox ones out there - terraria, starbound etc.  I'm thinking LWJGL will be good choice for the gfx api or maybe slick2d?

Now, this is prob asked a lot, how or where do you start in creating a procedural 2d map like these games? Such as biomes?
I'd like the map to be large, being able to dig down.

I've googled stuff but still struggling with this - all seem to point to perlin noise etc.

This seemed good: http://www.java-gaming.org/topics/lwjgl-procedurally-generated-simplex-perlin-noise-2d-world/31991/view.html

and http://fbksoft.com/procedural-level-generation-for-a-2d-platformer/

Any advice, a starting point would be great.

Thanks,
Steve
17  Games Center / Cube World Projects / Re: A different Cube World on: 2013-05-18 18:53:21
This could be good ;-)
18  Games Center / Cube World Projects / Re: Voxby - my source code give away on: 2013-05-18 17:40:22
Quarry - if you read my posts you will see I've moved to using shaders and thus the programmable pipeline, the voxel engine was a learning experience for me and as Pauler says, it uses display lists - I moved to VBO and got same results. 



19  Java Game APIs & Engines / OpenGL Development / Re: Programmable pipeline on: 2013-05-12 17:33:00
Thanks,

Stack trace:

1  
2  
3  
4  
5  
6  
7  
8  
9  
Exception in thread "main" org.lwjgl.opengl.OpenGLException: Invalid operation (1282)
   at org.lwjgl.opengl.Util.checkGLError(Util.java:59)
   at org.lwjgl.opengl.GL20.glGetProgram(GL20.java:551)
   at Square.printLogInfo(ShaderBox2.java:219)
   at Square.createVertShader(ShaderBox2.java:192)
   at Square.<init>(ShaderBox2.java:127)
   at ShaderBox2.init(ShaderBox2.java:71)
   at ShaderBox2.<init>(ShaderBox2.java:26)
   at ShaderBox2.main(ShaderBox2.java:75)


My gfx card supports shading language upto 1.20 and OGL 3.0 (except shading language 1.30) - Using GLview it reports OpenGL version as 2.1 Apple-8.0.61.

Is there any tutorials which show rendering using a vertex shader, what I've seen they still use glBegin?!

Thanks

20  Java Game APIs & Engines / OpenGL Development / Re: Programmable pipeline on: 2013-05-12 16:08:54
Hi,

Here is the code that seems to cause the crash:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
private static boolean printLogInfo(int obj) {
        IntBuffer iVal = BufferUtils.createIntBuffer(1);
        glGetProgram(obj, GL_INFO_LOG_LENGTH, iVal);   // <-- THIS LINE CAUSES CRASH, IF I REMOVE THEN OK

        int length = iVal.get();
        if (length > 1) {
            // We have some info we need to output.
            ByteBuffer infoLog = BufferUtils.createByteBuffer(length);
            iVal.flip();
            glGetProgramInfoLog(obj, iVal, infoLog);
            byte[] infoBytes = new byte[length];
            infoLog.get(infoBytes);
            String out = new String(infoBytes);
            System.out.println("Info log:\n" + out);
        } else return true;
        return false;
    }


Thanks,
Steve
21  Java Game APIs & Engines / OpenGL Development / Re: Programmable pipeline on: 2013-05-10 19:48:11
Thanks,

What is the programHandle parameter?

22  Java Game APIs & Engines / OpenGL Development / Programmable pipeline on: 2013-05-10 17:12:01
Hi,

I've tried to use OGL2.0 with a vertex shader, doing it with LWJGL - fails on compiling the vertex shader which is fine as the shader compiles fine when I use ARB extensions - could it be my gfx card which is a intel hd 3000 on my macbook pro?

1  
2  
3  
4  
5  
6  
7  
vertex shader:

varying vec4 vertColor;
void main(){
           gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;
           vertColor = vec4(0.0, 0.0, 1.0, 1.0);
}

Thanks for any help
23  Games Center / Cube World Projects / Re: Voxby - my source code give away on: 2013-05-10 17:05:57
No probs ;-)

Loving the new project by the way, I really need to get into doing something similar - could I ask, I'm at a crossroad, fixed pipeline or programmable...I've tried a bit of programmable with LWJGL and OGL2.0 but get errors on my vertex shader yet using ARB extensions it is fine?!
24  Games Center / Cube World Projects / Voxby - my source code give away on: 2013-05-10 12:30:11
Here is a link to the code for my voxel project:


https://sites.google.com/site/voxbygame/


Hope it helps somebody!  (Note - collision not fully implemented).

Keys wads, space to jump (infinitely), b to drop block, u to remove block, 4 to toggle through
block player holding.
25  Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-05-10 12:23:13
It's just a value that is calculated to get a bobbing effect - I got the idea from Vermeer who I believe got it from one of nehe's tuts.

You can just do:

GL11.glTranslatef(-0.05f, 0.9f, 0.4f);

You may have to play around with the values dependant on your camera position.
26  Games Center / Cube World Projects / Re: Voxel Engine Problems on: 2013-05-10 12:12:47
I don't translate the position - just set identity and position the cube after.

I just do:

1  
2  
3  
4  
5  
6  
   glLoadIdentity();  

   GL11.glRotatef(10, 0, 0, 1);
   GL11.glTranslatef(-0.05f, (walkbias / 2.3f) + 0.9f, 0.4f);

       // draw cube


The above is called after my camera has been translated.
27  Games Center / Cube World Projects / Re: Voxel - a start on: 2013-05-10 06:33:45
Many thanks @davedes, will certainly look at your tutorials.

I have used LibGdx in the past when doing an Android game, although didn't go that low level with it.

I like LWJGL, it makes setting stuff up a lot simpler and a lot less tedious.

Thanks again,
Steve
28  Games Center / Cube World Projects / Re: Voxel - a start on: 2013-05-09 15:54:46
Thanks for your advice,

How difficult a task is it to switch to using shaders as opposed to fixed pipeline?
Such as transformations, camera system, object placement, lighting.

Programmable pipeline I believe was introduced in OpenGL3.0 - is this correct? Would not pretty
much everybody have this support on their GFX card now?

I do a lot of mobile dev work although not done any opengl on it, but that uses the programmable pipeline so if porting to say android, using programmable pipeline seems the way to go?

29  Games Center / Cube World Projects / Re: Voxel - a start on: 2013-05-09 14:32:27
Update with how my port going to C++ - well, must admit, wishing hadn't bothered, lol. Just wasted
a load of time of time I don't really have! 

I use to enjoy coding in C++, but I guess since using java for now over 8 years, I'm enjoying it  a lot more.

Lesson learned, time to get back to my vox project with Java.

Would I be wise to switch to the programmable pipeline and use shaders as opposed to fixed pipeline?
It seems a lot of people doing the voxel engines on here are using fixed pipeline.

Thanks,
Steve
30  Games Center / Cube World Projects / Re: 3D Turnbased Rougelike (LWJGL) on: 2013-05-05 17:50:09
Hi,

Looking really, really good this ;-)

Are you using shaders for this or fixed pipeline?

Thanks,
Steve
Pages: [1] 2 3 ... 9
 
Riven (31 views)
2015-04-16 10:48:47

Duke0200 (43 views)
2015-04-16 01:59:01

Fairy Tailz (33 views)
2015-04-14 20:13:12

Riven (34 views)
2015-04-12 21:36:37

bus hotdog (50 views)
2015-04-10 02:39:32

CopyableCougar4 (52 views)
2015-04-10 00:51:04

BurntPizza (52 views)
2015-04-06 22:06:58

ags1 (54 views)
2015-04-02 10:58:48

Riven (53 views)
2015-04-01 18:27:05

ags1 (70 views)
2015-03-31 10:55:12
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

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
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!