Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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
1  Game Development / Newbie & Debugging Questions / [LibGdx] Stuck with simple collision detection on: 2014-11-08 20:26:27
Hi

I'm trying to do a simple collision detection with LibGDX's intersector class. I draw the sprites so that it draws them from the center of the sprites and not from the bottom left corner of the sprite like it usually is. When I use sprite.getBoundingRectangle() method it doesn't draw around the sprite but instead it draws it somewhere else because of the way I draw the sprites.

Enough talk, here is the code:

Drawing the sprite(class extends Sprite):
1  
2  
3  
4  
5  
6  
7  
8  
@Override
   public void draw(Batch batch) {
      batch.draw(this.getTexture(), this.getX() - this.getOriginX(), this.getY() - this.getOriginY(),
            this.getOriginX(), this.getOriginY(), this.getWidth(), this.getHeight(), 1.0f, 1.0f,
             0, this.getRegionX(), this.getRegionY(),
             this.getRegionWidth(), this.getRegionHeight(), false, false
         );
   }


Checking collision:
1  
2  
3  
4  
5  
public void checkCollisions(Object obj){
      if(obj instanceof Enemy && Intersector.overlaps(this.getBoundingRectangle(), ((Paddle) obj).getBoundingRectangle())){
         this.speed.y = -this.speed.y;
      }
   }


What should I do to fix this?
2  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Player Movement lagging on: 2014-05-06 10:04:45
Fixed it finally. I removed the keyDown,keyUp and update method for player and instead replaced them with this.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public void move() {
         if(Gdx.input.isKeyPressed(Keys.A)) {
            movement.x = -velocity;
            body.applyLinearImpulse(movement, new Vector2(), true);
         }
         
         if(Gdx.input.isKeyPressed(Keys.D)) {
            movement.x = velocity;
            body.applyLinearImpulse(movement, new Vector2(), true);
         }
         
         if(!(Gdx.input.isKeyPressed(Keys.A)) && !(Gdx.input.isKeyPressed(Keys.D)))
            body.setLinearVelocity(new Vector2());
   }

I'm just wondering is there a better way to do this? Anyways Thanks alot for helping out.
3  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Player Movement lagging on: 2014-05-04 23:04:00
Thanks for the reply. I know that my explanation isn't the best, but the .jar says it all Grin

I removed the switch case in replaced it with if statements (without else) and it still does not work.
I dont want to use applyForce(); for the player.I've had this with all my projects and because I just can't fix it I usually stop doing those projects Sad.
4  Game Development / Newbie & Debugging Questions / [LibGDX] Player Movement lagging on: 2014-05-04 20:37:36
So I'm trying to make the player move using Box2D. The player moves left and right using 'A' and 'B' keys.
When I press 'A' and 'D' very fast the movement lags or should i say twitches. Here is the code.

The Player class extends InputAdapter and I Override 2 methods, KeyDown and KeyUp.
The movement is Vector2 variable.
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  
@Override
   public boolean keyUp(int keycode) {
      if(Keys.A == keycode || Keys.D == keycode && movement.x > 0) {
         body.setAngularVelocity(0);
         movement.x = 0f;
         body.setLinearVelocity(movement);
      }else
         return false;
     
      return true;
   }
   
   @Override
   public boolean keyDown(int keycode) {
      switch(keycode) {
      case Keys.A:
         movement.x = -velocity;
         break;
      case Keys.D:
         movement.x = velocity;
         break;
      default:
         return false;
      }
      return true;
   }


The Player class has also update method where I apply the movement
1  
2  
3  
public void update() {
         body.applyLinearImpulse(movement, new Vector2(), true);
   }


And then I've just used the players update method in the render method like so player.update();
of course the i've added listenenrs and so on. Is there something that I've forgotten?

Here is the .jar file.
http://www.mediafire.com/download/x5aogpoqahcb87h/test.jar
Is it normal that the file is 18Mb?? Cheesy

Thank you very much.
5  Games Center / Featured Games / Re: FarSky on: 2014-04-26 21:49:22
I just bought this game on Steam. Grin
Nice work and keep the good work up! All hands down.
6  Game Development / Newbie & Debugging Questions / Re: Hard to start a project. on: 2014-02-27 15:10:32

If you have a bit more musical knowledge I would recommend getting something like FamiTracker, it's a lot less linear.

