:D我在Java中使用Swing做了迷宮遊戲。我的渲染只是因爲它
public void paintComponent(Graphics g)
{
super.paintComponent(g);
buffor = (Graphics2D)g;
double ca,sa,alfa,r,x=0,y=0,size;
buffor.setColor(Color.BLUE);
buffor.fillRect(0,0,639,240);
buffor.setColor(Color.GREEN);
buffor.fillRect(0,241,639,479);
alfa=ga-0.52359; ///the result how we see things
buffor.setColor(Color.WHITE);
int i;
for (i=0;i<640;i++)
{
if((map[(int)(y/64.0)][(int)(x/64.0)]=='e'))
{
buffor.setColor(Color.BLACK);
buffor.drawString("EXIT",330,330);
buffor.setColor(Color.WHITE);
}
ca=Math.cos(alfa); sa=Math.sin(alfa); r=0.0; x=gx; y=gy;
while((map[(int)(y/64.0)][(int)(x/64.0)]!='x') && (map[(int)(y/64.0)][(int)(x/64.0)]!='e'))
{
x=gx+r*sa;
y=gy+r*ca;
r=r+0.01;
}
r *= Math.cos(ga - alfa);
size=12000/r;
buffor.drawLine(i,240-(int)size,i,240+(int)size);
alfa=alfa+0.00163625;
}
buffor.drawImage(cross,289,209,null);
buffor.drawImage(logo,0,0,null);
System.out.println(""+ (int)(gy/64.0) + " " + (int)(gx/64.0) + " " + ga);
}
有Java3D但這總比WPF指出錯誤,不那麼容易IMO使用。
老兄,你用手工製作的多邊形做了迷宮?我也是!檢查了這一點:http://dl.dropbox.com/u/3045472/StackOverflow/labyrinth.exe – Marcelo 2010-10-26 12:59:25