Hello, I am having a simple problem I cant quite sort out. I have a sprite that is being rotated to point towards the mouse position. I have this all working so far with degrees, 0-360 for both the mouse and object. My problem is when I come to the transition, when the angle changes abruptly from 0 to 360 degrees.

I have tried working with difference between the two angles, rather then working with the comparision of them, but I run into the same problem. (mouseAngle - shipAngle) and (shipAngle - mouseAngle) both have the same problem when the angle measurement flips from 0 to 360, or vice versa.

I failed to take into account the situation where (collidingY && collidingX), such as when the player is in a corner. I have tried putting the player back to their previous location, but that just causes a strange jiggle and no real progress.

I am struggling with some basic rectangle collision in my pacman clone, hoping for some help or simplification.

So I am using libgdx Tiled maps, in which I have made an object layer, and surrounded all the collide-able things with rectangles. My player is also represented as a rectangle, and I use these to handle collision.

Here is my problem graphically (I made debug render classes to help see the problem):

Holding right button, then right + up, when approaching corner.Holding right button and up button, player now stuck. Must press left, then up, to move up.

Essentially, I have sliding on the walls working, but when I get to a corner, the rectangles mash together and block movement. I want this to slide around the corner, and not get stuck.

I know this is probably something really simple I am overlooking, but I cant quite place my finger on it.

1. First I add a number to velX or velY based on input.2. Then I check the future player rectangle, using the velocities from 1. to determine if the player will collide in the X or Y directions.3. Finally, if the player is not colliding in X, move player in X.4. If the player is not colliding in Y, move player in Y.

It seems like I need to have code that says "As soon as the player can move up, move up and stop all X movement", but I cannot figure out how to implement it.

In my first attempt, each slot machine "reel" consists of 3 sprite images placed in a column. The images then flip to the next image, making a cheap sort of scrolling.

I'm interested in using an actual scrolling sprite to implement my slot machine reels, but I am confused how to do it. I found this tutorial https://code.google.com/p/libgdx-users/wiki/ScrollingTexture which helped me get the basics of scrolling a texture, but now I am struggling with indexing where the actual images are. Here is some code:

This successfully makes the image as large as I want, and also makes it scroll downwards like a slot machine reel would. Since my source image consists of 6 seperate images, each individual picture on the reel is some N/6 (thus the 3f/6f makes my reel display 3 images out of 6 at once).

My issue is identifying where the actual images are on the scrolling texture. When the player stops the reel, it needs to stop at the nearest actual image at the midpoint of the reel. This is quite tricky. Does anyone have any suggestions of how I would accomplish this? The V and V2 coordinates are a bit confusing.

Another method I considered was to compose a larger "reel" texture from the 6 individual textureRegions, and maybe use those as indexes somehow?

I'm a bit stumped with my project. I am using Tiled and libGDX, and I need to come up with a good way of interacting with different tiles. Currently, my player can only interact with one kind of tile but I need many more. Here is my working code at the moment:

So I ask the level for a tile layer, then check if the cell I'm looking at contains the property "crop".

My issue is that I need to do with with multiple types of tiles: signs, beds, water, doors, and chest. I know my current method will not scale up as well and will become a giant mess, and I need some help designing a more general kind of interaction system.

and creating one 2D array of these Interactions from all map layers combined (Code here: http://pastebin.java-gaming.org/e0c1e796e84). From there I would make more classes implementing that state IE: Sign Interaction extends Interaction. Does this system seem adequate? Has anyone else done something similar before and could share some tips with me?

I also am struggling a bit with states and how to interrupt gameplay for things like text boxes. I have GameStates:Play, Menu, etc, but for UI interrupting gameplay I feel that my Play state needs sub-states such as "playing", "dialog", etc. Any tips regarding this would be appreciated as well.

I'm finding it very hard to even understand how to solve the puzzle, let alone program something to do it for me.

There seems to be a somewhat random element in that after every move, a random block is chosen (of all blocks, including those with 2's already and excluding those with 4 and above), then a 2 is placed there.Sometimes this will make it look like a 4 was spawned.

Currently, my bot would spam WASDWASDWASDWASD. I have gotten over 5000 points with that method, though sometimes its as low as 2000.

I solved my original problem, it was a silly mistake where I hadn't told the for loop how many times to loop properly, in order to draw all the tiles.I also solved a coordinate grid problem between TMX maps and double for loop arrays.

Now I'm running into a tearing problem. Ive read all over threads here and other places about ways to fix this, but none seem to work.Note: this only happens every once in a while, not consistent, but will stick like this when I stand in certain places.

I tried looking into using MathUtils.round on my player X,Y before using them to update the camera, but my camera is scaled. So if I pass it Integers, the camera is really jumpy.

Hello! Im new to libgdx, and having some problems with drawing sprites over a tiled map. I got it to work successfully with the player sprite, but other sprites locked on map grid I cannot get to draw.

First: the explanation.I am drawing a whole map of tiles, but some of the tiles need to be "crop" tiles, where the player can plant seeds, farm, etc and have the plant image update for differing conditions (watered/not watered/growth level).

What I am doing at the moment is setting a specific tile property to "crop" in Tiled, then creating a new CropTile in the same position.

I think my problem might have to do with mixing coordinate planes, IE: libGDX uses bottom left (0,0) while my code is implying (0,0) top left? I understand more code is probably needed, please let me know what to share. I got this method to work well with the player Sprite, I just cant seem to figure out many tiles.

What is the best way to have drawn tiles on top of TiledMapRenderer? Should I be editing the tiles within the TMX file, or is my method acceptable? Should I be passing one SpriteBatch and Camera around everywhere?

I have a similar system, but I use a program called Tiled to draw my maps.Natively, Tiled outputs a few specific TMX map formats which you can get a java library to read (complicated), but I have had little success with.

I simply load my spritesheet into tiled, and draw a map. Then I export the .TMX map file as CSV. Once that is done, I simple open the .TMX with notepad, copy the relevant array of integers the program has made for me, and plunk it into my own text file. All I use tiled for is numbering the spritesheet really, though it has all kinds of advanced features.

This makes it really easy to design maps visually instead of with text.

None of the UI gets rendered, even ones which weren't within the original g2d.fillRect(64, 64, 640, 640) area. It seems like I need to cast my g2d back into g? Not sure how to solve this, I would appreciate some assistance.

Thanks to the tutorial, I figured it out. In the end I ran into a simple semantics problem.The code above references a "CanMove" method which checks a tile to see if the player can move there, while my collision layer was using the term "DetectCollision".

It took me a bit to figure out that (CanMove = true) != (DetectCollision = true). One says "yes you can move there", the other says "yes there is a collision".

Now I am trying to alter this new movement method so I can have similar movement as before. IE: Press button,ignore input, move player image a few pixels, repeat for X ticks until centered on a tile, allow input again.

Also! I noticed a slight bug in the tutorial code, which was mentioned. Even if the player wasnt moving, it continued to call the CanMove functions a total of 10+ times every tick.

You need to create a separate thread for your game when you're using JFrame. If you don't, you will have problems with JFrame.

The great tutorial maker arrives! I was just reading your tutorial linked above! Thanks for it, I'm just fiddling with the LWJGL keyboard stuff there.

Also, how would I go about making a seperate thread for my jframe? I have no experience with threads really.Here is my main, which pretty much just makes a frame and launches it. I assume I would have to modify this?

Hello, I'm working on a top down 2d game and am having some problems with collision detection. Here is a basic screenshot.

My issue involves buggy movement. If I spam movement keys near a wall, I can pass through and get stuck. I think my problem may be related to multiple threads, but I am not sure.

I have a text file grid of integers read in for collision, 1 = not passable, 0 = passable. My checkCollision function checks the proposed new player position for a collision, and disallows that movement if there is a tile.

Somewhere in here there is a bug going on. I know the detectcollision method is working properly as I debugged it with println's. It seems that sometimes, while I am actively "Moving", my direction can change and place me in a wall. Note that this code has double collision checking, I tried with one and it simply let me into impassable walls, with two checks i actually get stuck in the wall and cant move at all.

Can anyone help me out here. Is there a simpler way of getting animated tile movement?

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