Java-Gaming.org Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (679)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (731)
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 ... 14
1  Game Development / Newbie & Debugging Questions / Re: libGDX weird player moving away from camera! + collision dont work on: 2015-09-30 13:23:13
When do you call the fallPlayer method?

after jumping i set falling = true and falling is always waiting to be true
2  Game Development / Newbie & Debugging Questions / Re: libGDX weird player moving away from camera! + collision dont work on: 2015-09-30 13:17:22
The video is private, perhaps you should change that might you want us to see it Wink

lol sy xD there you go
3  Game Development / Newbie & Debugging Questions / Solved libGDX weird player moving away from camera! + collision dont work on: 2015-09-30 12:12:49
here is video showing you + collisions dont work

<a href="http://www.youtube.com/v/hZs_OJbPi6Q?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/hZs_OJbPi6Q?version=3&amp;hl=en_US&amp;start=</a>

the player box moves down on screen when its suppose to stay in the middle O.o never seen it before

My Tick Method
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  
   public void tick(){
     
      float moveAmountu = (float) (jumpingSpeed * fixDt);
      float moveAmountd = (float) (fallingSpeed * fixDt);
      float moveAmountl = (float) (speedLeft * fixDt);
      float moveAmountr = (float) (speedRight * fixDt);
     
     
      if(Gdx.input.isKeyJustPressed(Keys.SPACE) && !toggleJump && !jumping){
         jumping = true;
         toggleJump = true;
         falling = false;
      }
     
      if(falling){
         fallPlayer(moveAmountd);  
      }
      if(jumping){
         jumping(moveAmountu);
      }
     
      camera.position.x = pos.x;
      camera.position.y = pos.y;
      camera.update();
   }



Jump and Falling Code where i check Collision
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  
   public void jumping(float speed) {
      if(!Collision.CollisionPlayerBlock(
           
            new Point((int) (pos.x) ,
                    (int) (pos.y - speed)),
                   
            new Point((int) (pos.x + width) ,
                    (int) (pos.y - speed))  )){
         
         
         if(jumpingSpeed > 0){
            jumpingSpeed -= .09;
         }
         if(jumpingSpeed <= 0){
            falling = true;
            jumping = false;
            jumpingSpeed = defaultjumpingSpeed;
         }
         
         pos.y+=speed;
         
      }else{
         jumpingSpeed = defaultjumpingSpeed;
         falling = true;
         jumping = false;

      }
   }
   
   public void fallPlayer(float speed) {
      if(!Collision.CollisionPlayerBlock(
           
            new Point((int) (pos.x ) ,
                    (int) (pos.y + height + speed)),
                   
            new Point((int) (pos.x + width) ,
                    (int) (pos.y + height + speed)) )){
   
         
         
         if(fallingSpeed != maxSpeed*16){
            fallingSpeed += .1;
         }
         if(fallingSpeed >= maxSpeed*16){
            fallingSpeed = maxSpeed*16;
         }
         
         pos.y-=speed;

      }else{
     
         toggleJump = false;
         fallingSpeed = 0;
      }
   }



My Collision Class
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
   public static boolean CollisionPlayerBlock(Point p1, Point p2){
     
      for(int x = 0; x < 50;x++){
         for(int y = 0; y < 50;y++){
            Block[][] blocks = World.getPlayer().getWorld().getLoadedChunkBlocks();
           
            if(blocks[x][y].isSolid()){
               if(blocks[x][y].contains(p1) || blocks[x][y].contains(p1)){
                  return true;
               }
            }
           
            System.out.println(blocks.length+"");
         }
      }
      return false;
     
     
   }



My Contains Method <-- might be the one that fails me Sad
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
   public boolean contains(Point point) {

      double px = point.getX();
      double py = point.getY();
     
      if(px < blockPos.x){
         if(px > blockPos.x){
            if(py < blockPos.y){
               if(py > blockPos.y){
                  System.out.println("TRUE");
                  return true;
               }
            }
         }
      }
     
      return false;
   }


My Whole Player Class
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  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
public class Player implements InputProcessor {

   private Vector2 pos = new Vector2(50*50, 100*80);
   private Vector2 vol = new Vector2();
   
   
   private World world;
   private OrthographicCamera camera;
   private int width = 16, height = 32;
   
   public float fixDt = 60f/60F;
   public static float maxSpeed = 2.9F;
   
   public boolean falling,isInAir,jumping,isAlive,toggleJump,moving, space, running = false;
   
   public float speedLeft = 0;
   public float speedRight = 0;
   public float fallingSpeed = 3;
   public float defaultjumpingSpeed = 3.56f;
   public float jumpingSpeed = defaultjumpingSpeed;
   
   public Player(OrthographicCamera camera, World world) {
      this.camera = camera;
      this.world = world;
   }
   
   
   public void draw(SpriteBatch batch){
     
   }
   
   public void tick(){
     
      float moveAmountu = (float) (jumpingSpeed * fixDt);
      float moveAmountd = (float) (fallingSpeed * fixDt);
      float moveAmountl = (float) (speedLeft * fixDt);
      float moveAmountr = (float) (speedRight * fixDt);
     
     
      if(Gdx.input.isKeyJustPressed(Keys.SPACE) && !toggleJump && !jumping){
         jumping = true;
         toggleJump = true;
         falling = false;
      }
     
      if(falling){
         fallPlayer(moveAmountd);  
      }
      if(jumping){
         jumping(moveAmountu);
      }
     
      camera.position.x = pos.x;
      camera.position.y = pos.y;
      camera.update();
   }
   
   
   public void jumping(float speed) {
      if(!Collision.CollisionPlayerBlock(
           
            new Point((int) (pos.x) ,
                    (int) (pos.y - speed)),
                   
            new Point((int) (pos.x + width) ,
                    (int) (pos.y - speed))  )){
         
         
         if(jumpingSpeed > 0){
            jumpingSpeed -= .09;
         }
         if(jumpingSpeed <= 0){
            falling = true;
            jumping = false;
            jumpingSpeed = defaultjumpingSpeed;
         }
         
         pos.y+=speed;
         
      }else{
         jumpingSpeed = defaultjumpingSpeed;
         falling = true;
         jumping = false;

      }
   }
   
   public void fallPlayer(float speed) {
      if(!Collision.CollisionPlayerBlock(
           
            new Point((int) (pos.x ) ,
                    (int) (pos.y + height + speed)),
                   
            new Point((int) (pos.x + width) ,
                    (int) (pos.y + height + speed)) )){
   
         
         
         if(fallingSpeed != maxSpeed*16){
            fallingSpeed += .1;
         }
         if(fallingSpeed >= maxSpeed*16){
            fallingSpeed = maxSpeed*16;
         }
         
         pos.y-=speed;

      }else{
     
         toggleJump = false;
         fallingSpeed = 0;
      }
   }
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   @Override
   public boolean keyDown(int arg0) {
      return false;
   }

   @Override
   public boolean keyTyped(char arg0) {
      return false;
   }

   @Override
   public boolean keyUp(int arg0) {
      return false;
   }

   @Override
   public boolean mouseMoved(int arg0, int arg1) {
      return false;
   }

   @Override
   public boolean scrolled(int scrolls) {
     
      if(scrolls < 1){
         camera.zoom -= 0.1f;
         camera.update();
      }else{
         camera.zoom += 0.1f;
         camera.update();
      }
     
      return false;
   }

   @Override
   public boolean touchDown(int arg0, int arg1, int arg2, int arg3) {
      return false;
   }

   @Override
   public boolean touchDragged(int arg0, int arg1, int arg2) {
      return false;
   }

   @Override
   public boolean touchUp(int arg0, int arg1, int arg2, int arg3) {
      return false;
   }


   public void drawShapes(ShapeRenderer shapeR) {
      shapeR.rect(pos.x , pos.y, width, height);
   }


