Search Results

Search found 4 results on 1 pages for 'gopgop'.

Page 1/1 | 1 

  • Checking if an object is inside bounds of an isometric chunk

    - by gopgop
    How would I check if an object is inside the bounds of an isometric chunk? for example I have a player and I want to check if its inside the bounds of this isometric chunk. I draw the isometric chunk's tiles using OpenGL Quads. My first try was checking in a square pattern kind of thing: e = object; this = isometric chunk; if (e.getLocation().getX() < this.getLocation().getX()+World.CHUNK_WIDTH*World.TILE_WIDTH && e.getLocation().getX() > this.getLocation().getX()) { if (e.getLocation().getY() > this.getLocation().getY() && e.getLocation().getY() < this.getLocation().getY()+World.CHUNK_HEIGHT*World.TILE_HEIGHT) { return true; } } return false; What happens here is that it checks in a SQUARE around the chunk so not the real isometric bounds. Image example: (THE RED IS WHERE THE PROGRAM CHECKS THE BOUNDS) What I have now: Desired check: Ultimately I want to do the same for each tile in the chunk. EXTRA INFO: Till now what I had in my game is you could only move tile by tile but now I want them to move freely but I still need them to have a tile location so no matter where they are on the tile their tile location will be that certain tile. then when they are inside a different tile's bounding box then their tile location becomes the new tile. Same thing goes with chunks. the player does have an area but the area does not matter in this case. and as long as the X and Y are inside the bounding box then it should return true. they don't have to be completely on the tile.

    Read the article

  • Scrolling though objects then creating a new instace of this object

    - by gopgop
    In my game when pressing the right mouse button you will place an object on the ground. all objects have the same super class (GameObject). I have a field called selected and will be equal to one certain gameobject at a time. when clicking the right mouse button it checks whats the instance of selected and that how it determines which object to place on the ground. code exapmle: t is the "slot" for which the object will go to. if (selected instanceof MapleTree) { t = new MapleTree(game,highLight); } else if (selected instanceof OakTree) { t = new OakTree(game,highLight); } Now it has to be a "new" instance of the object. Eventually my game will have hundreds of GameObjects and I don't want to have a huge if else statement. How would I make it so it scrolls though the possible kinds of objects and if its the correct type then create a new instance of it...? When pressing E it will switch the type of selected and is an if else statement as well. How would I do it for this too? here is a code example: if (selected instanceof MapleTree) { selected = new OakTree(game); } else if (selected instanceof OakTree) { selected = new MapleTree(game); }

    Read the article

  • OpenGL Lighting

    - by gopgop
    I have a simple day and night cycle by at day disabling OpenGL lighting and at night enabling openGL Lighting. When I enable everything appears darker. My question is How would I make it that at a specific spot there would be a light that will only light up its surrounding area for example: http://media.giantbomb.com/uploads/0/276/1414275-light_large.png Where the light is is where I want to position my light. My application is in 2D.

    Read the article

  • Converting Degrees to X and Y Coordinate change

    - by gopgop
    I am using a float positioning system in my game. IE float x,y,z now I want to get the location of the mouse, then to fire an arrow to it. X0 = the players X location X1 = the mouse X location Y0 = the players Y location Y1 = the mouse Y location I want to make a method that the parameters are Degrees and it sets my Yspeed and my Xspeed accordingly to get to the mouse xy starting at player xy How do would I accomplish this?

    Read the article

1