Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 4
1  Game Development / Newbie & Debugging Questions / Libgdx Coordinates to Box2D using Viewport on: 2014-10-13 07:09:19
I have a Body that I want to move towards the touch position (screenX, screenY). My current method for doing this works, but only for when the screen resolution is the same as the viewport width and height.

1  
2  
3  
4  
5  
@Override
   public boolean touchUp(int screenX, int screenY, int pointer, int button) {
      Vector3 touch = camera.unproject(new Vector3(screenX, screenY, 0));
      Vector2 direction = new Vector2((touch.x - currentBody.getPosition().x), (touch.y - currentBody.getPosition().y));
//normalise, scale etc...


I think the part I'm stuck on is converting the camera coordinate to the Box2D coordinate. When I resize the window, the Body doesn't move directly at the mouse, it's a bit off. I'm using a FitViewport with a virtual resolution of 640x1136
2  Game Development / Newbie & Debugging Questions / Re: Box2D Circle works but not pentagon Polygon? on: 2014-10-12 11:01:17
Thank you very much, that fixed it Cheesy
3  Games Center / Showcase / Re: Bubblution on: 2014-10-12 09:34:24
Thanks for the suggestion, the video is being rendered and will be uploaded shortly.

If anyone has an android device and doesn't mind, could you please do me a favour? I ask this because I don't have an android device, and I can't sign in from the emulator. I've implemented leaderboards using Google Play Services, but I haven't actually been able to test it. Would someone be able to test it for me? I just need you to see whether you can submit a score, and view the leaderboard. Your score should be submitted automatically at the end of a game.
4  Game Development / Newbie & Debugging Questions / Re: Box2D Circle works but not pentagon Polygon? on: 2014-10-11 01:49:27
Well, there are no errors, the Fixture just isn't being created. Not sure how else I can describe the problem.

Edit: Instead of trying to fix this problem, it would also help if someone told me how to create a pentagon fixture given the centre and radius.
5  Discussions / Miscellaneous Topics / Re: Is drinking half a bottle of vodka safe? on: 2014-10-10 06:06:07
Cheers for all the replies everyone. I told my friend what you guys said, and he called all of you losers (jokingly of course).
6  Game Development / Newbie & Debugging Questions / Re: Box2D Circle works but not pentagon Polygon? on: 2014-10-10 03:49:00
Good point, I've corrected that but the pentagons still aren't coming up properly
7  Games Center / Showcase / Bubblution on: 2014-10-10 01:48:10
This is my first properly completed game, available on Google Play: https://play.google.com/store/apps/details?id=com.rayexar.monsterblaster.android



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

Continuous side-scrolling shooter with weapon upgrades and powerups, and different types of enemies. Made using Libgdx.

I'd really appreciate any feedback, constructive criticism and suggestions. If anyone provides ideas that I use, you'll be credited.
8  Game Development / Newbie & Debugging Questions / Re: I'm desperate on: 2014-10-09 12:44:37
It probably would help if you're already familiar with Java before doing game dev, but I went into game development before I had a sound understanding of the basics. I picked up bits and pieces of Java as I learned game development, looking things up as I went. I still remember creating my own swing applications and Java2D games without knowing what "extends" and @Override public void run() meant, and I struggled to understand even after looking up tutorials.
9  Discussions / Miscellaneous Topics / Re: Is drinking half a bottle of vodka safe? on: 2014-10-09 12:38:20
Thanks guys, I'll just stick to a few shots, 1/4 bottle max. You guys may have saved my life because I probably would have done it if I didn't post here Cheesy

That is not called a "friend", it is called an "enemy". Or an "asshole".

He's a good friend, this is just a fun challenge Tongue
10  Discussions / Miscellaneous Topics / Is drinking half a bottle of vodka safe? on: 2014-10-09 11:21:18
Well basically my friend is forcing me to drink half a bottle of vodka. I don't want to black out or get extremely drunk or hungover. I don't drink very often.

Any experienced vodka drinkers here? I just want to know whether half a bottle is too much, and if so what's the maximum safe amount?
11  Game Development / Newbie & Debugging Questions / Box2D Circle works but not pentagon Polygon? on: 2014-10-09 10:57:07
I honestly have no idea why, but this code I'm using to create a Polygon Shape doesn't seem to work. I'm trying to create a regular pentagon given the centre and radius. Circle and Box shapes work.

Here's the code:

Circle, which works:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
Body createCircle(float centreX, float centreY, float radius, BodyType bodyType) {
      BodyDef bodyDef = new BodyDef();
      bodyDef.type = bodyType;
      bodyDef.position.set(centreX, centreY);

      Body body = world.createBody(bodyDef);

      CircleShape circle = new CircleShape();
      circle.setRadius(radius);

      FixtureDef fixtureDef = new FixtureDef();
      fixtureDef.shape = circle;
      fixtureDef.density = 0.5f;
      fixtureDef.friction = 0.4f;
      fixtureDef.restitution = 1f;

      body.createFixture(fixtureDef);

      circle.dispose();
     
      return body;
   }
   


Pentagon, doesn't work:
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  
   Body createPentagon(float centreX, float centreY, float radius, BodyType bodyType) {
      BodyDef bodyDef = new BodyDef();
      bodyDef.type = bodyType;
      bodyDef.position.set(centreX, centreY);
     
      Body body = world.createBody(bodyDef);
     
      PolygonShape shape = new PolygonShape();
      Vector2[] vertices = new Vector2[5];
     
      for(int i=0; i<=4; i++) {
         vertices[i] = new Vector2(centreX + (float) (radius*Math.cos(i*72)), (float) (centreY + radius*Math.sin(i*72)));
      }
     
      shape.set(vertices);
     
      FixtureDef fixtureDef = new FixtureDef();
      fixtureDef.shape = shape;
      fixtureDef.density = 0.5f;
      fixtureDef.friction = 0.4f;
      fixtureDef.restitution = 1f;

      body.createFixture(fixtureDef);
     
      shape.dispose();
     
      return body;
   }


Any ideas? Is it the maths I'm using wrong?
12  Game Development / Newbie & Debugging Questions / Re: I'm desperate on: 2014-10-09 02:27:28
I don't think you can easily pick up the skills in just a few tutorials. If you have the mindset that you can quickly learn how to make games, then move on to make a big, awesome game, you'll end up getting desperate. I didn't completely understand everything when I first started by following tutorials, but I tried many different tutorials which explained things differently, and that helped.

I used these tutorials for Java2D game development: https://www.youtube.com/user/Ulixava/playlists

Then moved onto Slick 2D: https://www.youtube.com/watch?v=AXNDBQfCd08

And finally Libgdx: https://www.youtube.com/playlist?list=PLXY8okVWvwZ0JOwHiH1TntAdq-UDPnC2L and https://www.youtube.com/playlist?list=PLXY8okVWvwZ0qmqSBhOtqYRjzWtUCWylb

I understand your frustration when you can't keep up with the tutorial, but just stick to it and you'll get it eventually. It does take time. What I think helped me the most was, after learning from tutorials, making my own game (different from the one in the tutorial) from scratch, applying what I learned without copying the code.

It also helped that I had a friend who's good at programming, and useful forums like this one Tongue, to ask when something didn't make sense.
13  Game Development / Newbie & Debugging Questions / Re: Generate Platforms (Rectangles) Randomly on: 2014-10-08 10:30:48
That was very useful, thank you very much!
14  Discussions / General Discussions / Re: What is wrong with reinventing the wheel? on: 2014-10-08 06:57:34
I just find it boring using other people's stuff when you can make your own version... It also makes me happier knowing that when I finish a game, I have made the game engine and the launcher creator...

I know what you mean, it is enjoyable and satisfying knowing that you made more of it yourself.
But why don't you create your own computer from parts you make from scratch, rather than just use "other people's stuff"? Then create your own programming language and operating system?
15  Game Development / Game Mechanics / [Libgdx] Move Box2D Body on Swipe on: 2014-10-07 01:31:27
I have a Box2d Body with a fixture attached, and I would like to move the Body by swiping on the screen. The Body should move according to the direction and "speed" of the swipe, with a faster/longer swipe applying a larger force on the Body.

How would you implement this in Libgdx? I'm stuck on the Input aspect (what to do with the InputProcessor).

Update: Well I've just tried MouseJoints and they're not what I'm looking for. I've decided to try applying an impulse to the body on touchDragged, but now I need a way to limit the velocity of a Body so that it never goes above a maximum.

If I check whether the velocity exceeds the maximum before applying an impulse, after the applied impulse, the velocity can still go above the max.
16  Game Development / Newbie & Debugging Questions / Generate Platforms (Rectangles) Randomly on: 2014-10-05 07:23:24
Hey everyone,

I'm trying to figure out how to generate platforms so that they would be set out in a way like this:



Imagine a platformer where the player should be able to "run" and "jump" onto all of the platforms.

I've tried generating a random boolean every frame with a  certain chance that it would be true, and if true, create a rectangle of random length (in a range of course), as the x-position increases across the map. This didn't work because at times there were platforms really close together, and sometimes it would be impossible to get from one side of the map to another (platforms too far apart).

The

Could someone suggest an algorithm I could use? I need to know "when" and "where" to create a platform, and how to generate the positions and sizes.

Other info which may be relevant, I'm using Box2D, the player is a 2x2m box.

Thanks
17  Game Development / Newbie & Debugging Questions / Re: LibGDX - Scrolling Texture Y-Axis on: 2014-10-02 09:09:10
I did this recently:

Render one image at y-position 0, and another at y-position Gdx.graphics.getHeight(). Every frame, for each texture, subtract an amount, scrollRate*Gdx.graphics.getDeltaTime() from the y-pos of each texture. Every frame, check whether the y-position of the bottom texture is equal to or less than -(negative) screenHeight , and if so, set it equal to screenHeight.
18  Game Development / Newbie & Debugging Questions / Boolean Methods in Libgdx InputProcessor and GestureListener on: 2014-09-30 03:58:33
I haven't really thought about this before because I've had no problems with the Libgdx InputProcessor or GestureListener, but what is the purpose of returning a boolean in, for example, the touchDown and fling methods?

1  
2  
3  
4  
5  
6  
public class InputHandler implements InputProcessor, GestureListener {

   @Override
   public boolean touchDown(float x, float y, int pointer, int button) {
      return false;
   }


In this case, touchDown returns false. Changing it to return true doesn't seem to have any effect. Could someone please explain this?
19  Game Development / Newbie & Debugging Questions / Re: LibGDX - Coordinate Issue with Gdx.input.istouched on: 2014-09-29 05:53:26
Is the rectangle being created and rendered at a different position on the screen as the image? Try rendering the rectangle on the screen to see it's position.

Did you set the projection matrix of the spritebatch and shaperenderer correctly? You should post your code so we can see, but I have a feeling you don't have the touch coordinates and screen coordinates set properly for the different screen resolution your android device might have.
20  Game Development / Newbie & Debugging Questions / Re: LibGDX Eclipse Setup Issues on: 2014-09-25 11:53:44
With the android errors, I got it working by exporting as an APK, then running that on an emulator or device.
21  Game Development / Newbie & Debugging Questions / Re: How do I create a good play button in libGDX? on: 2014-09-25 11:40:18
Do you want the button to come up after one second? If so, do this.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
boolean taskUpScheduled = false;
if(btnPressed == true){
            y = y + 4;
            btnPressed = false;
         }else if(btnPressed == false && !taskUpScheduled) {
taskUpScheduled = true;
           Timer.schedule(new Task() {
           
            @Override
            public void run() {
                y = 800 / 2 - 188 / 2;
taskUpScheduled = false;
            }
         }, 1);
         }


If you mean you want to set the screen after a second, you can do Timer.schedule(Timer.task, time delay), and set the screen in the Timer.task. Sorry I can't type the code properly right now because I'm on an iPad. But basically, just use Timer.schedule when you want to run some code after a time delay.
22  Discussions / Miscellaneous Topics / Re: I'm scared of Unity on: 2014-09-24 08:02:47
Some people work hard creating programs from pure assembly or machine code, while you get to use a programming language which is easier to use and has more tools.

Then why just stick with pure java, or any other programming language for that matter? You still get more control, flexibility and potential. If you make games because you want a final product that you can show off or sell, do whatever is easiest for that goal. I still think there are many advantages using Java compared to unity depending on what you want to do.

Personally I rather use Java + Libgdx over Unity/Game maker because I find it more enjoyable and still able to produce the same results. Besides, Unity has a pretty steep learning curve; people who use it also would have worked hard to learn it. And by the way, with PHP, I think it's starting to become out of date, being replaced with other web frameworks like Ruby on Rails.

BTW I also have a feeling you like programming because it makes you feel like you have more skill, and other people find it more impressive (nothing wrong with that of course Smiley).
23  Discussions / General Discussions / Re: Are Java applets really "dead" for indie developers? on: 2014-09-22 06:05:34
Funorb (http://www.funorb.com/) is pretty successful and it's games are applets.
24  Discussions / Miscellaneous Topics / Marmalade and Cocos2d-x on: 2014-09-19 09:12:11
I've just come across this: https://www.madewithmarmalade.com/ and it looks amazing.
https://www.youtube.com/watch?v=NWOKVCbB8JE

Looks like it's got all the features Libgdx has, but with more successful commercial games out there made with Marmalade.

My friend told me about this today: http://www.cocos2d-x.org/ which also looks good.

What do you guys think? Better than Libgdx? Other alternatives to these frameworks out there?

Personally I'm fine with Libgdx, but it seems like there's a lack of tutorials on integrating platform specific services such as Admob and Game Center (iOS). I got everything working eventually, but after all that, I really don't want to experience all that headache again, so I'm looking for an alternative.
25  Game Development / Newbie & Debugging Questions / Re: Game Doesn't Start on Android Emulator on: 2014-09-19 04:33:12
It worked in the end. Still comes up with the error message, but the game runs fine afterwards. It also runs on proper android devices Smiley

I had to turn GPU on and snapshot off in the emulator settings.
26  Game Development / Newbie & Debugging Questions / Re: iOS and Android Leaderboards and Ad Integration on: 2014-09-17 11:33:54
I'm following this tutorial: http://www.agur.pl/blog/implementing-admob-for-libgdx/

and I'm stuck at the bit where AdRequests are created. In the tutorial, they do this:

1  
2  
AdRequest adRequest = new AdRequest();
        AdRequest fadReq = new AdRequest();


however I can't create an AdRequest, as eclipse says it requires a Builder parsed into the constructor. Any ideas on how this is done?

UPDATE: This solved the problem: http://stackoverflow.com/questions/25123447/admob-new-adrequest-unrecognized-by-eclipse
27  Game Development / Newbie & Debugging Questions / Game Doesn't Start on Android Emulator on: 2014-09-17 01:17:02
Hey,

I've completed a game on Libgdx and it runs fine on desktop, but it when I compile it into an apk and install it into an android virtual device, I get the message "Unfortunately, [app name] has stopped". I couldn't find a log or anything so I have no idea what's wrong.

I've tried many different configurations, including Android L (Preview) and 4.4W as the OS. RAM is 512 MB and VM Heap is 64. I don't have a physical android device to test on.

Does anyone have an idea of what might be wrong?
28  Game Development / Newbie & Debugging Questions / Re: libGDX: UI using ImageButton in a table layout on: 2014-09-15 07:17:14
Hey @Norakomi have you figured it out yet? If not, what's the problem? That thread I started which you've linked to is pretty old,  but if I recall properly, I followed the advice I received there and used a Button rather than an ImageButton. I created skins programmatically by adding the textures I wanted, then created the Button, using the skin in the constructors as required.

And yes I agree with you, it was a horrible nightmare figuring out how to use scene2d in Libgdx, and now I create my own UI classes.

Anyways, after you've created a Button, you can add it to the table and use the chain methods to position it. I never used TextureAtlases, just changed the Button texture directly by giving it another texture when needed, e.g. in onClick actions.

BTW: I just noticed all the "star" buttons in your code. You could use a for loop to manage all that if you want, not relevant but I cleaned up something similar in my project just before writing this.
29  Game Development / Newbie & Debugging Questions / iOS and Android Leaderboards and Ad Integration on: 2014-09-14 07:31:19
Hey,

I've finally fully completed a game and I'm looking into implementing leaderboards and ad integration for iOS and Android (maybe even PC).

I really have no idea where to start. Could anyone give me some advice? I'm using Libgdx.

Thanks,
Rayexar.
30  Discussions / General Discussions / Re: How can I speed up my computer? (Gaming) on: 2014-09-08 04:05:02

by reformat and reinstall you mean you reinstall your entire os or just the game?
[/quote]

The entire OS, because it removes all viruses, bloatware, unneeded processes/services etc
Pages: [1] 2 3 4
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

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