Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
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  Game Development / Newbie & Debugging Questions / Re: Struggling to get my head around the [LibGDX] Particles Editor on: 2017-08-24 15:25:23
Hi phunni,

I have a blog which happens to have an article on the Libgdx particle editor and what each of the parameters do with a couple of examples.

Here is a list of what each of the parameters do:

2D Particle Effect Editor Properties Explained

So what are the different properties in the editor? Well they are:

    Image
        This is where we can add our own custom image to be used as a particle. Usually, the default image is fine and will be suitable for most of our effects. Sometimes you will want to add your own. For example, if you wanted a 1-UP effect to pop out of the player you can use an image with 1-UP text.
    Default
        This is to reset the image back to the default image if you changed the image previously.
    Default (Premultiplied Alpha)
        This set the image to be used to the default image and then sets the blending type. To view the difference, try using the default image with the default fire effect, then swap to the premultiplied alpha version and see what happens.
    Count
        The count is used to define how many particles there should be at any time during the effect. The two boxes set the minimum and maximum amount. If the min is 0 and the max is 0 then no particles will ever be made or drawn. If the min and max are both 10 then there will always be 10 particles drawn, if one finishes another is created to replace it.
    Delay
        The delay as expected delays the particles from being made. This is useful when you use multiple effects as you can have a fire effect which runs for about 1 second, then a smoke effect with a delay of 0.8-1.0 seconds so the fire appears to change to smoke.
    Duration
        The Duration is the value that sets how long the Effect runs. A duration of 1000 means the effect will last for 1 second.
    Emission
        This defines how the particles are spawned. If the minimum value is 5 then each second at least 5 particles will spawn. If the max is 100 then up to 100 can spawn per second. This is useful for effects like smoke which should fizzle out the longer it runs. so you can have it start or 20 particles per second and run down to 0. (This requires the duration graph to be used and will be covered later in this tutorial)
    Life
        This sets how long a particle will live for. If you set this to 1000 (1 second) the particle will last for 1 second then get removed. This is not 1 second from the start of the effect as a particle can be created at any time.
    Life offset
        This allows you to have a particle that starts part way through their life cycle. So particles that have a full life to live all the way down to particles that are just about to be killed off can spawn.
    X-Offset
        Adds an offset on the x axis to each particle. Negative values make particles spawn more to the left and positive values to the right.
    Y-Offset
        Adds an offset on the y axis to each particle. Negative values spawn more to the bottom and positive more to the top.
    Spawn
        This sets the shape of the area where particles can spawn.
    Spawn Width
        Sets the width of the spawn shape.
    Spawn Height
        Sets the height of the spawn shape.
    Size
        Sets the size of the particles.
    Velocity
        Sets the speed of the particles.
    Angle
        Sets the angle that the particles face. Only visible if velocity is set.
    Rotation
        Sets the rotation of the particle. Not very useful with the round default image.
    Wind
        Adds a force to move particles left or right to simulate the wind.
    Gravity
        Adds a force to move particle up or down to simulate gravity.
    Tint
        Colours the particles from left to right of the gradient defined.
    Transparency
        Sets the opacity of the particle over its lifetime.
    Options
        Allows you to change the properties of the Effect:
            Additive: Additive blending on/off.
            Attached: sets whether the particles move with the emitter or stay in the same place.
            Continuous: Should the effect loop or run once.
            Aligned: Particles should rotate with the emitter on/off.
            Premultiplied Alpha: Premultipled blending on/off.

If you want to learn more you can view it on https://www.gamedevelopment.blog/particle-effects-libgdx-2d/
2  Game Development / Newbie & Debugging Questions / Re: Textures loaded using AssetManager do not appear on screen on: 2017-08-04 11:02:13
Hey @mmx358,

I can't see anything wrong with the code you provided, I suspect it may be down to when you are loading and assigning the images.

