Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (701)
Games in Android Showcase (203)
games submitted by our members
Games in WIP (774)
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 ... 7
1  Game Development / Newbie & Debugging Questions / Re: Updated Android studio and libgdx now getting odd error message.. on: 2016-10-11 17:39:06
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\hp\AndroidStudioProjects\TechnoBrick\build.gradle' line: 47

* What went wrong:
A problem occurred evaluating root project 'TechnoBrick'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4 mins 10.457 secs


This is what I get when I try to gradlew clean build
2  Game Development / Newbie & Debugging Questions / Re: Updated Android studio and libgdx now getting odd error message.. on: 2016-10-11 17:10:37
I haven't tried that.  I'll try it now.  I'm definitely a newbie when it comes to gradle and all the little tools/programs
3  Game Development / Newbie & Debugging Questions / Re: Updated Android studio and libgdx now getting odd error message.. on: 2016-10-11 05:36:48
I was just using it though. I opened android studio to start coding again, which I was a couple hours before with no problems, decided to update. Restarted Android Studio, tried to run the game and got this error. Also, tried to create a new project and got the same exact error. I'm not sure what would have changed in my drivers just by updating android studio.

I appreciate the information though. This is really getting frustrating. I've been researching for a while now.
4  Game Development / Newbie & Debugging Questions / Re: Updated Android studio and libgdx now getting odd error message.. on: 2016-10-11 05:30:19
On Windows, you might get a low GL version if, during context creation, you use an unaccelerated pixel format. This means you get the default implementation of OpenGL which is version 1.1.

The solution to this is to be more careful in your pixel format selection. More information can be found at Platform_specifics:_Windows and other parts of the Wiki.

This is what's happening. By forcing software based openGL, it tells me that i'm running 1.1 which is incorrect. I don't understand what the solution part of that is telling me to do.
5  Game Development / Newbie & Debugging Questions / Re: Updated Android studio and libgdx now getting odd error message.. on: 2016-10-11 04:51:27
Not yet. I'm not really even sure where to look. I tried a game that i've been working on for a while which was fully working and I generated a new project and tried that. Right off the gate without doing anything other than setting up the DesktopLauncher i'm getting the same exception. Kind of wishing I wouldn't have updated anything now. I'm on vacation this week and was looking forward to coding tonight so i'm hoping I can figure it out lol. I'm at that critical stage where things are starting to make sense a little more and I can do more advanced things.

I tried google searching the error but there weren't many answers there either. A few similar exceptions were saying the graphics card didn't support openGL. They were a bit different though and the one game was working fine before the update.
6  Game Development / Newbie & Debugging Questions / Updated Android studio and libgdx now getting odd error message.. on: 2016-10-10 23:37:30
So I update my android studio, as well as libgdx and everything else...Now when I try to run any DesktopLauncher I get this error message...I know my graphics card supports opengl, everything was working fine before...Not sure what to do now.