   public World getWorld() {
      return world;
   }
4  Game Development / Newbie & Debugging Questions / Re: libGDX Camera Frustum! on: 2015-09-30 09:20:12
1  
camera.frustum.boundsInFrustum()


Note that this method requires the position be the center of your object.

got any simple tutorial on bounding box no f**king tutorial shows a simple use for it Sad

EDIT: found out the hard way -.-
5  Game Development / Newbie & Debugging Questions / Solved libGDX Camera Frustum! on: 2015-09-29 18:22:26
basically my chunks are loaded at the right spot but unloaded at the wrong place this images shows you what i mean




basically i want the chunk to be loaded when it's x comes from the right side off the screen!!    

but when i unload it it takes the first x from left again, so it removes chunk while chunk is still in the camera bounds

i want it to unload on chunkX + chunkWidth's x instead

if that makes sense xD

this is where i draw chunks
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   public void draw(SpriteBatch batch) {
      for(int x = 0; x < chunks.length; x++){
         for(int y = 0; y < chunks.length; y++){
            if(camera.frustum.pointInFrustum(chunks[x][y].getChunkPos().x , chunks[x][y].getChunkPos().y, 0)){
               
               chunks[x][y].draw(batch);
            }
         }
      }
   }

6  Game Development / Newbie & Debugging Questions / Re: LibGDX Saving Chunks To Files? on: 2015-09-24 13:20:06
will be Reading all off this and se if i can get it to work =D
7  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-23 20:54:46
Sigh... try this:

This will solve the problems in the image you showed. But there is another that you probably haven't noticed yet.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
        for (int y = 0; y < 8; y++) {
              for (int x = 0; x < 8; x++) {
                 
               
               if(chunk.chunkBlockList[x][y] != null){
                     if (y == 7 || chunk.chunkBlockList[x][y + 1] != null) {
                         //has block on top
                        chunk.chunkBlockList[x][y].setType(BlockType.DIRT);
                     } else {
                         //is top block    
                        chunk.chunkBlockList[x][y].setType(BlockType.GRASS_TOP);
                       
                     }
               }
                 
              }

          }

what would that be most off all blocks are as they are suppose to be now i need to be able to check chunk blocks above current chunk
8  Game Development / Newbie & Debugging Questions / Re: LibGDX Saving Chunks To Files? on: 2015-09-23 20:51:58
There are 2 different scenarios:

infinite or very big world:

use more than one file, since the memory usage and read and write
speed will decrease heavily, if you load too big files. You could store
16x16 chunks per file, and give this files coordinates

medium or small world (world that doesn't consume tons of memory, and can be saved quite quick)

Here you can save it in one file.


If youre just looking for a way to actually arrange the data, try jnbt. NBT is
the file format minecraft uses, and im using for my game right now. It's
a tree-like format, which is built out of different tags, like a Float Tag, Integer Tag,
Byte Array Tag and additionally Compound Tags, to actually build a tree. You
can google for jnbt, and use the file format of minecraft as reference (can be found
at minecraft wiki). The actual chunk data is saved as a byte array in this form
(assuming it's a 2D world): blocks[x * CHUNK_SIZE + y] = blockAt(x, y).

I hope this helps you out.

can you link any good tutorials on how to use it? it sounds promesing Smiley + i used todo minecraft plugins dunno if that will help att all hope fully i get it to work =D
9  Game Development / Newbie & Debugging Questions / Re: LibGDX Saving Chunks To Files? on: 2015-09-23 15:18:38
So what is your question? Are you having difficulty doing the actual file IO or serialization, etc.?
i dont know where to start besides adding chunks to file =/
10  Game Development / Newbie & Debugging Questions / LibGDX Saving Chunks To Files? on: 2015-09-23 12:05:00
i have now tried for about 6h to save chunks to file and then reload them back to game when needed

give any tips that might help me?
a good saving library like simple-json / xml

and how to approach this problem


basically what am trying to do is when all chunks has been generated
it will save them to one file
then ing remove chunks completely so they dont exist

and when player starts to go close to the location off those chunks they load back in using the file with information!

ChunkManager --> generates chunks and saves em to a file
Chunk --> generates blocks with properties

and what i want chunk file to do
ChunkFile --> save chunks and there inforamtion on the blocks and the chunks location in the Chunk[][] array
save the blocks in etch chunk and there location in the chunk and what type off block it is


you might have an idea now but just in case Smiley

PINK = Player Camera
BLUE = Loaded Chunks Player Camera Sees Chunks
YELLOW'ISH = Chunks Ready To Be Loaded, by taking info about it in file
RED = Not Even In Game, its just in a File And Ready To be Added To Game



11  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-22 15:54:30
You're looking at it the wrong way.

HuhHuhHuhHuh?
12  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-22 13:44:26
I'll give you a hint. That's only part of the problem.

1  
2  
        for (int y = 0; y < 7; y++) {
              for (int x = 0; x < 8; x++) {


well they cant both be 8 if i do
  • [y + 1]
13  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-22 07:30:33
please help me with this problem?
14  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-22 05:59:17
There's an obvious pattern there. You can do it.

i have been trying for hours now please come with a clue or something
15  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 21:36:01
Well is that the top of that chunk?

Draw the bounds of the chunks. So that you can visualize better.


this does not work with the system i want how would i fix like corner blocks and shit then?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
          for (int y = 0; y < 7; y++) {
              for (int x = 0; x < 8; x++) {
                 
               
               if(chunk.chunkBlockList[x][y] != null){
                     if (chunk.chunkBlockList[x][y + 1] != null) {
                         //has block on top
                        chunk.chunkBlockList[x][y].setType(BlockType.DIRT);
                     } else {
                         //is top block    
                        chunk.chunkBlockList[x][y].setType(BlockType.GRASS_TOP);
                       
                     }
               }
                 
              }
          }


this is all that does Sad
https://gyazo.com/b01db316c8a4256f401e519494a73325
16  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 19:26:38
Well is that the top of that chunk?

Draw the bounds of the chunks. So that you can visualize better.

cant my ShapedRenderer overrides my textures for some reason =P
17  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 19:13:16
You need to learn to write test code. Design a universe with just 4 blocks and execute the method. What happens? Run it again using a debugger.

https://gyazo.com/623a1dc1b8f4fb4dd69abd8e306abc0b

well i kinda solve it but its still alot off dirt that is dirt at top
18  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 19:05:53
You're using

1  
chunkBlockList.length


Edit: Oh you fixed it.

https://gyazo.com/e11f7eff60d2814e4d80d55642b2aa97

was not what i expected there is tons off dirt blocks at top that is still dirt and some chunks are just grass O,o

current code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
             for (int y = 0; y < 7; y++) {
                    for (int x = 0; x < 8; x++) {
                        if (chunk.chunkBlockList[x][y + 1] != null) {
                            //has block on top
                           setType(BlockType.DIRT);
                        } else {
                            //is top block    
                           setType(BlockType.GRASS_TOP);
                        }
                    }
                }
19  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 18:53:46
This is what I gather from what a compilation of your posts have said about this chunking system: Each chunk is 8x8, the world is comprised of chunks stretching left and right procedurally (un-bounded), and fixed vertically. The chunks are stored in a List, and the block inside of chunks are stored in individual Lists. Correct?

Assuming this (and keeping the same system), I would store the blocks in arrays (either 1D or 2D, it doesn't matter) inside each chunk instead of the Lists. The chunks themselves can continue to be stored in List format. That way, you can implement what KudoDEV suggested, which would be much easier than searching the List for each block.

well so i did but get error here
1  
2  
3  
4  
5  
6  
7  
         for(int x = 0; x < chunkBlockList.length;x++){
            for(int y = 0; y < chunkBlockList.length;y++){
               if(chunkBlockList != null){
                  chunkBlockList[x][y].draw(batch);
               }
            }
         }


and here is where i add blocks to chunk

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  
      chunkBlockList = new Block[8][8];
     
      for(int x = 0; x < chunkBlockList.length;x++){
         for(int y = 0; y < chunkBlockList.length;y++){

           
            int col = map.getPixel(region.getRegionX() + x, region.getRegionY() + y);

            switch(col & 0xFFFFFFFF){
               
               case 0xFFFFFFFF:
                  chunkBlockList[x][y] = new Block(
                        this,
                        gameScreen,
                        chunk_pos.x + x * Assets.blockSize,
                        chunk_pos.y + y * Assets.blockSize, BlockType.DIRT);
                  System.out.println("ADDED: NEW DIRT BLOCK: "+x+","+y + " TYPE: "+chunkBlockList[x][y].getBlockType());
                 
                 
               break;
               
           
            }
         }  
      }


it gives me the msg and it says it adds blocks so why do i get NullPointerException


EDIT: Got Rid off the error
20  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 18:17:34
can you? convert that code with arraylist instead?
21  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 17:36:25
Honestly I don't get your code.

if you use am array for the chunks you can do something like this:
Keeping it as similar as your original method.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
for (Chunk chunk : chunks) {
    for (int y = 0; y < rows; y++) {
        for (int x = 0; x < columns; x++) {
            if (chunk.blocks[x][y + 1] != null) {
                //has block on top
            } else {
                //is top block    
            }
        }
    }
}


i'am using arraylist btw =P just so you know can you convert that?
22  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 17:22:48
I have no idea what you mean anymore.

checking the block with it self like this
1  
2  
3  
      boxRectangle = new Rectangle(block_pos.x , block_pos.y , 0.3f , 0.3f);
   
      blockFace_UP = new Rectangle(block_pos.x , block_pos.y, 0.3f , 0.3f);


and check if they overlap etch other works

but when i do this

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
      boxRectangle = new Rectangle(block_pos.x , block_pos.y , 0.3f , 0.3f);
   
      blockFace_UP = new Rectangle(block_pos.x , block_pos.y + 0.4f, 0.3f , 0.3f);
     
      if(isAlive){
         if(body.isActive()){
           
            for(Chunk chunk : gameScreen.chunks){
               
               for(Block block : chunk.getBlocks()){
                  if(block != this){
                     if(!block.boxRectangle.overlaps(this.blockFace_UP)){
                        setType(BlockType.DIRT);
                     }else{
                        setType(BlockType.GRASS_TOP);
                     }
                  }
   
                  break;
               }
            }
         }
      }


it does not work

and if you wonder why i add 0.4f to blockface its so the rectangle check moves up one block
23  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 17:15:52
Is that image what it should look like? it's confusing. I can't tell whats grass.

No y coord?

1  
2  
3  
boxRectangle = new Rectangle(block_pos.x - Assets.blockSize / 2, block_pos.x - Assets.blockSize / 2, 0.3f, 0.3f);
   
blockFace_UP = new Rectangle(block_pos.x, block_pos.x , 0.3f, 0.3f);


to:

1  
2  
3  
boxRectangle = new Rectangle(block_pos.x - Assets.blockSize / 2, block_pos.y - Assets.blockSize / 2, 0.3f, 0.3f);
   
blockFace_UP = new Rectangle(block_pos.x, block_pos.y , 0.3f, 0.3f);

i edited those boxes, is where the boxRectangle is and where blockFace_UP  is the small once is all the blocks blockface up the bigger once are the blocks
24  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 16:57:41
So the little rectangles are grass? Are your blocks in an array or list?

is blockFace_UP an adjacent block?

in a list

but not even this works :/

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      boxRectangle = new Rectangle(block_pos.x - Assets.blockSize / 2, block_pos.x - Assets.blockSize / 2, 0.3f, 0.3f);
   
      blockFace_UP = new Rectangle(block_pos.x, block_pos.x , 0.3f, 0.3f);
     
//      if(isAlive){
//         if(body.isActive()){
            if(boxRectangle.contains(blockFace_UP)){
               setType(BlockType.GRASS_TOP);
            }
//         }
//      }


tried blockFace_UP = new Rectangle(block_pos.x - Assets.blockSize / 2, block_pos.x - Assets.blockSize / 2, 0.3f, 0.3f); as well

and just check my y was x but correcting it did not work
25  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 16:50:36
Is it a side scroller? What kind of game is it. it's impossible to help without knowing.

so checkBlock.blockFace_UP.overlaps(boxRectangle) is always returning false?

yeah its a side scroller, but why is it false doh here are the rectangles
https://gyazo.com/4d59e4bfe47dae153391c918bbb6afd0

the once at top is suppose to be the grass tiles coos there rects are not intersecting with any block

26  Game Development / Newbie & Debugging Questions / Re: LibGDX top grass tiles on: 2015-09-21 16:42:00
remove:
1  
2  
3  
else{
    setType(BlockType.GRASS_TOP); else we set it to grass top
}


i want to be able to set all blocks underneath to dirt and all blocks that is not intersecting with anything from top to be dirt
27  Game Development / Newbie & Debugging Questions / LibGDX top grass tiles on: 2015-09-21 16:35:40
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  
if(isAlive){
         if(body.isActive()){
           
            for(Chunk chunk : gameScreen.chunks){ <-- all game chunks
               
               Chunk checkCheck = chunk;
               
               for(Block blocks : checkCheck.getBlocks()){ <-- all chunks blocks
                 
                  Block checkBlock = blocks;
               
                  if(checkBlock != this){ <-- make sure its not the block we are currently checking
                     
                     if(checkBlock.blockFace_UP.overlaps(boxRectangle)){ if the if the checkbox'es rectangle above it overlaps the checking rectangle then we set it to dirt
                        setType(BlockType.DIRT);
                     }else{
                        setType(BlockType.GRASS_TOP); else we set it to grass top
                     }
                     
                  }
                 
                 
               }
               
            }
           
         }
      }


it just makes everything grass tiles
28  Game Development / Newbie & Debugging Questions / Re: libGDX get pixels out off TextureRegion on: 2015-09-20 19:19:12
A TextureRegion is merely just a region of a texture. It doesn't make a new texture, it just has numbers telling what part of the texture it occupies. You can merely use the TextureRegion's bounds to get the desired pixel on the original Texture object.

Say your region is using pixels from 8, 8 to 16, 16. If you want to get the pixel at 1, 1 in your region, you would start at where the texture region starts ( 8, 8 ) and add your desired coordinates that are in your region (1, 1). That ends up to the pixel at 9, 9 on your texture.

thanks mate Smiley really help alot =D now i know what texture region does better as well
29  Game Development / Newbie & Debugging Questions / Re: libGDX get pixels out off TextureRegion on: 2015-09-20 18:48:55
What's the problem exactly?

basicly i random generate an image 80x80 pixels
then i cut this image down to 8x8 images and pass on to my chunk system
all chunks needs to be able to ready this 8x8 image and get there pixel but the only way i know to get pixels is by doing this

1  
2  
3  
4  
5  
6  
7  
   
      TextureRegion chunk... <-- the 8x8 image

      Texture texture = chunk.getTexture();
     
      texture.getTextureData().prepare();
      map = texture.getTextureData().consumePixmap();


and what this does
1  
 chunk.getTexture();


it goes back to the orginal image of 80x80 pixels and no chunk is getting the blocks its suppose 2
30  Game Development / Newbie & Debugging Questions / Solved libGDX get pixels out off TextureRegion on: 2015-09-20 18:33:45
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      here it is 8 pixels
      System.out.println(chunk.getRegionWidth());
     
      Texture texture = chunk.getTexture();
     
      System.out.println(texture.getWidth());
      here it is back to 80 pixels

     
      texture.getTextureData().prepare();
      map = texture.getTextureData().consumePixmap();


if i do that it takes the pixels out off the orginal image and not the cutted texture region
Pages: [1] 2 3 ... 14
 
Mac70 (24 views)
2016-05-24 21:16:33

theagentd (41 views)
2016-05-14 18:38:35

theagentd (72 views)
2016-05-10 22:37:41

theagentd (77 views)
2016-05-10 22:33:46

IanParcs (108 views)
2016-04-18 14:18:53

KaiHH (101 views)
2016-04-18 08:35:41

KaiHH (129 views)
2016-04-15 12:43:58

theagentd (133 views)
2016-04-14 02:16:17

theagentd (155 views)
2016-04-14 02:15:43

IanParcs (250 views)
2016-04-12 03:51:16
FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50
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!