However I must say that a lot of the musical knowledge you have won't benefit your game development too much. I've been playing Saxophone and Piano for years, but making the music for video games is still a skill I haven't gained. Sad

I also play piano alot and still can't compose "good" music. If you really want to compose music you have to study music theory alot such as scales and chord. I think that ear training might help also. Playing music that someone else has composed won't help that much.

Thanks to all of you for great advices. I think i will just focus on the programming Smiley.
Sorry for my bad english.
7  Game Development / Newbie & Debugging Questions / Hard to start a project. on: 2014-02-25 18:15:21
Hi. I have troubles to start a new projects and cant make more complex games than before mainly because i cant draw good graphics or compose music.
This leads always to lack of motivation(I still want to make the projects but i just cant).

Should i just program the logic of the game and then find someone to draw my graphics or should i start with a artist and composer before starting a project?

All of my friends are programmers and not artist or composers so its hard.
This is not just a question but i also want to know if someone is in the same position as i am.

Thank you and i hope you understand what i mean.
8  Games Center / WIP games, tools & toy projects / Re: BrickBroken - Break brick game by SLDT on: 2013-12-14 16:23:26

Why are you saying that i can't programm 3D for the moment. I will tell you that I've already created a few 3D games and all of these games has all closed due to no - player problem, no one wanted to download the launcher why ? Because i'm not using SSL protocol in my website, Nobody wanted to test the game because they don't know me. So I aquired the way that nobody will never play to any new 3D game otherwise it's enterprise such as Nintendo, Microsoft,... !
That's one of the reason for why I had created BrickBroken.
So don't speak about thing that you don't know.

First of all. I never said you cant program 3D games. I said that imo(in my opinion) you should first program a few 2D games before moving into 3D programming. At least thats what im going to do.
9  Games Center / WIP games, tools & toy projects / Re: BrickBroken - Break brick game by SLDT on: 2013-12-14 12:29:54
I just cant understand why you want to rush and start developing 3D games when you cant even program a decent 2D game.
Imo you should first develop a few 2D games and when you get the hang of it then you should start thinking about 3D

Also developing a decent 2D rpg is not cakewalk and you are thinking about 3D MMORPG.
i hope you dont get me wrong, I'm just trying to save your time.
10  Games Center / WIP games, tools & toy projects / Re: BrickBroken - Break brick game by SLDT on: 2013-12-11 21:52:59
I am also currently programming a breakout game with libgdx(for exercise reasons to get familiar with all the libgdx stuff).
but after seeing this thread i have second thoughts.

I dont even want to try this for some reason.
I'll just stick with opiop65's Pong game Grin.
11  Games Center / Showcase / Re: Fetriz on: 2013-12-02 12:57:01
Seems like a lot of fun. +1 for the awesome idea.
cant wait to try this out and get the 10 points on expert Grin
12  Games Center / Showcase / Re: Fetriz on: 2013-12-01 18:53:09
I have Ati radeon HD5850 which supports OpenGL 3.2. This is becoming intresting  Cheesy
13  Games Center / Showcase / Re: Fetriz on: 2013-12-01 18:18:22
I updated Java and i still get the same error. I also tried java - jar Fetriz.jar
14  Games Center / Showcase / Re: Fetriz on: 2013-12-01 17:56:22
@wessles I've no idea what that error is caused by, seems like LWJGL can't create the display...  Undecided

@Zeta You tried to drag the folder to the desktop for example? Could you do a java -jar on the jar?

It gave me an Error "unable to access the jarfile Fetriz".
15  Games Center / Showcase / Re: Fetriz on: 2013-12-01 17:38:05
Which OS?

Windows 7
16  Games Center / Showcase / Re: Fetriz on: 2013-12-01 17:26:40
It does not run. It crashes immidiately after i start it.
17  Discussions / General Discussions / Re: Give me a game or program idea! on: 2013-12-01 17:11:26
Make something that you want to play/use.
Maybe something that is a bit challenging so you could also learn something new and develop your skills.


Maybe a top-down shooter or a rpg game(not sure if its too hard with 3 years of experience.)
18  Java Game APIs & Engines / Android / Re: [Solved] Supporting multiple devices. on: 2013-11-30 21:27:06
I read somewhere that when you make a folder named for example layout-large.
Then it recognizes if the app is played on hdpi devices and it runs the layout in the layout-large folder.

I really dont know if this is the best solution but good enough for me since im not doing fancy stuff with my app.

Here is a good link: http://developer.android.com/guide/practices/screens_support.html
19  Java Game APIs & Engines / Android / Re: Supporting multiple devices. on: 2013-11-30 12:26:53
I've solved the problem.

I had to make folders layout-small, layout-large etc. and make own layouts for them.

also i had to add "supports-screens" in manifest:
1  
2  
3  
4  
5  
<supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true" />


Now im experiencing problems with animation.
Maybe i should just use engine to make games for android, but i dont think i will learn much if i do so.
20  Java Game APIs & Engines / Android / [Solved] Supporting multiple devices. on: 2013-11-29 20:00:30
How can i make my app support multiple devices?
Im making the app without engines like libgdx so i can understand android development better(i guess).


I've made different resolution images for hdpi,mdpi and ldpi.
What dp width and height should i use in my xml code so it support most of the devices and does not look stretched?
Should i make different layouts for different devices or something?

Here is my xml code for the splash image:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/backgroundId"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/black"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/splashId"
        android:layout_width="match_parent"
        android:layout_height="240dp"
        android:background="@drawable/splash"
        android:contentDescription="@string/splash"
        android:orientation="vertical" >
    </ImageView>

</RelativeLayout>


Thank you.
21  Game Development / Newbie & Debugging Questions / Re: LibGdx resizing textures on: 2013-10-08 18:59:54
How can i use pixel density in libgdx that it will resize/ scale the textures in any phone.
all i could find was getPixelDensity();. Can i use this somehow or have i undestanded pixel density completely wrong?


Thank you. (didnt want to make o new topic since its relevant to this one).
22  Game Development / Newbie & Debugging Questions / Re: LibGdx resizing textures on: 2013-10-06 16:13:29
I still have a problem keeping the aspect ratio  Undecided. Thanks for your help thought.
23  Game Development / Newbie & Debugging Questions / Re: LibGdx resizing textures on: 2013-10-04 21:42:40
No, You don't need to do anything separately. Libgdx will do that for You
Here's a link talking about the camera and how it works:
https://code.google.com/p/libgdx/wiki/ProjectionViewportCamera

To sum it up, by default, the viewport is a rectangle -1 to +1 on both x and y. When You render Your texture at (-0.5,-0.5) with a size of 0.5, then it will be in the middle of the screen regardless of the screen. However, depending on the screen size, it might be stretched or the opposite.

not sure if im stupid. I cant still get it to work. here's what i've done

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  
   Stage stage;
   Texture backgroundTexture, titleTexture;
   Sprite background, title;
   SpriteBatch batch;
   Music bgm;
   private OrthographicCamera camera;

   @Override
   public void render(float delta) {
      camera.update();
     
      batch.begin();
      background.draw(batch);
      title.setBounds(Gdx.graphics.getWidth()/3.5f,Gdx.graphics.getHeight()/1.5f , title.getWidth(), title.getHeight());
      title.draw(batch);
      batch.end();
     
   }

   @Override
   public void resize(int width, int height) {
      float aspectRatio = (float) width / (float) height;
        camera = new OrthographicCamera(2f * aspectRatio, height);
   }

   @Override
   public void show() {
      backgroundTexture = new Texture(Gdx.files.internal("img/bgMain.jpg"));
      background = new Sprite(backgroundTexture);
      background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
     
      titleTexture = new Texture(Gdx.files.internal("img/MenuTitle.png"));
      title = new Sprite(titleTexture);
     
     
     
      batch = new SpriteBatch();
     
      bgm = Gdx.audio.newMusic(Gdx.files.internal("music/MenuBgm.mp3"));
      bgm.setLooping(true);
      bgm.setVolume(0.5f);
      bgm.play();
     
   }


Do i have to use meshes or am i just stupid  Smiley. Just keep in mind this is my first libgdx project.
24  Game Development / Newbie & Debugging Questions / Re: Can't figure out how to do Java Audio properly. on: 2013-10-04 21:12:03
I think DrZoidberg's solution is the best option and the easiest way to achieve overlapping sounds (two sounds at the same time).
There is no need for threads.
25  Game Development / Newbie & Debugging Questions / Re: LibGdx resizing textures on: 2013-10-04 12:54:48
Quote
Right?
So we will need to worry with textures too? Or we can just adjust the camera? I think we just need to adjust the camera Zeta! I think dermetfan already helped me to mess with @resize() method...

I've tried to do everything with camera just cant get it to work. I hope someone has solution for this. Or is it just better to do Android and desktop versions separately?
26  Game Development / Newbie & Debugging Questions / LibGdx resizing textures on: 2013-10-03 20:11:38
When I run the application on desktop every texture is in right position right size, but when i run it on Andorid device
some of the textures wont show because they are out of bounds.

How can i fix the resolution that it would be the same on both devices

application runs on 1024x786 on desktop.
27  Game Development / Newbie & Debugging Questions / how to split/get images from spritesheet with non-uniform sprite dimensions on: 2013-10-03 13:01:46
I want to split images from spritesheet with non-uniform sprite dimensions. What is the best way to split images this?


Here's an example of non-uniform sprite dimensions.



Thanks.
28  Game Development / Newbie & Debugging Questions / Re: Tween engine issue on: 2013-10-01 14:41:23
Make sure you import it, if that's already done it could be some weird version issue, make sure you use nightlies

Im using the nightliest. Maybe its the Eclipse version that i use? I'll just install the whole thing from scratch. I'll edit this post later if it worked?

EDIT: I made a silly mistake Smiley .  

1  
2  
3  
4  
Tween.registerAccessor(Sprite.class, new SpriteAccessor());

//should be
Tween.registerAccessor(Sprite.class, new ScreenAccessor())
29  Game Development / Newbie & Debugging Questions / Tween engine issue on: 2013-09-30 17:57:27
I use Libgdx and Tween engine. I get a weird problem when registering accessor like this.

EDIT: It seems that my Eclipse cant even find SpriteAccessor();. I installed Libgdx and Tween with the libGdx GUI installer. any advice how to fix this?

this class implements Screen
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
@Override
   public void show() {
      splashTexture = new Texture(Gdx.files.internal("img/splash.png"));
      splash = new Sprite(splashTexture);
      splash.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
     
      batch = new SpriteBatch();
      tweenManager = new TweenManager();
      Tween.registerAccessor(Sprite.class, new SpriteAccessor()); //Here the SpriteAccessor is underlined
     
      splashBgm = Gdx.audio.newMusic(Gdx.files.internal("sounds/bgm.mp3"));
      splashBgm.setVolume(.2f);
      splashBgm.setLooping(true);
      splashBgm.play();
   }


And here is my ScreenAccessor class that implements TweenAccessor<Sprite>
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
@Override
   public int getValues(Sprite target, int tweenType, float[] returnValues) {
      switch(tweenType){
      case ALPHA:
         returnValues[0] = target.getColor().a;
         return 1;
      default:
         assert false;
         return -1;
      }  
   }

   @Override
   public void setValues(Sprite target, int tweenType, float[] newValues) {
      switch(tweenType){
      case ALPHA:
         target.setColor(target.getColor().r, target.getColor().g, target.getColor().b, newValues[0]);
         break;
      default:
         assert false;
      }
   }


Thank you.
30  Game Development / Newbie & Debugging Questions / Re: What Game engine to use. on: 2013-09-29 13:46:07
It really depends on what you want. JME is a 3D engine thy will take a lot of the low level work off your hands and provide you with a nice interface to interface with the code, so use it if you don't like to code absolutely everything. However, its not really a 2D engine.

LibGDX is a great high level library, I personally love using it. It allows you to utilize OpenGL without having to write all the low level rendering code, so use it if you want to program most of your game, but are ok with not delving into the "hardcore" low level graphics. Its also mainly 2D!

LWJGL just "ports" OpenGL over so you can use it in Java since OpenGL was written with C languages in mind. If you use LWJGL, prepare to have to google a ton and work on the low level code for a while before you can start thinking about actually setting a game up. I've done it before, its actually fun to learn all about OpenGL and shaders, but I don't like having to rewrite my render engine because my new game has different requirements than my old engine.

There's also Slick2D, but its not as... (Trying not to stay a flame war) good or used much anymore. LibGDX is almost its successor, in a way. Slick2D is pretty easy to use, but I dont know if its ok for me to recommend it!

Good luck on whatever you pick!

I think i will go with libgdx, but should i use OpenGL with it? i didnt quite understand. Is there any other libriaries that i should use with libgdx?
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

TheDudeFromCI (12 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (55 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (91 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (94 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03

toopeicgaming1999 (161 views)
2014-11-26 15:22:04
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

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

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

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

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