1  
2  
3  
4  
5  
6  
"C:\Program Files\Android\Android Studio\jre\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files\Android\Android Studio\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Android\Android Studio\jre\jre\lib\charsets.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\cldrdata.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\dnsns.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\jaccess.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\localedata.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\nashorn.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\sunec.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\sunmscapi.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\ext\zipfs.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\jce.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\jsse.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\management-agent.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\resources.jar;C:\Program Files\Android\Android Studio\jre\jre\lib\rt.jar;C:\Users\hp\AndroidStudioProjects\TDG\desktop\build\classes\main;C:\Users\hp\AndroidStudioProjects\TDG\core\build\classes\main;C:\Users\hp\.gradle\caches\modules-2\files-2.1\com.badlogicgames.gdx\gdx\1.9.4\4b4b7962d1bc75af0438f5c81ec1010557bc9ee5\gdx-1.9.4.jar;C:\Users\hp\AndroidStudioProjects\TDG\core\build\libs\core-1.0.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\com.badlogicgames.gdx\gdx-backend-lwjgl\1.9.4\4c6c108a9dcbc07096de8594b93f9cab33856fe2\gdx-backend-lwjgl-1.9.4.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\com.badlogicgames.gdx\gdx-platform\1.9.4\8e93afecc287ab152179983fc1b5f65db4c2fa4c\gdx-platform-1.9.4-natives-desktop.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl\2.9.2\a9d80fe5935c7a9149f6584d9777cfd471f65489\lwjgl-2.9.2.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl_util\2.9.2\4b9e37300a87799856e0bd15ed81663cdb6b0947\lwjgl_util-2.9.2.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\com.badlogicgames.jlayer\jlayer\1.0.1-gdx\7cca83cec5c1b2f011362f4d85aabd71a73b049d\jlayer-1.0.1-gdx.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\org.jcraft\jorbis\0.0.17\8872d22b293e8f5d7d56ff92be966e6dc28ebdc6\jorbis-0.0.17.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl-platform\2.9.2\510c7d317f5e9e700b9cfaac5fd38bdebf0702e0\lwjgl-platform-2.9.2-natives-windows.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl-platform\2.9.2\d276cdf61fe2b516c7b7f4aa1b8dea91dbdc8d56\lwjgl-platform-2.9.2-natives-linux.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\org.lwjgl.lwjgl\lwjgl-platform\2.9.2\d55b46b40b40249d627a83a7f7f22649709d70c3\lwjgl-platform-2.9.2-natives-osx.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput\2.0.5\39c7796b469a600f72380316f6b1f11db6c2c7c4\jinput-2.0.5.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\net.java.jutils\jutils\1.0.0\e12fe1fda814bd348c1579329c86943d2cd3c6a6\jutils-1.0.0.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput-platform\2.0.5\7ff832a6eb9ab6a767f1ade2b548092d0fa64795\jinput-platform-2.0.5-natives-linux.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput-platform\2.0.5\385ee093e01f587f30ee1c8a2ee7d408fd732e16\jinput-platform-2.0.5-natives-windows.jar;C:\Users\hp\.gradle\caches\modules-2\files-2.1\net.java.jinput\jinput-platform\2.0.5\53f9c919f34d2ca9de8c51fc4e1e8282029a9232\jinput-platform-2.0.5-natives-osx.jar;C:\Users\hp\AndroidStudioProjects\TDG\desktop\build\libs\desktop-1.0.jar;C:\Program Files\Android\Android Studio\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.psillicoder.tdg.desktop.DesktopLauncher
Exception in thread "LWJGL Application" java.lang.NullPointerException
   at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.createDisplayPixelFormat(LwjglGraphics.java:322)
   at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:216)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:142)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:124)
7  Game Development / Newbie & Debugging Questions / Re: Collisions with rectangles and circles on: 2016-09-19 01:55:15
Here is a video of it in action. I'm using camstudio and it made the video extremely choppy. The movement in game is smooth..but the collisions aren't working the best.
<a href="http://www.youtube.com/v/G9oJYPtMpeg?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/G9oJYPtMpeg?version=3&amp;hl=en_US&amp;start=</a>
8  Game Development / Newbie & Debugging Questions / Directional collisions with rectangles and circles on: 2016-09-19 00:45:37
So taking advice from fellow jgo'ers I ditched the Box2d for my breakout clone. I'm just trying to learn and further my experience with java and libgdx. I've setup a simple basic collision system which uses the center of the ball to determine which side the ball is hitting the brick on. It still doesn't seem right though. It does work, but some of the collisions mess up as in going through bricks sometimes, bouncing the wrong direction, or sliding through the brick. The same happens with my ball and paddle. I know there are many ways to do this and i've done a bit of research on it but i'm having a hard time determining which to use and how to implement some of them.

I'll include my collision code. I have a lot of refactoring to do for the whole project really, but i'll post the link to my git as well.

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  
public void CheckCollision() {
        if (playerBall.getRect().overlaps(playerPaddle.getRect())) {
            int first = (int) playerPaddle.getPos().x;
            int second = (int) playerPaddle.getPos().x + 16;
            int third = (int) playerPaddle.getPos().x + 32;
            int fourth = (int) playerPaddle.getPos().x + 48;


            if (playerBall.getPos().x + 16 > first && playerBall.getPos().x < second) {
                playerBall.setSpeed(new Vector2(playerBall.getSpeed().x * -1, playerBall.getSpeed().y * -1));
            }

            if (playerBall.getPos().x > second && playerBall.getPos().x < third) {
                playerBall.setSpeed(new Vector2(playerBall.getSpeed().x, playerBall.getSpeed().y * -1));
            }

            if (playerBall.getPos().x > third && playerBall.getPos().x < fourth) {
                playerBall.setSpeed(new Vector2(playerBall.getSpeed().x, playerBall.getSpeed().y * -1));
            }

            if (playerBall.getPos().x > fourth && playerBall.getPos().x < third + 16) {
                playerBall.setSpeed(new Vector2(playerBall.getSpeed().x * -1, playerBall.getSpeed().y * -1));
            }
        }

        for (Brick tBrick : mManager.getBricks()) {
            /*
            if (tBrick.isAlive == false) {
                mManager.destroyBrick(tBrick.getRect(),mManager.getBricks().indexOf(tBrick));
            }
            */

            if (playerBall.getRect().overlaps(tBrick.getRect())) {
                System.out.println("Collision!");
                int ballCenterX = (int)playerBall.getRect().x + (int)playerBall.getRect().getWidth() / 2;
                int ballCenterY = (int)playerBall.getRect().y + (int)playerBall.getRect().getHeight() / 2;
               

                Rectangle brickTopLeft = new Rectangle(
                        tBrick.getRect().x,
                        tBrick.getRect().y + tBrick.getRect().getHeight() / 2,
                        tBrick.getRect().getWidth(),
                        tBrick.getRect().getHeight()
                        );
               
                Rectangle brickTopRight = new Rectangle(
                        tBrick.getRect().x + tBrick.getRect().getWidth() / 2,
                        tBrick.getRect().y + tBrick.getRect().getHeight() / 2,
                        tBrick.getRect().getWidth() / 2,
                        tBrick.getRect().getHeight() / 2
                );

                Rectangle brickBottomLeft = new Rectangle(
                        tBrick.getRect().x,
                        tBrick.getRect().y,
                        tBrick.getRect().getWidth() / 2,
                        tBrick.getRect().getHeight() / 2
                );

                Rectangle brickBottomRight = new Rectangle(
                        tBrick.getRect().x + tBrick.getRect().getWidth() / 2,
                        tBrick.getRect().y,
                        tBrick.getRect().getWidth() / 2,
                        tBrick.getRect().getHeight() / 2
                );

                //Ball collides with top left of brick
                if (playerBall.getRect().overlaps(brickTopLeft)) {
                    if (ballCenterX > brickTopLeft.x && ballCenterY > brickTopLeft.y + brickTopLeft.height) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x, playerBall.getSpeed().y * -1));
                        tBrick.isAlive = false;
                        continue;
                    } else if (ballCenterY < brickTopLeft.y + brickTopLeft.height && ballCenterX < brickTopLeft.x) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x * -1, playerBall.getSpeed().y));
                        tBrick.isAlive = false;
                        continue;
                    }
                }

                //Ball collides with top right of brick
                if (playerBall.getRect().overlaps(brickTopRight)) {
                    if (ballCenterX < brickTopRight.x + brickTopRight.width && ballCenterY > brickTopRight.y + brickTopRight.height) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x, playerBall.getSpeed().y * -1));
                        tBrick.isAlive = false;
                        continue;
                    }else if (ballCenterY < brickTopRight.y + brickTopRight.height && ballCenterX > brickTopRight.x + brickTopRight.width) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x * -1, playerBall.getSpeed().y));
                        tBrick.isAlive = false;
                        continue;
                    }
                }
                //Ball collides with bottom left of brick
                if (playerBall.getRect().overlaps(brickBottomLeft)) {
                    if (ballCenterX > brickBottomLeft.x && ballCenterY < brickBottomLeft.y) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x,playerBall.getSpeed().y * -1));
                        tBrick.isAlive = false;
                        continue;
                    }else if (ballCenterX < brickBottomLeft.x && ballCenterY > brickBottomLeft.y) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x * -1, playerBall.getSpeed().y));
                        tBrick.isAlive = false;
                        continue;
                    }
                }

                //Ball collides with bottom right of brick
                if (playerBall.getRect().overlaps(brickBottomRight)) {
                    if (ballCenterX < brickBottomRight.x + brickBottomRight.width && ballCenterY < brickBottomRight.y) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x, playerBall.getSpeed().y * - 1));
                        tBrick.isAlive = false;
                        continue;
                    }else if (ballCenterX > brickBottomRight.x + brickBottomRight.width && ballCenterY > brickBottomRight.y) {
                        playerBall.setSpeed(new Vector2(playerBall.getSpeed().x * -1, playerBall.getSpeed().y));
                        tBrick.isAlive = false;
                        continue;
                    }
                }

                }
            }
        mManager.bricksToDestroy();

        }


Github:
https://github.com/Jman9912/TechnoBrick


Thanks for any suggestions, advice, or tips!
9  Game Development / Newbie & Debugging Questions / Re: Issues with Box2d on: 2016-09-11 21:20:42
Yeah it's been fun playing around with it.  There are definitely a lot of benefits.  Hell,  I'm just now getting into collision detection  with it among other things.  I'm thinking about ripping the box2d stuff out though so I can make progress a little quicker with learning java and libgdx.
10  Game Development / Newbie & Debugging Questions / Re: Issues with Box2d on: 2016-09-11 14:08:46
Now I'm second guessing whether I should start over or not.  Haha.  I'm just trying to get over this learning curve.  I've been messing with it off and on for long enough,  I should be a pro.  But I'm not lol.  I know the basics.
11  Game Development / Newbie & Debugging Questions / Re: Issues with Box2d on: 2016-09-09 17:40:08
I was really just using box2d to learn how to use it.  But I've made a breakout clone before without box2d and had issues getting the angles at which the ball bounced correct and things like that. 
12  Game Development / Newbie & Debugging Questions / Issues with Box2d on: 2016-09-09 03:37:21
Okay so this is probably a pretty trivial question. I've been playing around with Box2d and libgdx for a little while now and i'm making a breakout type game. I've got my world setup, i'm using Tiled for the brick placement and all that seems to work...

The problem i'm having is with the paddle. I originally had set the paddle type to a Kinematic body as it doesn't need to be affected by gravity or anything like that. Everything seemed to be good. I think I had an issue with getting it to move at first if I recall correctly, but was able to figure that out. The bricks, of course, are Dynamic bodies. I also have unbreakable bricks on the sides to keep the ball and paddle in bounds...The only problem is, the paddle goes straight through the border bricks and does not collide or stop it...I could check for bounds and keep the paddle in bounds that way..But that wouldn't really solve my problems.

I tried setting the paddle to dynamic and the bricks stopped the paddle from moving when they touched...The problem here, is that when the ball hits the paddle, it moves it down from the force of the ball. So when the left or right keys are pressed, I set the paddle to dynamic and then directly back to kinematic...This solved the problem with the paddle falling when the ball hit it, but it still goes through the border bricks...I've searched and searched but can't seem to figure out the best way to do this.

I've been playing around with libgdx off and on for a while now. I should be a pro by now but I still have a lot to learn as I haven't stuck with it. I've been focusing more on it lately and trying to learn everything I can. I still have a lot of stuff to learn...I'm a bit overwhelmed by this already with the Box2d stuff. I'm also having a bit of trouble setting it up so that the ball behaves correctly...Right now, it just bounces a couple times on the paddle but doesn't have enough velocity to hit the bricks. Not to mention issues with getting collision detection set up..Lol. I have found many tutorials and documentation as far as box2d collision so i'm not worried about that issue as much. I do, however, need to structure my project a little better.   I'm working on setting up the project now on Github and i'll show you the embarrassing code haha.

Any help is greatly appreciated guys. I enjoy coding very much and am desperately trying to stick with it this time, i'm just a little frustrated.

Git:
https://github.com/Jman9912/BG

