detu.java

来自「“贪食蛇”游戏小程序设计与制作。实现贪食蛇游戏的运行」· Java 代码 · 共 47 行

JAVA
47
字号
import java.awt.*;
import java.util.Vector;
import java.awt.Point;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Detu extends Vector{
	Point po;
	int i,j;
	GamePanel gp;
Detu(GamePanel gp){
	this.gp=gp;
}
public void detu_1(){

	for(i=11;i<18;i++){
		for(j=7;j<14;j++){
			po=new Point(i,j);
			this.insertElementAt(po,0);
			gp.screen[po.y][po.x].setBackground(Color.cyan);
			po=new Point(i+28,j);
			this.insertElementAt(po,0);
			gp.screen[po.y][po.x].setBackground(Color.cyan);
			po=new Point(i,j+25);
			this.insertElementAt(po,0);
			gp.screen[po.y][po.x].setBackground(Color.cyan);
			po=new Point(i+28,j+25);
			this.insertElementAt(po,0);
			gp.screen[po.y][po.x].setBackground(Color.cyan);
		}	
	}
}
public void detu_2(){
	for(i=0;i<23;i++){
		for(j=19;j<22;j++){
		
			po=new Point(i,j);
			this.insertElementAt(po,0);
			gp.screen[po.y][po.x].setBackground(Color.cyan);
			po=new Point(57-i,j);
			this.insertElementAt(po,0);
			gp.screen[po.y][po.x].setBackground(Color.cyan);
		}	
	}
}
	
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?