- 0
Logic problem in lingdx game development java
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
Download: Java All-in-One For Dummies, 7th Edition ($27 Value) — free for your email
By News Staff,
- ebook offer
- sponsored
- (and 3 more)
- 0 replies
- 3 views
-
Learn Java with Projects (worth $44.99) but free in exchange for your email
By News Staff,
- packt
- ebook offer
- (and 2 more)
- 0 replies
- 3 views
-
JavaScript from Frontend to Backend ($20.99 Value) FREE for your work email
By News Staff,
- ebook offer
- sponsored
- (and 3 more)
- 0 replies
- 3 views
-
- 0 replies
- 3 views
-
Job Ready Java ($24 value) free download for a Limited Time
By News Staff,
- ebook offer
- java
- (and 1 more)
- 0 replies
- 2 views
-
Question
sk21
I have been stuck on this problem for days now. This is a simple ball game. The problem is that I want to make the ball jump. The ball is inside a much bigger circle. This is the screenshot https://postimg.org/image/ru0os2jer/ or .
I will try to explain my code as much as possible. Firstly whenever the user inputs data, the setXPosition() is called, now this method just sets the X Position without considering the angle etc. Then setYPosition() is called through the update() which automatically sets the Y position based on the X position. now, this is a little bad way of doing this, because X position doesnt change relative to the angle, which it should. it makes the ball's Y position faster at sides and slower in the middle. Now, when it jumps, the jump() method is called. and the gravity() method is called whenever update() is called. the *630/11 is a little wrong, i have fixed it since then and it is being used to convert radians into degrees, now i am using Math.toRadians. the GameScreen.mainCircle is the bigger circle in the screenshot (the white one) .Then InnerInnerCircleRadius is just the radius at which the ball is drawn(basically, it is GameScreen.mainCircle-ball.radius)., I have used a different radius (GameScreen.INNER_CIRCLE_RADIUS), but that is just the GameScreen.mainCircle again. I hope the Game Screen code is not necessary so I have not posted it. if yout think it is, please tell me and I will post it. There are a few idiotic variables. please dont pay attention to them, I created them in desperation. I am still a very beginner programmer. and though, I have made games in libgdx before, nothing this complicated. I have tried everything, and couldn't solve it. according to me, the ball's X position should change when it jumps but it doesnt. The Y position changes perfectly. In setting the X position, the code should take in account either the angle or the InnerInnerCircleRadius. any help is appreciated.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts