Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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  Discussions / Miscellaneous Topics / Looking for an Repo & Tutorials on: 2014-07-03 23:48:46
Hello,
I had have found an (Java)? Game Project on an Code Hosting Site and found it very useful, but I am not able to find it anymore.
It was an bigger one and I believe a clone of Dwarf Fortress. It followed mainly the ECS Model. Would be great if someone knews it.

And furthermore I am looking for more games which are implemented as an Component System.
2  Game Development / Newbie & Debugging Questions / Re: Colission Detection + ECS on: 2013-10-08 17:02:31
Okay, thx.
Updated the first post, hope somebody can now imagine what I am doing. But I basiclly guess that my Player has such a bad behaviour, due to the Input of more than one Key.
3  Game Development / Newbie & Debugging Questions / Re: Colission Detection + ECS on: 2013-10-07 18:41:32
Well, has nobody an clue whats wrong?
4  Game Development / Newbie & Debugging Questions / Colission Detection + ECS on: 2013-10-05 20:53:14
Hey I wrote a while back a Colission Detection which works more or less.
The problem is that if i am pressing up and left or right and above me is a colission Tile my Sprite goes the whole way right/left to the last colission Tile and I dont get why.

And how can I make it more intuitive? Because I want to be able to rotate Sprite, so they are not just looking in one of the four directions.

atm, I am doing it so:
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  
TiledMapTileLayer colissionLayer = (TiledMapTileLayer) gameMap.getLayers().get("colission");

        Vector3 colissionTile = null;
        if (colissionLayer != null || colissionOn) {
            if (pseudoPlayer == null) this.pseudoPlayer = new Player(player.getPostition(), player.getImage());
            pseudoPlayer.setFacing(player.getFacing());
            pseudoPlayer.setX(player.getX());
            pseudoPlayer.setY(player.getY());
            pseudoPlayer.update(elpasedTime);
            colissionTile = Collision.getTileColission(pseudoPlayer, colissionLayer, "blocked");
        }
        if (colissionTile == null) {
            player.update(elpasedTime);
        } else {
            switch (player.getFacing()) {
                case RIGHT:
                    player.setX(colissionTile.x - player.getWidth() - 1);
                    break;
                case LEFT:
                    player.setX(colissionTile.x + getTileSize() + 1);
                    break;
                case UP:
                    player.setY(colissionTile.y - player.getHeight() - 1);
                    break;
                case DOWN:
                    player.setY(colissionTile.y + getTileSize() + 1);
                    break;
            }
        }

    public static Vector3 getTileColission(IEntiy entity, TiledMapTileLayer layer, String term) {
        float y = entity.getY(), x = entity.getX();
        float TILE_SIZE = layer.getTileWidth();

        int tileX = (int) (x / TILE_SIZE);
        int tileY = (int) (y / TILE_SIZE);

        Vector3 tileA = new Vector3(x, y, 0);
        Vector3 ereg = new Vector3(0, 0, 0);
        int width = (int) entity.getWidth();
        int height = (int) entity.getHeight();

        tileA.x = tileX * TILE_SIZE;
        tileA.y = tileY * TILE_SIZE;
        if (intersects(entity, tileA, 32, 32) && !tileisFree(tileX, tileY, layer, term)) {


            return ereg.set(World.tilesToPixels(tileX, (int) TILE_SIZE), World.tilesToPixels(tileY, (int) TILE_SIZE), 0);
        }

        x += width;
        tileX = (int) (x / TILE_SIZE);
        if (intersects(entity, tileA, 32, 32) && !tileisFree(tileX, tileY, layer, term)) {
            return ereg.set(World.tilesToPixels(tileX, (int) TILE_SIZE), World.tilesToPixels(tileY, (int) TILE_SIZE), 0);
        }

        x -= width;
        y += height;
        tileY = (int) (y / TILE_SIZE);
        tileX = (int) (x / TILE_SIZE);
        if (intersects(entity, tileA, 32, 32) && !tileisFree(tileX, tileY, layer, term)) {
            return ereg.set(World.tilesToPixels(tileX, (int) TILE_SIZE), World.tilesToPixels(tileY, (int) TILE_SIZE), 0);
        }

        x += width;
        tileX = (int) (x / TILE_SIZE);
        if (intersects(entity, tileA, 32, 32) && !tileisFree(tileX, tileY, layer, term)) {
            return ereg.set(World.tilesToPixels(tileX, (int) TILE_SIZE), World.tilesToPixels(tileY, (int) TILE_SIZE), 0);
        }

        return null;
    }

So, how can I avoid that?


I recently discovered Entity Systems and like the concept so far.
How should I make an Colission System? And how to communicate between the Systems?
I thought about just processing the Movement System and then a collide System. If in the collide System a colission is detected it would set the sprite to the next safe place.
How to make an InputComponent? I thought about making just an COmponent with a List<Input.keys, Gameaction> this is then rendered by an System which checks if and key of the COmponent is pressend and then takes the GameAction and performs and Action depending on the GameAction.


Edit PseudoCode:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
method1(){
if(checkifColissionLayer){
    generate pseudoPlayer; set values to values of Player
    update pseudoPlayer;
    Vector3 clollTile= checkColission(pseudoPlayer)   //collTile is bottom left pixel of Tile
}
if(colltile==null) player.update;  //no colission
else
adjust player position depending on Direction he moved last
so, if the player last pressed up and there is an colission -> above me is an colissionTile -> calculate nearest pixel to the colissionTile
}

Vector3 checkColission(Player p,Layer l, String term){ //l... The layer where colissionTiles are exppected;  term... the property of a Tile if is colidable
tileX,TileY = The Tile, the player is standing on

calculate for all four corners the pixel Position and then change it back to the x,y coordinate of the Tile
if the player intersects with this Tile and the Tile is not free -> return bottom left Vector of the Tile the colission happened.

}

I already read many articles about Colission Detection, but didnt undersand them. So developed this one for my own. Although I knew that its not very sophisticated.
5  Game Development / Newbie & Debugging Questions / Re: libGdx HUD/ UI + PathFinding on: 2013-09-06 17:46:25
Ahh slider, right.
But how to add there the "HP"? So draw the background/borders and then how do i fill it? I see that there is an setter for that, but how to draw em? Maybe something with the draw() and then make the batch red?
BTW, is there an Bug? If I set disabled true, I am still able to change the value.


Yeah the Algorithms is not the Problem, more libgdx.
It makes Cells into TiledMapLayers and TiledTiles into Cells and Layers int MapLayers. So, what should I take to create an easy Map for the Pathfinder? It also seems taht the TileLayers dont have the same size as the created Map, at least if the TileLayer is not so big as the map.
So, from which class can i get the stuff?

Yeah i hardcoded some sizes, but they didnt aplly. Either on the texture or on the Widget.
6  Games Center / Featured Games / Re: Blue Saga on: 2013-09-05 19:53:48
yeah, I don´t knew wif u knew it already, but there seems to be a bug with the new login.

I used "forgot password" and generated a new one, but the client always told me, that the Account has to be activated.
And now I am even not able to send a mail, I am always getting an:
Quote
Message could not be sent.Mailer Error: Could not instantiate mail function.
Error.

Would be great if someone could report it to the Admin.
7  Game Development / Newbie & Debugging Questions / Re: libGdx HUD/ UI + PathFinding on: 2013-09-05 18:04:28
Thanks, but i still dont get it.

So, i should make an Image with the full HP/MP and instantiiate it as an Image, okay.
But how then i set the pixxels inside the Bar? The only thing i can think about is taking something like a Progressbar, but yeah that wouldnt be very handy...

And is there maybe an easy way to get to the informations of an TiledMap?
Only to get to the Tilesize I do :
1  
2  
TiledMapTileLayer layer= (TiledMapTileLayer)gameMap.getLayers().get(0);
       return layer.getTileWidth();

Especially; If there is an way how to get the Tile I am standing or clicking? Currently I am just divididing the position tru the Tile Size, but its not very sophisticated...
8  Game Development / Newbie & Debugging Questions / libGdx HUD/ UI + PathFinding on: 2013-09-02 20:45:13
Hello, I would like to know how it is possible to make an Interface in libgdx? I knew the Channel from dermetfan and some Tutorials, but I don´t get it to 100%.

Is it possible to set a screen ontop of another Screen or do I have to use Stage for the UI?

Lets say I want to make an hp/mp bar what would I have todo to draw this? Currently I am doing it just like this
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
    Table playerInfo = new Table();
        //playerInfo.top().left();
       playerInfo.defaults().space(3f);
        playerInfo.pad(10f, 10f, 0, 0);
        playerInfo.debug();
        playerInfo.setPosition(0, Gdx.graphics.getHeight());
        playerInfo.size(200f, -100f);
        playerInfo.add(new Label("HP: ", skin)).size(25f, 20f);
        playerInfo.add(new Label("", skin)).size(75f, 20f).row();
        playerInfo.add(new Label("MP: ", skin)).size(25f, 20f);
        playerInfo.add(new Label("", skin)).size(75f, 20f).row();


