Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (683)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (750)
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: [Solved][Libgdx] How do I blend textures? (like Flash) on: 2016-05-16 12:29:13
If the effect works for you, fine.  But it's not "useful for people lurking Google searches" because you're replicating a wrong answer to your question!

Fine, I guess you're right. But if it's not overlay, what is it? And why did it work?
2  Game Development / Newbie & Debugging Questions / Re: [Solved][Libgdx] How do I blend textures? (like Flash) on: 2016-05-16 08:46:34
Well it's not the wrong one either, so whatever it is, I'm not complaining! Cool
3  Game Development / Newbie & Debugging Questions / Re: [Libgdx] How do I blend textures? (like Flash) on: 2016-05-16 02:52:28
Alright, after looking some more, I finally got the answer:

1  
2  
3  
//render first image
batch.setBlendFunction(GL20.GL_DST_COLOR, GL20.GL_SRC_ALPHA); //Acts like Flash/Photoshop's overlay
//render next image


Found it here
4  Game Development / Newbie & Debugging Questions / Re: [Libgdx] How do I blend textures? (like Flash) on: 2016-05-15 05:19:10
I'll try that out, thanks!
5  Game Development / Newbie & Debugging Questions / Re: [Libgdx] How do I blend textures? (like Flash) on: 2016-05-14 15:01:40

But blending is enabled by default, and if I simply rendered the overlay sprite on top of the other sprite, then I assume the blend mode would be "normal", not "overlay"?


Nope, it's just in 2D, although might come in handy for other people
6  Game Development / Newbie & Debugging Questions / [Solved][Libgdx] How do I blend textures? (like Flash) on: 2016-05-14 13:04:12
Back then when I was working with Flash and Actionscript, I can blend sprites like this:

1  
2  
3  
main.addChild(backgroundSprite);
overlaySprite.blendMode = BlendMode.OVERLAY;
main.addChild(overlaySprite);


In which overlaySprite will be overlayed on top of backgroundSprite.

How would I achieve the same thing using Libgdx? I've tried messing around with textures and the spritebatch, but I couldn't really get it working, and I'm not that much experienced with shaders. But if it can be as simple as to how it was done in Flash, then it could be simple with Libgdx too, right?
7  Game Development / Newbie & Debugging Questions / Re: [Libgdx][Box2D] Box2D not scaling correctly on: 2016-05-03 15:20:25
I personally don't use box2d but the libgdx doc says that PolygonShape.setAsBox() takes in half-size arguments. Could it be that you're setting the box to be 1x1, but the parameters assume that's half size and make it 2x2? Your body definition code isn't included so we can't tell.

Well I'll be, it seems you're right

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
bodyDef = new BodyDef();
bodyDef.angle = this.rotation;
bodyDef.position.set(this.x, this.y);
bodyDef.type = BodyDef.BodyType.StaticBody;
body = w.createBody(bodyDef);
poly = new PolygonShape();
poly.setAsBox(this.width, this.height); //should have been halved
fix = new FixtureDef();
fix.friction = this.friction;
fix.restitution = this.resituition;
fix.shape = poly;
body.createFixture(fix);


I guess I should have read the docs more Clueless I have this bad habit of just quickly scanning over wikis and just picking what I think I need

It's fixed now, thanks!
8  Game Development / Newbie & Debugging Questions / [Libgdx][Box2D] Box2D not scaling correctly [Fixed] on: 2016-05-03 14:49:59
In my game, I use Box2D. Now Box2D doesn't use pixels as units, so instead, it uses meters.

I render two things in my game to keep the physics and the graphics separate. Graphics is in normal libgdx coordinates (lower-left origin) because I'm used to having it as that. Physics is in Box2D coordinates (center origin) because that's what Box2D needs.

Everything seems fine, except that Box2D renders everything twice as big:

White line is the graphics renderer while the green lines are from the Box2D debug renderer


(Yeah I know it's not centered but it's on purpose)

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  
//I set 60 pixels per meter
private static final int PIXELS_PER_METER = 60;

private Box2DDebugRenderer debug;
private OrthographicCamera camera;

//...

public ...() {
   debug = new Box2DDebugRenderer();
   //Convert window width and height to meters because that's what Box2D needs
   camera = new OrthographicCamera(Maths.pixelsToMeters(Gdx.graphics.getWidth()), Maths.pixelsToMeters(Gdx.graphics.getHeight()));

   //Just offset the camera, because in-game center isn't the window center; not sure if this is relevant
   camera.position.sub(0f, Maths.pixelsToMeters(Gdx.graphics.getHeight() - Maths.IN_GAME_HEIGHT / 2f - Gdx.graphics.getHeight() / 2f), 0f);
   
   camera.update();
}

//...

public static float pixelsToMeters(float p) {
   return p / (float)(PIXELS_PER_METER);
}

//...

public void render(float delta, SpriteBatch batch) {
   camera.update();
   //...
   debug.render(world, camera.combined);
}


Given that the cube above is 60 by 60 pixels, that would be 1 meter in Box2D units (println's also say this). But every time it is rendered it shows up twice as big (120 by 120 pixels). It also said in the javadocs that OrthographicCamera takes in half a viewport, but that still doesn't work.
9  Game Development / Newbie & Debugging Questions / 3D Camera Effect? (like in Five Nights at Freddy's) on: 2015-01-23 12:18:30
In Five Nights at Freddy's the game has some sort of "3D camera vision" like so:

http://webmup.com/riR0o/vid.webm

I think it's called the fish eye lens effect? It's basically just a long flat image stretched/curved(?) to look like the player was looking around I guess. The game has surveillance cameras too, and they have the same effect when moving left and right.

I was wondering how I could achieve the same effect? Preferably with Libgdx or using GL functions  Smiley
10  Game Development / Newbie & Debugging Questions / Re: LibGDX List of Disposable objects on: 2014-12-22 04:30:37
When your app exits, everything is disposed. You only need to dispose things explicitly if you need them to be disposed without exiting the app. Eg, maybe you have separate screens and want to unload all the stuff from one screen before you show another. This could make sense if the screens each had a huge map with screen specific textures, etc.

Does this mean disposing all things Disposable when the app exits is unnecessary?
Definitely, yes. Don't do stuff you don't have to do.

Oh gosh. That's now gonna be a hard habit for me to break  Sad
11  Game Development / Newbie & Debugging Questions / Re: LibGDX List of Disposable objects on: 2014-12-22 00:17:07
When your app exits, everything is disposed. You only need to dispose things explicitly if you need them to be disposed without exiting the app. Eg, maybe you have separate screens and want to unload all the stuff from one screen before you show another. This could make sense if the screens each had a huge map with screen specific textures, etc.

Does this mean disposing all things Disposable when the app exits is unnecessary?
12  Discussions / General Discussions / Re: Just joined the website. Wish I found it sooner. on: 2014-11-30 01:23:01
Hi! Welcome to JGO! Smiley
13  Discussions / General Discussions / Re: PrepperCraft! - A free voxel game. on: 2014-11-26 22:05:10
Screw you all! I'm leaving this site. Bye asswholes! Have a nice time in hell!

Well that escalated quickly
14  Discussions / General Discussions / Re: Microsoft to buy Mojang for $2 billion? on: 2014-09-15 13:18:56
Well, it's been confirmed

https://mojang.com/2014/09/yes-were-being-bought-by-microsoft/
15  Discussions / Miscellaneous Topics / Re: Losing projects on: 2014-06-13 11:22:24
I've made and abandoned projects too. One time I deleted a project because I thought "eh, the way I wrote my code is very ugly. Maybe I could just rewrite all of it, but I might as well just start from scratch.." so I did. Then I found out that I've written code that was in the old project that I wasn't able to redo. So I tried going to the Recycle Bin to see if my old project was there. It wasn't. I may have emptied it. I instantly regretted it. (Although a very small portion of the code survived, thanks to me asking a question Wink)

Nowadays I don't delete projects just because I lost motivation. I simply leave it there. Who knows? Maybe I'll come back to it, and actually finish a game Smiley

16  Game Development / Newbie & Debugging Questions / Re: get cell in tiled map on: 2014-06-08 13:50:05
I'm not quite familiar with libtiled since I use Libgdx but this getTileAt(int tx, int ty) seems to do the trick
17  Discussions / General Discussions / Re: "No, You Can't Make Video Games" on: 2014-05-20 06:35:37
...Well that was discouraging...
18  Game Development / Newbie & Debugging Questions / Re: [Libgdx] Vector2 won't set on: 2014-05-15 06:10:35
1  
2  
cellAroundPlayer = new Vector2[4];
Arrays.fill(cellAroundPlayer, new Vector2());


You may think that you're filling the array slots with 4 distinct vector instances, but this is what actually happens:
1  
2  
3  
cellAroundPlayer = new Vector2[4];
Vector2 tmp = new Vector2();
Arrays.fill(cellAroundPlayer, tmp);
All your array slots refer to 1 Vector2 instance.

Do this instead:
1  
2  
3  
cellAroundPlayer = new Vector2[4];
for(int i=0; i<4; i++)
   cellAroundPlayer[i] = new Vector2();


Thanks! Grin I guess the way I used Arrays.fill before was probably different for what I am doing now...
19  Game Development / Newbie & Debugging Questions / [Solved] [Libgdx] Vector2 won't set on: 2014-05-15 05:23:56
So I have this code right here:

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  
//...
//put package and imports here
//...

public class Map implements Disposable {
    //...
    //put other variables here
    //...

    private Vector2[] cellAroundPlayer;
    private float offset;
 
    public Map(String mapTmx, float tileSize, float camTileSize, Player player1) {
        //...
        //other stuff here
        //...
        cellAroundPlayer = new Vector2[4];
        Arrays.fill(cellAroundPlayer, new Vector2());
        offset = 1f;
    }
   
    public void render() {
        //...
        System.out.println("Player Pos: " + player.getMiddleOriginX() + ", " + player.getMiddleOriginY());
        cellAroundPlayer[0].set((int)player.getMiddleOriginX(), (int)(player.getMiddleOriginY() + offset));
        cellAroundPlayer[1].set((int)player.getMiddleOriginX(), (int)(player.getMiddleOriginY() - offset));
        cellAroundPlayer[2].set((int)(player.getMiddleOriginX() + offset), (int)player.getMiddleOriginY());
        cellAroundPlayer[3].set((int)(player.getMiddleOriginX() - offset), (int)player.getMiddleOriginY());
       
        System.out.println("Cells around player: " + cellAroundPlayer[0] + ", " + cellAroundPlayer[1] + ", " + cellAroundPlayer[2] + ", " + cellAroundPlayer[3]);
       
        //...
    }
   
    //put other methods here
}


So you probably think: hmm a Vector2[4] which contains four Vector2()'s and they get set to the positions of the cells around the player.

The first println() says:
1  
Player Pos: 0.5, 3.5


So this means that (int)player.getMiddleOriginX() = 0 and (int)player.getMiddleOriginY() = 3 right?
And since offset = 1, this means that:

1  
2  
3  
4  
cellAroundPlayer[0] //0, 4
cellAroundPlayer[1] //0, 2
cellAroundPlayer[2] //1, 3
cellAroundPlayer[3] //-1, 3


(Note: 0, 1, 2, 3 means North, South, East and West)

But that's not what the second println() says!

1  
Cells around player: [0.0:3.0], [0.0:3.0], [0.0:3.0], [0.0:3.0]


What?

I could be doing something wrong, and that the answer is really obvious Clueless, but I couldn't seem to find it. Any help would be appreciated  Smiley
20  Discussions / Miscellaneous Topics / Re: What are Anti-Virus Developers Protecting us From? on: 2014-04-17 01:46:24
I use Avast and Malwarebytes, and they seem to do the trick for me

Although I'm pretty sure the best anti virus is Common Sense 2014 Smiley
21  Discussions / Miscellaneous Topics / Re: f.lux on: 2014-04-16 10:34:36
I use f.lux, and for me it makes me easier to see the monitor at night. One time, I accidentally disabled f.lux at night and as soon as the yellowish tint has gone I was immediately hit by the white glare my computer had.

If you are having problems with f.lux, maybe you can adjust the settings? I have my set somewhere between Daylight and Halogen because Halogen is two yellowish for me. Although if you are having experiences like getting eye sore , I guess maybe you should stop. F.lux isn't quite for everybody
22  Game Development / Newbie & Debugging Questions / Re: type as parameter. on: 2014-01-12 11:39:54
I need to stop looking for new posts and do some coding Cheesy

@cannonball
Could you explain yourself ?

Oops sorry, I misread your post Sad
23  Game Development / Newbie & Debugging Questions / Re: type as parameter. on: 2014-01-12 11:31:06
Did you try using Object and then casting it?
24  Discussions / General Discussions / Re: Do you customize your IDE (Eclipse?) on: 2013-09-16 12:03:03
I don't quite customize Eclipse since it always resets the settings every time I create a new workspace (unless there's a way to keep the settings as I've set them)
25  Game Development / Newbie & Debugging Questions / Re: Libgdx Orthographic Camera on: 2013-08-26 12:30:24
In the
resize(int width, int height)
method in your main class, go like this:

1  
2  
3  
camera.viewportWidth = width;
camera.viewportHeight = height;
camera.update();


Welp. Didn't knew it was that simple. Using this while setting the camera's y position to keep it at the bottom did the trick for me.

Thanks so much!
26  Game Development / Newbie & Debugging Questions / Libgdx Orthographic Camera on: 2013-08-26 11:32:12
I've have some problems with this, and hopefully you guys can help me with it  Smiley

I have a 800 x 600 area where the game would be. And I also have a 800 x 600 window. But the window would be resizable, and I don't want to stretch or have any black bars on the sides of the game. I just want it to still be 800 x 600, and bottom centered. (I've made sure that the windows can't be less than 800 x 600)

Something like this



I've fiddled around with the stage, camera and the resize function but nothing seems to be working  Sad
27  Java Game APIs & Engines / Tools Discussion / Re: Abundant Music: An online procedural music generator on: 2013-08-18 13:45:09
Sorry for bumping, but can I ask if you still have the midi for generative song I?
28  Game Development / Newbie & Debugging Questions / Re: Can games like Super Meat Boy or Binding of Isaac be recreated with Java? on: 2013-04-28 13:53:33
Anything could be recreated in Java.

This guy attempts to recreate the Binding of Isaac using only Java2D
Pages: [1]
 
orrenravid (189 views)
2016-07-16 03:57:23

theagentd (260 views)
2016-07-11 14:28:54

Hydroque (344 views)
2016-07-06 05:56:57

Hydroque (492 views)
2016-07-03 08:52:54

GrandCastle (375 views)
2016-07-01 09:13:47

GrandCastle (366 views)
2016-07-01 09:09:45

CopyableCougar4 (421 views)
2016-06-25 16:56:52

Hydroque (401 views)
2016-06-22 02:17:53

SwampChicken (365 views)
2016-06-20 13:22:57

SwampChicken (298 views)
2016-06-20 13:22:49
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17
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!