?? paint.java
字號:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Paint{
OneSquareDown st;
public Paint(OneSquareDown st){
this.st=st;//指定繪圖區(qū)
}
//畫出磚塊組動作區(qū)地圖外框
public void DrawMapFrame(int x,int y,int wid,int hig,int side){
//定義多邊形坐標
int xx[][]={{x,x+wid,x+wid-side,x+side},//上
{x+wid-side,x+wid,x+wid,x+wid-side},//右
{x+side,x+wid-side,x+wid,x},//下
{x,x+side,x+side,x}};//左
int yy[][]={{y,y,y+side,y+side},//上
{y+side,y,y+hig,y+hig-side},//右
{y+hig-side,y+hig-side,y+hig,y+hig},//下
{y,y+side,y+hig-side,y+hig}};//左
//畫出多邊形
for(int i=0;i<=3;i++){
//不同邊設定不同顏色
switch(i){
case 0:
st.g.setColor(new Color(150,150,150));
break;
case 1:
st.g.setColor(new Color(150,150,150));
break;
case 2:
st.g.setColor(new Color(180,180,180));
break;
case 3:
st.g.setColor(new Color(180,180,180));
break;
}
st.g.fillPolygon(xx[i],yy[i],4);
st.g.setColor(Color.black);
st.g.fillRect(x+side-1,y+side-1,wid-side*2+2,hig-side*2+2);
}
}
//畫出磚塊組
public void DrawBrickGroup(int x,int y,int type,int direct,Color c){
Square sb=(Square)st.BrickArray.get(type);
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if(sb.BRICK_ARRAY[direct][i][j]==1){
DrawBrick((i+x),(j+y),c);
}
}
}
}
//清除前一個磚塊組
public void DrawBrickGroup(int fx,int fy,int fdirect){
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if((i+st.NOW_BRICK_X)>=0 && (i+st.NOW_BRICK_X)<st.GRIDX &&
(j+st.NOW_BRICK_Y)>=0 && (j+st.NOW_BRICK_Y)<st.GRIDY){
if(st.NowBrick.BRICK_ARRAY[fdirect][i][j]==1){
DrawBrick(i+fx,j+fy,Color.black);
}
}
}
}
//畫出現(xiàn)在磚塊組
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if((i+st.NOW_BRICK_X)>=0 && (i+st.NOW_BRICK_X)<st.GRIDX &&
(j+st.NOW_BRICK_Y)>=0 && (j+st.NOW_BRICK_Y)<st.GRIDY){
if(st.NowBrick.BRICK_ARRAY[st.NOW_BRICK_DIRECT][i][j]==1){
DrawBrick(i+st.NOW_BRICK_X,
j+st.NOW_BRICK_Y,
Color.blue);
}
}
}
}
}
//畫出單一磚塊
public void DrawBrick(int x,int y,Color c){
st.g.setColor(Color.black);
st.g.drawRect(x*st.BRICK_WIDTH+st.MAPX,y*st.BRICK_WIDTH+st.MAPY,
st.BRICK_WIDTH-1,st.BRICK_WIDTH-1);
st.g.setColor(c);
st.g.fill3DRect(x*st.BRICK_WIDTH+st.MAPX+st.BRICK_SIDE,
y*st.BRICK_WIDTH+st.MAPY+st.BRICK_SIDE,
st.BRICK_WIDTH-st.BRICK_SIDE*2,
st.BRICK_WIDTH-st.BRICK_SIDE*2,true);
}
//畫出字型
public void DrawFont(String str,int x,int y,int size,Color c,String fs){
Font f=new Font(fs,Font.BOLD,size);
st.g.setColor(c);
st.g.setFont(f);
st.g.drawString(str,x,y);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -