• Content count

  • Joined

  • Last visited

Community Reputation

130 Neutral

About manderin87

  • Rank
  1. My first game to be released on google play. The game is only available on tablets due to higher screen space required, however I am looking into making a version for phones. Description An asteroids - like game in which you destroy asteroids and survive for as long as you can. You control a gunship and collect power ups and survive wave after wave of asteroids coming from every direction in space. Explode asteroids in brilliant color and crystal shards. Can you survive the onslaught? Avaliable here Thanks
  2. Ive rechecked everything... The rotation code was the problem.... I made two lists to keep track of the points... the original points and the rotated points. Both were pointing to the same object, i thought they were seperate, but they were not... so I just made both lists create a new point when adding to the list. The rotation is now correct. Here is the polygon constructor [CODE] public Polygon(Point... points) { if(points.length < 3) { throw new IllegalArgumentException("polygons must contain at least 3 points."); } for(Point p : points) { mRotatedPoints.add(new Point(p)); mOriginalPoints.add(new Point(p)); } } [/CODE] And the rotation code. [CODE] public void rotate(float x0, float y0, float degree) { for(int i = 0; i < mOriginalPoints.size(); i++) { Point point = mOriginalPoints.get(i); float x = (float) (x0 + (point.x - x0) * Math.cos(Utilities.toRadians(degree)) - (point.y - y0) * Math.sin(Utilities.toRadians(degree))); float y = (float) (y0 + (point.x - x0) * Math.sin(Utilities.toRadians(degree)) + (point.y - y0) * Math.cos(Utilities.toRadians(degree))); Point p = mRotatedPoints.get(i); p.x = x; p.y = y; } [/CODE] thanks everyone for the help and forgive my idiocy for not noticing they were they same instead of being seperate.
  3. [quote name='Khatharr' timestamp='1354244657' post='5005545'] while(mDegree >= 360) {mDegree -= 360;} while(mDegree < 0) {mDegree += 360;} [/quote] Didnt fix it. I know it has to be something wrong with the polygone rotation, its not working correctly. Ive stared at it for hours and i dont know what the problem is. Ive checked several places and the algorithm seems to be correct, but its not rotating correctly.
  4. [quote name='Khatharr' timestamp='1354244436' post='5005544'] Does SpriteBatch::draw() want degrees or radians? [/quote] Degrees
  5. Its the same thing... my Utilities.toRadians() calls Math.toRadians()
  6. This method is better for fixing the degree but it didnt change the behavior that I am experiencing [CODE] if(mDegree >= 360) { mDegree -= 360; } else if(mDegree < 0) { mDegree += 360; } [/CODE]
  7. the draw method i use is above, but spritebatch deffinitely uses degrees its located here [url=""][/url]
  8. They both recieve the same mDegree value. Could it be something with the way i move the degree past 0? [CODE] if(mDegree > 360) { mDegree = 0; } else if(mDegree < 0) { mDegree = 360; } [/CODE]
  9. The polygon rotation method is [CODE] public void rotate(float x0, float y0, double angle) { Log.i("Polygon", "Degree: " + angle); for(int i = 0; i < mPoints.size(); i++) { Point point = mPoints.get(i); float x = (float) (x0 + (point.x - x0) * Math.cos(Utilities.toRadians(angle)) - (point.y - y0) * Math.sin(Utilities.toRadians(angle))); float y = (float) (y0 + (point.x - x0) * Math.sin(Utilities.toRadians(angle)) + (point.y - y0) * Math.cos(Utilities.toRadians(angle))); point.x = x; point.y = y; } } [/CODE] The sprite rotation is done through a libgdx spritebatch and I am certain its correct. [CODE] public void draw(SpriteBatch batch, float x, float y, float degree) { batch.draw(mImage, x - width() / 2, y - height() / 2, pivotX(), pivotY(), width(), height(), mScale, mScale, degree, 0, 0, (int) width(), (int) height(), false, false); } [/CODE] The delta time comes from libgdx and is the time since last frame. [CODE] float deltaTime =; [/CODE] I am almost certain its something in the polygon rotation code... I was testing it... it would rotate until a certain point and then go the other way.
  10. There is something wrong with the polygon rotation method... I watched the degrees subtract and the polygon was still rotating the other way.. as the degree increased it went left as the degree decreased it still went left, instead of right.
  11. While trying to check, i made the rotation manual.... the polygon is still rotating faster. Its not the framerate, its the way the polygon is rotating using the polygon rotation method above or the method used to rotate the sprite.
  12. I dont know if it makes a difference but I am using libgdx to draw everything.
  13. I added to the rotate method [source lang="java"]mDegree += mRotationSpeed * deltaTime[/source] This fixed the polygon rotation a little, it doesnt rotate as fast as it did, but it still rotates much faster than the object.
  14. [quote name='BCullis' timestamp='1354214546' post='5005393'] In case my previous post got skipped, you DON'T WANT to establish a "per frame" rate, as you can't necessarily control the varying length of time it takes to process each frame. Ex: your player is facing a wall that takes up 95% of their view and isn't moving. That frame only takes 2ms to process. Then they turn around, facing 2000 props, 12 animated enemies, and dozens of particle streams. That frame takes 17ms to process. Your triangle would be spinning like crazy at the 2ms/frame, and then slow down considerably at the 17ms/frame. Rotate at a fixed time rate, not frame rate. That's why you want to use deltaTime, correctly, and why when you weren't bothering to use deltaTime it sped up and slowed down. [/quote] That certainly sounds like what is going on, should i just multply the rotation speed by the deltatime? The behaivor happened even when deltaTime wasnt there. [quote name='Álvaro' timestamp='1354215341' post='5005398'] I don't think it's an issue with the frame rate. The only suspicious part in how the code in the first post handles the frames is that there is a call to drawBounding() inside of the loop that updates the state, which seems wrong. Either the update happens independently of the drawing or --if update() is responsible for drawing-- the drawing should only happen once, at the end of the function. [/quote] The drawBounding() was relocated from the rendering loop so i could see if it had any effect. Its been moved back since, but the behaivor never changed.
  15. [quote name='Álvaro' timestamp='1354213068' post='5005386'] mDegree should be how much to rotate by this frame. It should not grow with time. What rotate() is doing is increase the rotation speed. EDIT: Wait... I think I see what the others are seeing now. Is it possible that mOrigins and mPoints are actually the same thing? FURTHER EDIT: What does this line do? [quote][code] Point npoint = mPoints.get(i);[/code][/quote] [/quote] There are two lists of points inside the polygon class. The original points mOrigin and the current points mPoints. mPoints changes and mOrigin does not with the rotation. That code takes the point i from mPoints and updates it. The rotate method just applies the .5f to increase the degree... The speed never increases, its always .5f and mDegree is increased by that amount each update.