*EDIT*
Edited to add Git url. The code is extremely messy. I'm learning as i'm going and trying to refactor and clean it up a bit. Thanks again guys! Any information or feedback is appreciated!
13  Discussions / General Discussions / Re: Which IDE do you use for linux? on: 2015-11-09 02:22:24
I installed Android Studio. I like it so far. My only question is, is it sufficient for non android programming?
14  Discussions / General Discussions / Re: Which IDE do you use for linux? on: 2015-11-08 22:07:17
I'm not familiar with IntelliJ. I'll check that out. I may just install Eclipse and Android Studio so I can try them both. I guess I was hoping for another IDE that I wasn't aware of that was great. Lol. Wishful thinking I guess. haha.
15  Discussions / General Discussions / Re: Which IDE do you use for linux? on: 2015-11-08 21:52:36
Yeah, I mean, I got use to using Eclipse...So i'm not really opposed to it. I just didn't know if there were any other superior options. I've heard a lot about Android Studio and I like the way it's set up...But I want to do more than just Android apps...So I don't know if that would really suffice for what I need. I'm still fairly new to Linux. I've been using it for about 6 months, so I know the basics..But I still have a lot to learn. The same with Java and LibGDX. I've been using it off and on for about 2 years.
16  Discussions / General Discussions / Which IDE do you use for linux? on: 2015-11-08 21:41:19
Hey guys, i've recently made the switch to using linux (Well, Ubuntu) and i'm working on getting everything set up now. When I was on Windows, I used Eclipse and LibGDX. From doing a bit of research, I see there are a few different options...

I'm having a hard time choosing and making sure everything is going to work correctly. What do you guys use? I could still use Eclipse from what I understand, but I don't know if that would be the best option for me. I have experience with eclipse, but i'm not really sure I like it that much. There are too many options for which I only need 5% of them..The rest is for other tasks....

I also read something about using android studio. I do wish to make android apps as well as deploy my games to android...But, again, i'm not sure if that would really be the best option...

So I just want to hear you guy's opinions and what you use.

Thanks!
17  Game Development / Newbie & Debugging Questions / Re: LibGDX Center player on tile half the size.. on: 2015-05-21 00:43:55
I use free movement. I think there is a better way to do it. Right now it basically adds player speed to x or y depending on key pressed. Then to get the tile x,y, of course I just divide by tilesize. I figured out why it wasn't centering but I'm still trying to improve my movement.

I appreciate the attempt pocket but all that would do is draw the sprite without centering it or doing anything to it at all.
18  Game Development / Newbie & Debugging Questions / Re: LibGDX Center player on tile half the size.. on: 2015-05-19 22:11:49
I don't that really explained my problem..I know how to center it in the tile..I think the problem is my movement system is flawed.
19  Game Development / Newbie & Debugging Questions / LibGDX Center player on tile half the size.. on: 2015-05-19 19:50:11
I refactored my tiled game to use 32x32 tiles instead of 16x16 tiles as I am using the LPC assets for tiles and sprites..The sprite characters are gridded out into 64x64 cells for animation....The player is a bit smaller...

Anyways, i've got the grid system set up and i've got a square highlighting the cell...But no matter what I do, I can't get the player to center into the tile...

Here is my simplified render call..

1  
batch.draw(downRegion, playerX - (playerWidth / 2 / 32f), playerY,playerWidth/32f, playerHeight/32f);   


Whereas, playerWidth and playerHeight = 64;

Here is what I get...

20  Game Development / Newbie & Debugging Questions / Re: LibGDX World units and width and height.. on: 2015-05-12 17:35:33
Yeah, not too bad I guess. Now just to figure out the movement system. The character moves around but freely. The plan is to center my sprite and make the base occupy one tile and use that to move...then it shouldn't be too hard for collision detection.
21  Game Development / Newbie & Debugging Questions / Re: LibGDX World units and width and height.. on: 2015-05-12 04:17:58
Yeah, I wrote that quickly while I was playing around with the texture regions and forgot. Already fixed.

