俄罗斯方块实现
2009-09-09 00:00:00 来源:WEB开发网BoxItemManager类
Java代码
package com.zsyao.tetris;
import java.util.ArrayList;
import java.util.Random;
public class BoxItemManager
{
private static ArrayList<String> m_abs_box_item_list = new ArrayList<String>();
static
{
BoxItemManager.addAbsBoxItem("com.zsyao.tetris.item.BoxItem1");
BoxItemManager.addAbsBoxItem("com.zsyao.tetris.item.BoxItem2");
BoxItemManager.addAbsBoxItem("com.zsyao.tetris.item.BoxItem3");
BoxItemManager.addAbsBoxItem("com.zsyao.tetris.item.BoxItem4");
BoxItemManager.addAbsBoxItem("com.zsyao.tetris.item.BoxItem5");
BoxItemManager.addAbsBoxItem("com.zsyao.tetris.item.BoxItem6");
}
public static void addAbsBoxItem(String class_name)
{
m_abs_box_item_list.add(class_name);
}
public static AbsBoxItem getRandomAbsBox()
{
Random random = new Random();
int i_random = random.nextInt(m_abs_box_item_list.size());
try
{
return (AbsBoxItem)Class.forName(m_abs_box_item_list.get(i_random)).newInstance();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
}
更多精彩
赞助商链接