|
|
@ -29,6 +29,7 @@ import sig.JavaProjectTemplate; |
|
|
|
|
|
|
|
|
|
|
|
public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
JFrame window; |
|
|
|
JFrame window; |
|
|
|
|
|
|
|
static JavaProjectTemplate gameInstance; |
|
|
|
public int pixel[]; |
|
|
|
public int pixel[]; |
|
|
|
final int CIRCLE_PRECISION=32; |
|
|
|
final int CIRCLE_PRECISION=32; |
|
|
|
final int OUTLINE_COL=Color.BRIGHT_WHITE.getColor(); |
|
|
|
final int OUTLINE_COL=Color.BRIGHT_WHITE.getColor(); |
|
|
@ -63,12 +64,14 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
public static Panel p; |
|
|
|
public static Panel p; |
|
|
|
public static JFrame f; |
|
|
|
public static JFrame f; |
|
|
|
|
|
|
|
|
|
|
|
public static void InitializeEngine(){ |
|
|
|
public static void InitializeEngine(JavaProjectTemplate instance){ |
|
|
|
System.setProperty("sun.java2d.transaccel", "True"); |
|
|
|
System.setProperty("sun.java2d.transaccel", "True"); |
|
|
|
System.setProperty("sun.java2d.d3d", "True"); |
|
|
|
System.setProperty("sun.java2d.d3d", "True"); |
|
|
|
System.setProperty("sun.java2d.ddforcevram", "True"); |
|
|
|
System.setProperty("sun.java2d.ddforcevram", "True"); |
|
|
|
System.setProperty("sun.java2d.xrender", "True"); |
|
|
|
System.setProperty("sun.java2d.xrender", "True"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameInstance=instance; |
|
|
|
|
|
|
|
|
|
|
|
RENDERHINTS.put(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_SPEED); |
|
|
|
RENDERHINTS.put(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_SPEED); |
|
|
|
RENDERHINTS.put(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_DISABLE); |
|
|
|
RENDERHINTS.put(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_DISABLE); |
|
|
|
RENDERHINTS.put(RenderingHints.KEY_FRACTIONALMETRICS,RenderingHints.VALUE_FRACTIONALMETRICS_OFF); |
|
|
|
RENDERHINTS.put(RenderingHints.KEY_FRACTIONALMETRICS,RenderingHints.VALUE_FRACTIONALMETRICS_OFF); |
|
|
@ -97,7 +100,7 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
dt += System.nanoTime() - lastGameTime; |
|
|
|
dt += System.nanoTime() - lastGameTime; |
|
|
|
lastGameTime = System.nanoTime(); |
|
|
|
lastGameTime = System.nanoTime(); |
|
|
|
while (dt >= UPDATE_LOOP_NANOTIME) { |
|
|
|
while (dt >= UPDATE_LOOP_NANOTIME) { |
|
|
|
JavaProjectTemplate.updateGame(); |
|
|
|
gameInstance.updateGame(UPDATE_LOOP_NANOTIME/1000000000d); |
|
|
|
dt -= UPDATE_LOOP_NANOTIME; |
|
|
|
dt -= UPDATE_LOOP_NANOTIME; |
|
|
|
TIME += UPDATE_LOOP_NANOTIME; |
|
|
|
TIME += UPDATE_LOOP_NANOTIME; |
|
|
|
} |
|
|
|
} |
|
|
@ -231,7 +234,7 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public /* abstract */ void render(){ |
|
|
|
public /* abstract */ void render(){ |
|
|
|
JavaProjectTemplate.drawGame(); |
|
|
|
gameInstance.drawGame(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void FillCircle(Color col,double center_x,double center_y,double r) { |
|
|
|
public void FillCircle(Color col,double center_x,double center_y,double r) { |
|
|
@ -297,10 +300,12 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
nextScanLine = scanLine+1; |
|
|
|
nextScanLine = scanLine+1; |
|
|
|
do { |
|
|
|
do { |
|
|
|
for (int i=0;i<active_edges.size();i+=2) { |
|
|
|
for (int i=0;i<active_edges.size();i+=2) { |
|
|
|
|
|
|
|
if (i>=active_edges.size()-1) break; |
|
|
|
Edge e1 = active_edges.get(i); |
|
|
|
Edge e1 = active_edges.get(i); |
|
|
|
Edge e2 = active_edges.get(i+1); |
|
|
|
Edge e2 = active_edges.get(i+1); |
|
|
|
//System.out.println("Drawing from "+((int)Math.round(e1.x_of_min_y))+" to "+e2.x_of_min_y+" on line "+scanLine);
|
|
|
|
//System.out.println("Drawing from "+((int)Math.round(e1.x_of_min_y))+" to "+e2.x_of_min_y+" on line "+scanLine);
|
|
|
|
for (int x=(int)Math.round(e1.x_of_min_y);x<=e2.x_of_min_y;x++) { |
|
|
|
for (int x=(int)Math.round(e1.x_of_min_y);x<=e2.x_of_min_y;x++) { |
|
|
|
|
|
|
|
if (x<0||x>JavaProjectTemplate.WINDOW_WIDTH) continue; |
|
|
|
int index = (scanLine+(int)y_offset)*getWidth()+x+(int)x_offset; |
|
|
|
int index = (scanLine+(int)y_offset)*getWidth()+x+(int)x_offset; |
|
|
|
if (index<pixel.length&&index>=0) { |
|
|
|
if (index<pixel.length&&index>=0) { |
|
|
|
Draw(index,col.getColor()); |
|
|
|
Draw(index,col.getColor()); |
|
|
@ -388,11 +393,7 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
g2.dispose(); |
|
|
|
g2.dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
System.out.println("Invalid frame!"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
System.out.println("Invalid frame!"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
updateFPSCounter(); |
|
|
|
updateFPSCounter(); |
|
|
|
//System.out.println("Repaint "+frameCount++);
|
|
|
|
//System.out.println("Repaint "+frameCount++);
|
|
|
@ -573,7 +574,6 @@ public class Panel extends JPanel implements Runnable,KeyListener { |
|
|
|
sprite.getWidth()-(X-(int)xOffset): |
|
|
|
sprite.getWidth()-(X-(int)xOffset): |
|
|
|
(X-(int)xOffset)) |
|
|
|
(X-(int)xOffset)) |
|
|
|
+(int)x; |
|
|
|
+(int)x; |
|
|
|
|
|
|
|
|
|
|
|
if (((sprite.getImg().getRGB(X,Y)>>>24)&0xFF)==0||index<0||index>=pixel.length) { |
|
|
|
if (((sprite.getImg().getRGB(X,Y)>>>24)&0xFF)==0||index<0||index>=pixel.length) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|