I also just divided the width and height by tile size, but do I need to do that to everything? Or is there a better way?
22  Game Development / Newbie & Debugging Questions / LibGDX World units and width and height.. on: 2015-05-11 00:46:04
I've got a tiledmap rendered and i'm rendering the player sprite over it...When I call my player.draw() it draws a texture region of the player specifying x,y,width,height....which is good, it's rendering the correct place and moving around on the tiles...But the width and height are incorrect...My tiles are 16x16 and my player sprite is 24x32...so i'm getting a really blown up player sprite...How can I fix this?

This is my gamescreen 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  
package com.psillicoder.farmGame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TmxMapLoader;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;

public class gameScreen implements Screen {

   gameClass game;
   
   
   
   private OrthographicCamera camera;
   private OrthogonalTiledMapRenderer renderer;
   private TiledMap map;
   private PlayerClass player;
   
   
   SpriteBatch batch;
   SpriteBatch guibatch;
   
   BitmapFont font;
   
   
   float unitScale = 1/16f;
   int tileSize = 16;
   
   
   
    public gameScreen(gameClass game) {
       this.game = game;
       
     
    }
   
    @Override
    public void render(float delta) {
       
       Gdx.gl.glClearColor(0, 0, 0, 1);
         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
         
     
         //camera.position.x = player.getPos().x - (Gdx.graphics.getWidth() / 2);
         //camera.position.y = player.getPos().y - (Gdx.graphics.getHeight() / 2);
         
         camera.position.x = player.getPos().x;
         camera.position.y = player.getPos().y;
         
         camera.update();
         
         
         batch.setProjectionMatrix(camera.combined);
         
         renderer.setView(camera);
         renderer.render();
         
         
         
         batch.begin();
         player.render(batch);  
         batch.end();
         
         guibatch.begin();
         font.draw(guibatch, "FPS: " + Gdx.graphics.getFramesPerSecond() , 10, Gdx.graphics.getHeight() - 10);
         font.draw(guibatch, "Player X: " + player.getPos().x + " | Player Y: " + player.getPos().y , 10, Gdx.graphics.getHeight() - 20);
         guibatch.end();

      processInput();
     
       
    }
   
    @Override
    public void resize(int width, int height) {
       
    }
   
    @Override
    public void show() {
       
       map = new TmxMapLoader().load("tdmap1.tmx");
       
       renderer = new OrthogonalTiledMapRenderer(map,unitScale);
     
       
       font = new BitmapFont();
       
       camera = new OrthographicCamera();
       
       camera.setToOrtho(false,40,40);
       renderer.setView(camera);
       camera.update();
       
       
       
       batch = new SpriteBatch();
       guibatch = new SpriteBatch();
       player = new PlayerClass(30, 30);
         
    }
   
   
   
    public void processInput() {
       if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) player.setPos((int)player.getPos().x - player.getSpeed(),(int)player.getPos().y);
       
       if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) player.setPos((int)player.getPos().x + player.getSpeed(),(int)player.getPos().y);
       
       if (Gdx.input.isKeyPressed(Input.Keys.UP)) player.setPos((int)player.getPos().x,(int)player.getPos().y + player.getSpeed());
       
       if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) player.setPos((int)player.getPos().x,(int)player.getPos().y - player.getSpeed());
       
    }
   
    @Override
    public void hide() {
      dispose();
    }
   
    @Override
    public void pause() {
       
    }
   
    @Override
    public void resume() {
       
    }
   
    @Override
    public void dispose() {
       System.out.println("Disposed");
       batch.dispose();
       renderer.dispose();
       map.dispose();
       player.dispose();
       font.dispose();
    }
}


and my player class render method:
1  
2  
3  
4  
5  
6  
   public void render(SpriteBatch batch) {
     
      batch.draw(downRegion, playerX, playerY);
   
   }
   



