Search Results

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

Page 1/1 | 1 

  • How do I get information about the level to the player object?

    - by pangaea
    I have a design problem with my Player and Level class in my game. So below is a picture of the game. The problem is I don't want to move on the black space and only the white space. I know how to do this as all I need to do is get the check for the sf::Color::Black and I have methods to do this in the Level class. The problem is this piece of code void Game::input() { player.input(); } void Game::update() { (*level).update(); player.update(); } void Game::render() { (*level).render(); player.render(); } So as you there is a problem in that how do I get the map information from the Level class to the Player class. Now I was thinking if I made the Player position static and pass it into the Level as parameter in update I could do it. The problem is interaction. I don't know what to do. I could maybe make player go into the Level class. However, what if I want multiple levels? So I have big design problems that I'm trying to solve.

    Read the article

  • Rendering problems with Java LWJGL

    - by pangaea
    I'm new to rendering and so I don't know if I can speed up the code or that what I'm doing is bad. This is what it looks like But, if I have say 100-200 triangles everything is fine. Yet, when I get to 400 triangles it becomes very laggy. At 1,000 triangles it becomes 5fps at max. Also, when I try to close it everything becomes extremely laggy and the game breaks my computer. Is this normal? The code is here http://pastebin.com/9N6qdEbd game http://pastebin.com/fdkSrPGT mobs I haven't even adding collision detection.

    Read the article

  • Multithreading in lwjgl getting rid of sleep.

    - by pangaea
    I'm trying to use multithreading in my game. However, I can't seem to get rid of the sleep. If I don't it's a blank screen, as there is no time for the computer to actually render the triangleMob as it can't access getArrayList(), in my main class I have a TriangleMob arraylist. If I delay it, then it can access the previousMob and it renders. If I don't, then it's blank screen. Can I get rid of the delay? Also, is this a bad way to multithread? Surely, this should be fast. I need multithreading so can you please not suggest not using it. public class TriangleMob extends Thread implements Runnable { private static int count=0; private int objectDisplayList; private static ArrayList<TriangleMob> previousMob = new ArrayList<TriangleMob>(); private static ArrayList<TriangleMob> currentMob = new ArrayList<TriangleMob>(); private static ArrayList<TriangleMob> laterMob = new ArrayList<TriangleMob>(); private Vector3f position = new Vector3f(0f,0f,0f); private Vector3f movement = new Vector3f(0f,0f,0f); public TriangleMob() { // Create the display list CreateDisplayList(); count++; } public TriangleMob(Vector3f position) { // Create the display list CreateDisplayList(); this.position = position; count++; } private void CreateDisplayList() { objectDisplayList = glGenLists(1); glNewList(objectDisplayList, GL_COMPILE); { double topPoint = 0.75; glBegin(GL_TRIANGLES); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -0.75, -4); glColor4f(0, 0, 1, 1f); glVertex3d(1, -.75, -4); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(1, -0.75, -4); glColor4f(0, 0, 1, 1f); glVertex3d(1, -0.75, -6); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(1, -0.75, -6); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -.75, -6); glColor4f(1, 1, 0, 1f); glVertex3d(0, topPoint, -5); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -0.75, -6); glColor4f(0, 0, 1, 1f); glVertex3d(-1, -.75, -4); glEnd(); glColor4f(1, 1, 1, 1); } glEndList(); } public static int getCount() { return count; } public Vector3f getMovement() { return movement; } public Vector3f getPosition() { return position; } public synchronized int getObjectList() { return objectDisplayList; } public synchronized static ArrayList<TriangleMob> getArrayList(){ if(previousMob != null) { return previousMob; } previousMob.add(new TriangleMob()); return previousMob; } public synchronized void move(Vector3f movement) { // If you want to move in all 3 axis position.x += movement.x; position.y += movement.y; position.z += movement.z; } public synchronized void render() { glPushMatrix(); glTranslatef(-position.x, -position.y, -position.z); glCallList(objectDisplayList); glPopMatrix(); } public synchronized static void setTriangleMob(ArrayList<TriangleMob> triangleMobSet) { laterMob = triangleMobSet; } private synchronized void setPreTriangleMob(ArrayList<TriangleMob> currentMob2) { previousMob = currentMob2; } public void run(){ while(true) { if(laterMob == null) { currentMob = laterMob; System.out.println("Copying"); } for(int i=0; i<currentMob.size(); i++) { currentMob.get(i).move(new Vector3f(0.1f,0.01f,0.01f)); } setPreTriangleMob(currentMob); try { sleep(1L); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }

    Read the article

  • Lwjgl camera causing movement to be mirrored

    - by pangaea
    I'm having a problem in that everything is rendered and the movement is fine. However, everything seems to be mirrored. In the sense that the TriangleMob should move towards me, but it doesn't instead it mirrors my action. I move forward the TriangleMob moves backwards. I move left, it moves right. I move backwards, it moves forward. The code works if I do this glPushMatrix(); glTranslatef(-position.x, -position.y, -position.z); glCallList(objectDisplayList); glPopMatrix(); However, I'm scared this will cause a problem later on. I suppose the code works. However, shouldn't the call be glPushMatrix(); glTranslatef(position.x, position.y, position.z); glCallList(objectDisplayList); glPopMatrix(); I think the problem could be caused by how I'm doing the camera, which is this glLoadIdentity(); glRotatef(player.getRotation().x, 1.0f, 0.0f, 0.0f); glRotatef(player.getRotation().y, 0.0f, 1.0f, 0.0f); glRotatef(player.getRotation().z, 0.0f, 0.0f, 1.0f); glTranslatef(player.getPosition().x, player.getPosition().y, player.getPosition().z);

    Read the article

1