Search Results

Search found 3 results on 1 pages for 'tifa'.

Page 1/1 | 1 

  • Push back rectangle where collision happens

    - by Tifa
    I have a tile collision on a game I am creating but the problem is once a collision happens for example a collision happens in right side my sprite cant move to up and bottom :( thats because i set the speed to 0. I thinks its wrong. here is my code: int startX, startY, endX, endY; float pushx = 0,pushy = 0; // move player if(Gdx.input.isKeyPressed(Input.Keys.LEFT)){ dx=-1; currentWalk = leftWalk; } if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)){ dx=1; currentWalk = rightWalk; } if(Gdx.input.isKeyPressed(Input.Keys.DOWN)){ dy=-1; currentWalk = downWalk; } if(Gdx.input.isKeyPressed(Input.Keys.UP)){ dy=1; currentWalk = upWalk; } sr.setProjectionMatrix(camera.combined); sr.begin(ShapeRenderer.ShapeType.Line); Rectangle koalaRect = rectPool.obtain(); koalaRect.set(player.getX(), player.getY(), pw, ph /2 ); float oldX = player.getX(), oldY = player.getY(); // THIS LINE WAS ADDED player.setXY(player.getX() + dx * Gdx.graphics.getDeltaTime() * 4f, player.getY() + dy * Gdx.graphics.getDeltaTime() * 4f); // THIS LINE WAS MOVED HERE FROM DOWN BELOW if(dx> 0) { startX = endX = (int)(player.getX() + pw); } else { startX = endX = (int)(player.getX() ); } startY = (int)(player.getY()); endY = (int)(player.getY() + ph); getTiles(startX, startY, endX, endY, tiles); for(Rectangle tile: tiles) { sr.rect(tile.x,tile.y,tile.getWidth(),tile.getHeight()); if(koalaRect.overlaps(tile)) { //dx = 0; player.setX(oldX); // THIS LINE CHANGED Gdx.app.log("x","hit " + player.getX() + " " + oldX); break; } } if(dy > 0) { startY = endY = (int)(player.getY() + ph ); } else { startY = endY = (int)(player.getY() ); } startX = (int)(player.getX()); endX = (int)(player.getX() + pw); getTiles(startX, startY, endX, endY, tiles); for(Rectangle tile: tiles) { if(koalaRect.overlaps(tile)) { //dy = 0; player.setY(oldY); // THIS LINE CHANGED //Gdx.app.log("y","hit" + player.getY() + " " + oldY); break; } } sr.rect(koalaRect.x,koalaRect.y,koalaRect.getWidth(),koalaRect.getHeight() / 2); sr.setColor(Color.GREEN); sr.end(); I want to push back the sprite when a collision happens but i have no idea how :D pls help

    Read the article

  • Is avoiding the private access specifier in PHP justified?

    - by Tifa
    I come from a Java background and I have been working with PHP for almost a year now. I have worked with WordPress, Zend and currently I'm using CakePHP. I was going through Cake's lib and I couldn't help notice that Cake goes a long way avoiding the "private" access specifier. Cake says Try to avoid private methods or variables, though, in favor of protected ones. The latter can be accessed or modified by subclasses, whereas private ones prevent extension or re-use. in this tutorial. Why does Cake overly shun the "private" access specifier while good OO design encourages its use i.e to apply the most restrictive visibility for a class member that is not intended to be part of its exported API? I'm willing to believe that "private" functions are difficult test, but is rest of the convention justified outside Cake? or perhaps it's just a Cake convention of OO design geared towards extensibility at the expense of being a stickler for stringent (or traditional?) OO design?

    Read the article

  • What is w componet [duplicate]

    - by Tifa
    This question already has an answer here: What does the graphics card do with the fourth element of a vector as the final position? 3 answers What is the W component on graphics programming. I read a blog about opengl that says that w must be equal to either 0 or 1 here. But the book I am currently reading has put w component to more than 1 value. So im kinda confuse what does it really do. The book I am reading is OpenGL es a quick start guide.

    Read the article

1