In order to use an normal Image like in every common Game how todo? Especially I dont get how to draw the pixel, when the bar is not full. So, would it be correct to draw the bar surronding and load it then per LabelStyle? So the Background? Or just an different Class? How then i draw the red pixels according to the health?

How do i do it that it looks like an Window? ....Ah I can make an Window Class and then add to it an Table, great.
How can I make the positions better? When u look at the above example, its very annoying with the fixed sizes, is there somekind of Layout possible?

Well for Pathfinding Algorithms I need the Map data, so should i read everytime from the Tiledmap from libgdx or make an own Map Class and then fill it with an 2d Array just if the Tile is blocked or free?
9  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-19 20:36:28
Well, okay I think I will try and ask in the official forum.

Just one thing.
Im creating with my Starterclass a tileTestGame, which extends game then setting screen to GameScreen which implements Screen. The GameScreen creates the World and Worldrenderer. and in the render() of the GameScreen the render() from WorldRenderer is called.
Can there be anything wrong?
10  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-18 22:24:22
Hmm thanks.
I also thought about Spritebatches at the start, but the code seemed okay.

Maybe I am misunderstanding the answer there, but aren´t I doing that?
Everytime the render() is creating an Spritebatch and closes it. So there shouldn´t be two Batches open at the same time.? https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/maps/tiled/renderers/BatchTiledMapRenderer.java
11  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-18 19:21:50
lol, well just thought to use the newest stable one, didn´t thought that the nighly is so far ahead.

Now, using the nightly one. I am doing the same like before, but in the render:

1  
2  
3  
4  
5  
6  
7  
8  
9  
  camera.position.set(player.getX() + player.getImage().getWidth() / 2, player.getY() + player.getImage().getHeight()/2, 0);
        camera.update();
        tileMapRenderer.setView(camera);
 tileMapRenderer.render(new int[]{0});
        spriteBatch.begin();
        spriteBatch.draw(player.getImage(), player.getX(), player.getY());
        spriteBatch.end();
        //foreGround
       tileMapRenderer.render(new int[]{1});


Now nothing is displayed only my Player on a blank frame. If I throw away the camera.pos.... it´s the same as from the beginning, the map is correctly showed but (of course) no followment.

12  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-16 16:46:19
Waa, sorry I haven´t seen that somebody postet something.

Hmm okay, I haven´t known OrthogonalTiledMapRenderer yet, but I am also not able to use it, it just doesn´t find the package??? I have even no maps package.

Quote
Read the code carefully, it is not the same. Wink
Nope, still can´t see a difference. LoL

Well I made a new Project, only for loading and rendering, but it´s still the same, here is the code:

create()
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
 map = world.map;
  atlas = world.atlas;
  tileMapRenderer = new TileMapRenderer(map, atlas, 32, 32);
camera = new OrthographicCamera();
spriteBatch = new SpriteBatch();
 camera.setToOrtho(false, map.tileWidth * 20, map.tileHeight * 20);
 Texture image = new Texture(Gdx.files.internal("assets/images/player.png"));
 initInputActions();
 player = new Player(new Vector3(0, 100, 0), image);
Gdx.input.setInputProcessor(manager);


render()
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  
Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        processInput();
        player.update(Gdx.graphics.getDeltaTime());


      //to follow the player
       camera.unproject(new Vector3(player.getX(), player.getY(), 0));
        camera.position.set(player.getX(), player.getY(), 0);

        isOnMap();

        camera.update();
        spriteBatch.setProjectionMatrix(camera.combined);

        //background
       tileMapRenderer.render(camera, new int[]{0});


        spriteBatch.begin();
        spriteBatch.draw(player.getImage(), player.getX(), player.getY());
        spriteBatch.end();

        //foreGround
       tileMapRenderer.render(camera, new int[]{1});


With this it´s still starting at 60% of the x-coordinate.
Which is normal because I am setting the position Vector in 8&9 to the player position.
And it seems that the position Vector in OrthoCam is calculated from the middle of the screen (I don´t understand the Code of OrthoCam correctly).

But even if i try to change the Vector with the screen width and height or just with control structures I am not able to set it correctly.

So, even if i set the cam.pos =0 like above and i debug this it just says 0 if I move the player away from the map. Without the if it says a minus value.
13  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-11 17:02:17
Yes, thats right, I want to follow the player.
Sorry, no English native Wink

Quote
EDIT: Well now that i read your post again, the camera allways assumes a bottom/left position

Thanks, i already figured it out, but I still doesn´t understand that when i call in my render() cam.position.set(...), it seems that is then the middle of the screen and i can´t find anything related to that in https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/OrthographicCamera.java.

@Otreum
I really don´t understand your code, because its the same as mine?
I can´t get an null value because the x and y in Vector3 is public.

My Problem:
If I am doing it like that:

1  
2  
3  
4  
 camera.unproject(new Vector3(player.position.x,player.position.y,0));
       camera.position.set(player.position.x,player.position.y, 0);
camera.update();
        spriteBatch.setProjectionMatrix(camera.combined);

In the render Method, my Player is centered and the Cam also follows him, but I see this annoying blank space where no map is, like i explained in the first post. But if i do away this two rows my map starts correct at (0,0) in the frame, but (of course) I don´t follow the player then.

Now, I did many debuggins and it seems that the camera is related/mapped/linked with the map, because if i create my Player at (0,100,9) it is correctly placed on the map, but of course the map ist only at ~50% of the frame. Then when I give out my cam position it tells my at the start the x=0, yeah
When i am going with the player to the left (so to the blank space) it remains 0 if i am going to the right it goes up more than 1280.

So it seems that i have to set my map correctly at (0,0; related to the frame), but I don´t know howto do.
14  Game Development / Newbie & Debugging Questions / Re: [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-08 18:20:05
Great thank you, so I was mostly correct with my thoughts.

But^^
In the API stands that setToOrtho dividides the viewport by two and the cam is centered there, but if I give it widht or with/2, there is no difference whats showed. Why?

So I have to call unproject() everytime i click on a object, just with the coordinates the Listener delivers me?

I still want to follow my player. But, when I add in my render Method the code to follow him the blak space appears and I am not able to undo this with any if,else construct.

1  
2  
3  
4  
5  
6  
7  
 camera.unproject(new Vector3(player.position.x,player.position.y,0));
       camera.position.set(player.position.x,player.position.y, 0);
         if(camera.position.x>width) camera.position.x=width;
         else if(camera.position.x<0)camera.position.x=0;

        camera.update();
        spriteBatch.setProjectionMatrix(camera.combined);


And is this x Position now calculated from the bottom left corner or from the middle of the screen?
15  Game Development / Newbie & Debugging Questions / [LibGdx]Doesn´t understand Camera + Noob Questions on: 2013-08-07 16:58:30
Hey,
I found libGdx a few weeks a ago and I like it so far.
But now I want to load a tiled map und render it.
My Problem now is I don´t knew how camera, Renderer, Map and the Frame are playing together.
I already read nearly all Tutorials and YT Tutorials, but these are most Sidescrollers.

I just want that my left bottom of the map is also there in the Frame, but the beginning of the map is approx. at 70% on x and 30% on y in the frame, the rest is blank. And my player which, startpoint is at x=0 and y=100 is spawning at this location, but on the blank part. (Hope somebody understands what I mean)
So, how is it possible to tell the camera really to watch the map and not the frame?
I guess when i call "batch.draw(player,....) it is drawing everything on the screen, so its normal that my player is on this position.

When I do it like that:   camera.setToOrtho(false, map.tileWidth * 20, map.tileHeight * 20);
and in the render: renderer.render(camera,...)
The map is correctly beginning on (0,0) but when I add
1  
2  
camera.position.x=player.position.x-player.getImage().getWidth()/2;
    camera.position.y=player.position.y-player.getImage().getHeight()/2;
in render, the above thing is happening. So, how do I do it correctly?

What is project/unproject and combined doing?
Is this something like, I have a map with 4000x3000px and a Frame with 720p and I click now in the frame on 500,600 but I am in the map on 3000x1200 unproject is now translating to the map and project  is then doing the counterpart?
Does that mean that i have to call everytime when I click on a object unproject() and when I done with the logic project()?


I am normally using Tiled, is there an other better Editor?
Like for collision detection? I am currently making an own layer and then draw a special tile on the blocked Tiles.
But what should I do when the Tile is a side tile? So, a 32x32 but only has 7px which should be blocked, is there a way to do it? It´s a little bit annoying to block an whole Tile for that. Or half water and half grass on a Tile, how to do?
16  Games Center / Featured Games / Re: Blue Saga on: 2013-08-06 18:48:58
hey, just wanted to say that there seems to be an error.

I got 4.31 updated it and then it said "creating game" but no frame occurs, but I can see that in the procesmanager are many Java Instances.
The same now on 4.32.
No Problems before 4.31.

Any ideas?
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.

atombrot (23 views)
2014-08-19 09:29:53

Tekkerue (22 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (57 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (36 views)
2014-08-06 19:49:38

BurntPizza (66 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!