You can check if the images have loaded with
1  
2  
3  
if(manager.isLoaded("data/mytexture.png")) {
    // image loaded to set it as sprite
}


Quote
But I'd like to know how to deal with this issue to write as good code as possible for a simple game and to get advantage of AssetManager for a complex one with large number of different textures.

I have a guide on my blog for the Asset Manager which can be used for more than just textures. As well as the Texture packer which is a great tool for packing lots of images into a single atlas. These are great when used together as it allows you to have a pack for your loading screen, a pack for your game assets and a pack for GUI etc which can be loaded or unloaded separately.
3  Game Development / Game Mechanics / Re: Move one game object to another (moving) game object with libGDX on: 2017-08-03 14:43:39
Since velocityX and velocityY are normalised you can multiply them by the amount of units you want the object to travel per second.

So if you want the unit to travel at 5 units per second you can use

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
        float speedPerSecond = 5;
        //normalise
        if (distance != 0) {
            velocityX /= distance;
            velocityY /= distance;
        }

        if (!arrived) {
            position.x += (velocityX * speedPerSecond)  * deltaTime;
            position.y += (velocityY * speedPerSecond)  * deltaTime;
            Rectangle ninjaRectangle = target.getBoundingRectangle();
            Rectangle shurikenRectangle = getBoundingRectangle();
            if (ninjaRectangle.overlaps(shurikenRectangle)) {
                arrived = true;
            }
        }


This is dependant on your banana units, if you are using pixel perfect units then you will travel at 5 pixels per second, if you're using 16pixels per world unit then it 16 * 5 per second.
4  Game Development / Game Mechanics / Re: Move one game object ot another (moving) game object with libGDX on: 2017-08-01 13:40:54
I can't see any reason in the code you provided that would make the bullet object go horizontally other than the target being in a position horizontal to the bullet. I suggest monitoring the values of all items in the init method for each step to see what the values are at each step.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public void init(TigerActor target) {
        this.target = target;
        System.out.println("TargetValStart"+target.getX()+":"target.getY()); // maybe init is being called before target x and y has been set
        System.out.println("PositionValStart"+position.x+":"position.y);
        direction = new Vector2();
        direction.x = target.getX() - position.x;
        direction.y = target.getY() - position.y;
        System.out.println("b4Nor:"+direction);
        direction = direction.nor();
        System.out.println("AfterNor:"+direction);
    }


For reference I looked back into a project I had weapons in and found this snippet:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public void baseShoot(Entity ent,float targetX,float targetY, Array<Bullet> activeBullets,boolean playSound){
      float shooterX = ent.getBody().getPosition().x; // get shooters x pos
      float shooterY = ent.getBody().getPosition().y;  // get shooters y pos
      float velx = targetX - shooterX; // get distance from shooter to target on x axis
      float vely = targetY - shooterY; // get distance from shooter to target on y axis
      float length = (float) Math.sqrt(velx * velx + vely * vely); // get distance to target direct
      // normalise
      if (length != 0) {
            velx = velx / length;
            vely = vely / length;
      }
      // get bullet from pool
      Bullet bullet = (Bullet) bp.obtain();
      // add to array for rendering
      activeBullets.add(bullet);
      // activate bullet (set start pos, velocity, and owener)
      bullet.activate(new Vector2(shooterX,shooterY), new Vector2(velx*speed,vely*speed), ent);

      if(playSound){
         this.shootSound();
      }
      // update weapon shot timer
      this.hasShot();
   }

5  Game Development / Game Mechanics / Re: Move one game object ot another (moving) game object with libGDX on: 2017-08-01 11:44:42
Quote
Having logged the result of calculating the direction I can see it's 1.0 : 0.0

This looks like your float values are being converted to Integers. Are any of the values you use such as Target.getX() or Position Integers? I assumed they would all be Vector2.
6  Game Development / Game Mechanics / Re: Move one game object ot another (moving) game object with libGDX on: 2017-07-31 15:27:04
The code itself is fine, I have tested it in libgdx with this code:

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  
package com.mygdx.gtest;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.math.Vector2;

