2014-02-12 3 views
-1

Мои два класса LWJGL дают мне ошибку, и я предполагаю, что это как-то связано с кубом, который я сделал, поскольку он не отображается!Мои классы Java, дающие мне ошибки

Ошибка: Иерархия типа stonehearth_display/stonehearth_cube противоречива

stonehearth_display:

package com.mime.stonehearth; 

import org.lwjgl.LWJGLException; 
import org.lwjgl.opengl.Display; 
import org.lwjgl.opengl.DisplayMode; 

public class stonehearth_display extends stonehearth_cube{ 

    public static void main(String[] args) { 
     try { 
      Display.setDisplayMode(new DisplayMode(800, 600)); 
      Display.setTitle("Stonehearth Pre-Alpha 0.0.1"); 
      Display.create(); 
     } catch (LWJGLException e) { 
      System.err.println("Display wasn't initialized correctly."); 
      System.exit(1); 
     } 

     try { 
      render(); 

      angle = (angle+1)%360; 
     } 


     while (!Display.isCloseRequested()) { 
      Display.update(); 
      Display.sync(60); 
     } 

     Display.destroy(); 
     System.exit(0); 

    } 

} 

stonehearth_cube.java

package com.mime.stonehearth; 

import static org.lwjgl.opengl.GL11.*; 
import org.lwjgl.opengl.Display; 
import org.lwjgl.opengl.DisplayMode; 



public class stonehearth_cube extends stonehearth_display{ 


     int angle = 0 ; 

    public void render(){ 

     float edgeLength= 20.0f; 
     edgeLength /= 2.0f; 

     glMatrixMode(GL_PROJECTION); 
     glLoadIdentity(); 
     glOrtho(0.0f, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight(), 0.0f, -50.0f, 50.0f); 
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 
     glPushMatrix(); 
     glTranslatef((Display.getWidth()/2), (Display.getHeight()/2), 0.0f); 
     glRotatef(angle, 1.0f, 1.0f, 1.0f); 
     glBegin(GL_TRIANGLES); 

     //Back 

     glColor3f(1.0f, 0.0f, 0.0f); 
     glVertex3f(-edgeLength, edgeLength, edgeLength); 
     glVertex3f(-edgeLength, -edgeLength, edgeLength); 
     glVertex3f(edgeLength, -edgeLength, edgeLength); 
     glVertex3f(-edgeLength, edgeLength, edgeLength); 
     glVertex3f(edgeLength, edgeLength, edgeLength); 
     glVertex3f(edgeLength, -edgeLength, edgeLength); 

     //Front 

     glColor3f(0.0f, 0.0f, 1.0f); 
     glVertex3f(-edgeLength, edgeLength, -edgeLength); 
     glVertex3f(-edgeLength, -edgeLength, -edgeLength); 
     glVertex3f(edgeLength, -edgeLength, -edgeLength); 
     glVertex3f(-edgeLength, edgeLength, -edgeLength); 
     glVertex3f(edgeLength, edgeLength, -edgeLength); 
     glVertex3f(edgeLength, -edgeLength, -edgeLength); 

     // Right 
     glColor3f(1.0f, 1.0f, 1.0f); 
     glVertex3f(edgeLength, edgeLength, -edgeLength); 
     glVertex3f(edgeLength, -edgeLength, -edgeLength); 
     glVertex3f(edgeLength, -edgeLength, edgeLength); 
     glVertex3f(edgeLength, edgeLength, -edgeLength); 
     glVertex3f(edgeLength, edgeLength, edgeLength); 
     glVertex3f(edgeLength, -edgeLength, edgeLength); 

     glEnd(); 
     glPopMatrix(); 
    } 
} 

} 
+6

У вас есть наследование кругового класса. Как это имеет смысл для вас? –

ответ

0

Вы не можете иметь классы, унаследованные им самим или ее ChildClass.

stone_cube -> stone_display -> stone_cube -> stone_display ...

ли вы поймать его?

Мне нужно только унаследовать stone_cube от stone_display, после этого вы должны создать другое, где создаете один камень_дисплей или один камень-кубик и делаете что-нибудь.

Смежные вопросы