⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blood.java

📁 简单的贪吃蛇源码
💻 JAVA
字号:
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.Random;


public class Blood extends Block{
	public static final int BloodSize = 20 ;	
	public static final Color BloodColor = Color.RED ;	
	private static Random r = new Random();
	 Snake s;	
	public Blood(int x,int y,Snake s){
		super(x,y,BloodColor);
		this.s = s;
		 this.x = x;
		 this.y = y;		 
	}
	
	public void paint(Graphics g){			
		super.Draw(g);		
	}
	
	public void chang(){			
			this.x = r.nextInt(Snake.GameWidth-20);			
			this.y = r.nextInt(Snake.GameHeight-50)+30;
			if(s.h.EatBlood(this)){
				chang();
			}
			else if(s.y.pongBlood(this)){
				chang();
			}
	}	

	public Rectangle getRect() {
		return new Rectangle(x, y, BloodSize , BloodSize);
	}
	
	
}

⌨️ 快捷键说明

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