public class Test extends ApplicationAdapter{
   Bullet b;
   TigerActor t;
   
   @Override
   public void create() {
      b = new Bullet();
      t = new TigerActor();
      b.init(t);
   }
   

   @Override
   public void render() {
      b.act();
   }


   @Override
   public void dispose() {
      super.dispose();
   }
   
   private class Bullet {
      TigerActor target;
      Vector2 direction;
      Vector2 position = new Vector2(40,40);
     
      public void init(TigerActor target) {
         this.target = target;
         direction = new Vector2();
         direction.x = target.getX() - position.x;
         direction.y = target.getY() - position.y;
         direction = direction.nor();
         System.out.println(direction);
      }
     
      public void act(){
         position.x += direction.x;
         position.y += direction.y;
         System.out.println(position);
      }
   }
   
   private class TigerActor{
      int x = 10;
      int y = 10;
     
      public int getX(){
         return this.x;
      }
      public int getY(){
         return this.y;
      }
   }
}


Try printing out or debugging the code and inspect the target position and direction.
7  Game Development / Newbie & Debugging Questions / Re: Struggling with Cameras and TileMaps on: 2017-07-05 14:10:19
What I do with TiledMap game is clamp the camera position to within the map area.

1  
2  
3  
4  
5  
6  
7  
float evw = cam.viewportWidth * cam.zoom;
float evh = cam.viewportHeight * cam.zoom;
float gutter = viewport.getWorldHeight() / (sh  / 80) ;
cam.position.x = MathUtils.clamp(cam.position.x, evw / 2f, model.currentMapWidth - evw / 2f);
cam.position.y = MathUtils.clamp(cam.position.y, evh / 2f - gutter , model.currentMapHeight - evh / 2f);
cam.update();                                            
mapRenderer.setView(cam);
8  Games Center / WIP games, tools & toy projects / Re: BlockBreaker on: 2017-06-27 14:41:37
Hi thanks for your input.

Quote
-> The Ball does not bounce in a different direction depending on where it hit the paddle -> the player is just reacting, cant control much, its mostly about catching things that fall down.

I have updated the pad from a plain rectangle to an convex polygon with a curved top. This should increase the control for the user Smiley (still needs some adjustment)

Quote
-> You should add a stronger light emitter to the balls, they are too small and hard to spot when everything is blinking and moving.

That's a good idea. I will add this in the next update.

Quote
-> elements are too small in general for the screen. try boosting their relative size

Do you mean things like bricks and balls are too small for 1024x786. I currently do all my testing on 1920x1080.

Quote
-> The paddle movement does not respond immediately, try making it controlled directly by the mouse-pointer-position, without acceleration.

I use a small amount lerping on the paddle to increase difficulty. I could remove this and increase the ball speed to make it more challenging as I think it's too easy at the moment.

As for the 40MB download 28MB of that is music :/
9  Game Development / Newbie & Debugging Questions / Re: [libgdx] How can rotate multiple texture same like one texture? on: 2017-05-05 08:29:56
If all the images are sprites you could use the setOrigin method to set their origin at the same world position. The images will then all scale and rotate from the same point.

1  
2  
3  
4  
tex1.setOrigin(0, -100)
tex2.setOrigin(0, -200)
tex3.setOrigin(0, -300)
tex4.setOrigin(0, -400)


Then once you finish rotating you can use setOriginCenter to place the origin back the the middle so they can be rotated independently again.
10  Discussions / General Discussions / Re: Coding music! on: 2017-04-22 08:56:56
I tend not to listen to the same music genre for extended periods and end up swapping after a while.

The last tunes I listened to:

<a href="http://www.youtube.com/v/KR-eV7fHNbM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/KR-eV7fHNbM?version=3&amp;hl=en_US&amp;start=</a>
<a href="http://www.youtube.com/v/XivpeO_ZUys?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/XivpeO_ZUys?version=3&amp;hl=en_US&amp;start=</a>
<a href="http://www.youtube.com/v/r-Vehm8b5xU?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/r-Vehm8b5xU?version=3&amp;hl=en_US&amp;start=</a>
11  Game Development / Newbie & Debugging Questions / Re: [Best practice]Assetmanager vs TextureAtlas on: 2017-04-13 09:49:11
The assetManager not only loads image files, but sounds, music, particleEffects, fonts, skins etc. It also keeps track of all of the items it loads and won't dispose of the item until all references of it are no longer needed as well as only loading a single item once even if asked to load it twice as it knows it already has one reference to that item. Finally it allows you to load items asynchronously so you can make cool loading screens with progress bars Smiley
12  Game Development / Newbie & Debugging Questions / Re: [Best practice]Assetmanager vs TextureAtlas on: 2017-04-13 09:20:17
The text file is also known as an atlas, this text file has the names of all the image files it needs and so when the assetManager loads the text file it will find the names of the images needed and load them.

This is an excerpt of a text file for some packed images from my pet project:

Quote
loadingGui.png
format: RGBA8888
filter: MipMapLinearLinear,MipMapLinearLinear
repeat: none
blockBreakerTitle
  rotate: false
  xy: 2, 109
  size: 960, 145
  orig: 960, 145
  offset: 0, 0
  index: -1

As you can see on the first few lines is the name of the image which contains all the smaller images as well as some image type information. From blockBreakerTitle until the end is one of the images that was packed. It says where this smaller image can be found on the packed image as well as it's size and offset. The final attribute "index" is to say which page the image is on. This package only has 1 image so -1 is used but if there was more images the index of the page it is on would be used.
13  Game Development / Newbie & Debugging Questions / Re: [Best practice]Assetmanager vs TextureAtlas on: 2017-04-13 08:35:02
In Libgdx, the asset manager will load all the pages that belong to the atlas automatically as long as they're numbered.
So for gui.atlas all gui_1.png, gui_2.png and gui_3.png will be loaded.

Have you tried to load a single atlas with multiple pages then use an image from each page? Would be a good way to check if it's working.
14  Discussions / Miscellaneous Topics / Re: Silly Programming Mistakes on: 2017-04-12 10:29:31
1  
2  
3  
4  
5  
6  
7  
8  
fbPostEffects = new FrameBuffer(Format.RGBA8888,this.sw,this.sh, false);

fbPostEffects.begin();
...
fboPostEffects.end();

renderTexture = fboPostEffects.getColorBufferTexture();
fboPostEffects.dispose();


Yesterday I created a FrameBuffer for adding some shader effects and disposed it before using it. Spent about 45 minutes wondering why my screen was black.
15  Game Development / Newbie & Debugging Questions / Re: [Best practice]Assetmanager vs TextureAtlas on: 2017-04-11 09:20:39
The main reason to put all your images in a TextureAtlas is to keep as many images as possible in a single image so you only need to read the image file from disk once which is slow. Then when you want a single image you read it from the already loaded TextureAtlas which is loaded in memory which is a lot faster. So in terms of performance, you are best off having as few as possible Images to load from disk.

Usually, if you have a lot of images that won't fit onto a single 1024x1024 image you would pack them onto multiple 1024x1024 pages all in the same atlas. This would give you one atlas(information on individual images) and several 1024x1024 image files that belong  to that atlas.

16  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-04-10 21:19:38
Added a simple shockwave shader to my pet project

<a href="http://www.youtube.com/v/RytJ537BlPo?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/RytJ537BlPo?version=3&amp;hl=en_US&amp;start=</a>
17  Game Development / Newbie & Debugging Questions / Re: [Best practice]Assetmanager vs TextureAtlas on: 2017-04-10 17:50:17
Quote
But what is the maximum size for textureatlas?

You can put as many images as you want into an atlas but you should try and keep the atlas size 1024 x 1024 for maximum compatibility but 2048 x 2048 will work on most devices.

If you have too many images to fit onto a single 1024x1024 image then you can use split the atlas into several pages of 1024x124
18  Game Development / Newbie & Debugging Questions / Re: [Best practice]Assetmanager vs TextureAtlas on: 2017-04-10 09:17:54
You appear to be using the asset manager correctly.

Quote
How can i give the TextureAtlas all Assets from the AssetManager?

I assume by this you mean how do you put all images into one atlas?

You can use a texture packer to pack all your images into a larger file.

A guide on AssetManager https://www.gamedevelopment.blog/asset-manager-libgdx-tutorial/

A guide on Texture Packer  https://www.gamedevelopment.blog/texture-packer-gui-quick-tutorial/
19  Games Center / WIP games, tools & toy projects / Re: BlockBreaker on: 2017-04-07 07:45:56
Download link has been fixed
20  Games Center / WIP games, tools & toy projects / BlockBreaker on: 2017-04-06 18:05:41
I originally started making this project to test out the Box2D Lights extension and ended up sticking on it to make a full game.

It uses the Libgdx Framework with Box2D and Box2D lights.

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

The jar can be downloaded from https://www.gamedevelopment.blog/downloads/

Controls:
ControlEffect
Mouse Left/RightPad Left/Right
Left ClickMagnetise(Pull)
Right ClickMagnetize(Push)
BBomb
PPause

Debug Controls:
ControlEffect
F3Box2D Renderer
F4Add Brick
F5Kill 50% of Bricks
F6Bomb


21  Game Development / Newbie & Debugging Questions / Re: LibGDX - Top down car rotation very weird and buggy on: 2017-04-06 11:08:29
Hi elaguy ,

You're currently setting the both x and y velocity when the the player presses up or down. This is causing your car to move in those angles.

Instead of setting the velocity of the car directly you could update the car speed from the user input and then calculate the velocity based on the angle of rotation of the car. e.g:

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  
private void update(float delta) {
     
      if(Gdx.input.isKeyPressed(Input.Keys.UP)) {
         speed+=1f ;
         if(speed > 2){
            speed = 1;
         }
      }
     
      if(Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
         speed-=1f;
         if(speed < 0){
            speed = 0;
         }
      }
     
      if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
         playerCar.rotate(+3);
      }
     
      if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
         playerCar.rotate(-3);
      }
     
      playerCar.setOriginCenter();
     
      Vector2 vel = getVelocity(speed,playerCar.getRotation());
      playerCar.setX(playerCar.getX() + vel.x);
      playerCar.setY(playerCar.getY() + vel.y);
     
      System.out.println("Rotation:"+playerCar.getRotation());
     
      cam.position.set(playerCar.getX() + (playerCar.getWidth()/2), playerCar.getY() + (playerCar.getHeight()/2), 0);
      cam.update();
   }
   
   private Vector2 getVelocity(float sp, float rotation){
      Vector2 vel = new Vector2();
      float vx = (float) Math.cos(Math.toRadians(rotation)) * sp;
      float vy = (float) Math.sin(Math.toRadians(rotation)) * sp;
      vel.x = vx;
      vel.y = vy;
      return vel;
   }
Pages: [1]
 
Riven (578 views)
2019-09-04 15:33:17

hadezbladez (5495 views)
2018-11-16 13:46:03

hadezbladez (2398 views)
2018-11-16 13:41:33

hadezbladez (5756 views)
2018-11-16 13:35:35

hadezbladez (1219 views)
2018-11-16 13:32:03

EgonOlsen (4659 views)
2018-06-10 19:43:48

EgonOlsen (5667 views)
2018-06-10 19:43:44

EgonOlsen (3193 views)
2018-06-10 19:43:20

DesertCoockie (4093 views)
2018-05-13 18:23:11

nelsongames (5104 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04: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!