Also, i'm confused as how camera.setToOrtho works. I'm using 40 as width and height and it seems to work okay...From what I understand, this is how many tiles I want to show on the screen?
23  Game Development / Newbie & Debugging Questions / Re: Libgdx TiledMapRenderer on: 2015-05-08 03:28:28
Okay I think my question is, how do I set my player up to move on my level coordinates instead of screen coordinates? I know libgdx does this for you by setting the unit scale..but when I call the players render function is only drawing in screen coordinates.. I'm confused about how and what libgdx does for you. I want to use lwjgl but I just don't think I'm experienced enough and I like having the sprite batch and stuff set up for me...I don't use libgdx's stage or actors or anything like that.
24  Game Development / Newbie & Debugging Questions / Libgdx TiledMapRenderer on: 2015-05-06 21:06:45
So I'm trying to get this whole level system down and I'm a bit confused.  The tiledmaprenderer does most of the work for me,  but I still need to set up my grid system and figure out my player movement... I know I can call each tile by using Cell but it doesn't seem to work the way I need it to.. My levels are 100x100..I want to be able to reference each tile by using the xy coordinates like 24,65, etc.  But I also need the player to be positioned on those coordinates...the player is 24x32 (which I may change this anyway)

I'm having a hard time figuring out how to use the level coordinates with the player and having them in unison... If this makes sense..

I'll elaborate more when I get off work,  sorry if it doesn't make sense... Just thinking about it during my downtime at work.
25  Game Development / Newbie & Debugging Questions / Re: Having trouble with the screen class.. on: 2015-04-29 03:17:38
........

Wow, i'm an idiot haha. I don't know how I missed that. I knew it was something dumb. I appreciate it! I guess I need to brush up on everything.
26  Game Development / Newbie & Debugging Questions / Re: Having trouble with the screen class.. on: 2015-04-29 03:08:22
Ah..I see what you're saying..I forgot more than I thought...so I should be passing the objects through to the render class? That doesn't seem right...It could get pretty lengthy.
27  Game Development / Newbie & Debugging Questions / Having trouble with the screen class.. on: 2015-04-29 02:39:50
I'm just getting back into this after a long break so bare with me...Basically, i'm making a 2d tiled game and having a big issue off gate...I'm implementing Screens with libgdx and basically, I immediately set it to the gamescreen and render tiles...I'm getting a NPE on my camera and my renderer in the render method...I think it's calling the render class before calling create() where the objects are created...I made a post over at stack exchange with the code:

http://gamedev.stackexchange.com/questions/99182/java-libgdx-game-screens-and-rendering-tile-map


I know it's gotta be something simple that i'm just missing..I just can't find it.
28  Game Development / Newbie & Debugging Questions / Re: Tower Defense pathfinding? on: 2014-11-23 22:32:12
Yeah, there is some good stuff on there! Thanks.

I'm rewriting this now to use tiled instead..It's too hard to manage in the array...My question is, how do I set up a grid to use a* with tiled? I tried this before and was unsuccessful. That's part of the reason, I decided to do it from scratch as I would already have a grid..I know it's something simple, but I don't see it.
29  Game Development / Newbie & Debugging Questions / Re: Tower Defense pathfinding? on: 2014-11-23 21:48:26
That is awesome! Thank you Gibbo. A simple search probably would have found that for me! I didn't think about searching for tower defense specifics.

I agree, CC. I just needed some reassurance!

I just hope I can stick with this without getting bored. I'm only developing it for the experience, but I need to finish something completely so I can move forward to the games I have been planning for months.
30  Game Development / Newbie & Debugging Questions / Re: Tower Defense pathfinding? on: 2014-11-23 21:00:12
That's what I'm going for. Just trying to figure out the best way to calculate the pathfinding..there aren't many obstacles and it's just from A to B, so I feel like a* might be too much..

This is the first time I've ever done any type of pathfinding.
Pages: [1] 2 3 ... 7
 
ral0r2 (213 views)
2016-11-23 16:08:26

ClaasJG (354 views)
2016-11-10 17:36:32

CoffeeChemist (446 views)
2016-11-05 00:46:53

jay4842 (499 views)
2016-11-01 19:04:52

theagentd (508 views)
2016-10-24 17:51:53

theagentd (499 views)
2016-10-24 17:50:08

theagentd (454 views)
2016-10-24 17:43:15

CommanderKeith (453 views)
2016-10-22 15:22:05

Roquen (424 views)
2016-10-22 01:57:43

Roquen (310 views)
2016-10-17 12:09:13
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21
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!