快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

斗兽棋java小程序代码 斗兽棋python

斗兽棋怎么玩啊?

斗兽棋是一种运用阶级吃子的版图益智类游戏,游戏双方在9x7格的版图上操作八只以动物命名的棋子,其中任意一方棋子走进对方兽穴或吃光对方所有棋子者胜。

成都创新互联公司公司2013年成立,先为米东等服务建站,米东等地企业,进行企业商务咨询服务。为米东企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

游戏中双方各有八只棋子,依大小顺序为象、狮、虎、豹、狗、狼、猫、鼠。大的可以吃小的,同类可以互吃,而鼠则可以吃象,象不能吃鼠。

斗兽棋是尘模一种棋类游戏,双方有八只棋子,依大小顺序为象、狮、虎、豹、犬、狼、猫、鼠。较大的可吃较小的,同类可以互吃,而鼠则可吃象,象不能吃鼠。动物走一格,前后左右都可以。

棋盘横七列,纵九行。棋子放在格子中。双方底在线各有三个陷阱(作品字排)和一个兽穴(于品字中间)。如果一方进入了对方的兽穴便胜出。任何一方都不能进入自己的兽穴。如果对方的兽类走进陷阱,己方任何一只兽都可以把它吃掉,如果敌兽进入陷阱,一回合后,自己的兽类不吃掉陷阱中的敌兽,当对方进入己方兽穴时,则本方输。中间有两条小河(跟湖差不多)。狮、虎可以横直方向跳过河,而且可以直接把对岸的动物吃掉。只有鼠可以下水,在水中的鼠可以阻隔狮、虎跳河。两鼠在水内可以互吃。

部份斗兽棋的次序略有不同:象、狮、虎、豹、狼、狗、猫、鼠 。 亦有狗吃狼的。亦有用狐代替狼的:象、狮、虎、豹、狗、狐、猫、鼠。水里的不可直接吃陆上的,陆上的也不可吃水里的。

普通吃法

普通吃法:象〉狮〉虎〉豹〉狗(犬)〉狼〉猫〉鼠。

特殊吃法

斗兽棋特殊吃法说明如下:

1、鼠吃象法:八兽的吃法除按照大小次序外,惟鼠能吃象。

2、互吃法:凡同类相遇,可互相吃。

3、陷阱:棋盘设陷阱,专为限制敌兽的战斗力(自己的兽,不受限制),敌兽走入陷阱,即失去战斗力,本方的任意兽类都可以吃去陷阱里的兽类。每方在兽穴旁设三个陷阱。

4、 胜负:无论任何一方的兽走入敌方的兽穴就算胜利(自己的兽类不可以走入自己的兽穴),胜利方按级别取得赢分,失败方扣2分。一方提议作和,对方同意此时作和,和局双方不扣分。

在电脑游戏中的碰姿异常处理双方走棋出现循环反复达三次以上,首先走棋的人如不变着作认输论处。

2、游戏进行中不正常离局者,断线次数加1次,并扣十分游戏金币数。

3、若是某个玩家在规定时间内没有任何响应,游戏程序将替他停棋一步,并增加超时一次,三次以上超时(不包括三次)作认输论处。

4规则玩法

基本规则

棋盘:9x7格

斗兽棋棋盘和棋子:斗兽棋棋子共十六个,分为红黄两组,各八个,由双方各执一组,兽类是一样。

分为八种:

红派吵缓方:象、狮、虎、豹、狼、狗(犬)、猫、鼠

黄方:象、狮、虎、豹、狼、狗(犬)、猫、鼠

棋子活动的场所,叫做“棋盘”,在长方形的平面上,有横九竖七共六十三个格子组成,棋子就摆在这些格子内。棋盘内有两条小河,河上有三座桥可以通过。

基本玩法

每只动物每次走一方格,前后左右均可,但是狮、虎、鼠三种兽类,还有不同走法,说明如下:

1、狮虎跳河法:棋盘中有两条河,狮虎过河,可以纵横对直跳过,并且在跳得方格内,也能把敌方较小的兽类吃掉,但是如果老鼠在河里,把跳的路线阻隔就不能跳。

2、鼠入水中法:鼠过河可以走入水中(走法同陆地),如鼠在河里,陆地上的兽类都不能吃它,鼠亦不能吃陆地上的象。当两鼠在河内相遇,可以互吃。

急需用eclipse写的小游戏代码 比如贪吃蛇,五子棋,猜数字,俄罗斯方块等的小游戏代码

新建一个project,新建一个哪派闹类

把代码贴进去,找到运行(run)这个按钮,按了就能运行,找不到的话快捷键是Ctrl + F11

import java.awt.Color;

import java.awt.Component;

import java.awt.Graphics;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import java.util.ArrayList;

import javax.swing.BorderFactory;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JPanel;

public class SnakeGame {

public static void main(String[] args) {

SnakeFrame frame = new SnakeFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

}

}

/羡闷/ ----------记录状态的线程李罩

class StatusRunnable implements Runnable {

public StatusRunnable(Snake snake, JLabel statusLabel, JLabel scoreLabel) {

this.statusLabel = statusLabel;

this.scoreLabel = scoreLabel;

this.snake = snake;

}

public void run() {

String sta = "";

String spe = "";

while (true) {

switch (snake.status) {

case Snake.RUNNING:

sta = "Running";

break;

case Snake.PAUSED:

sta = "Paused";

break;

case Snake.GAMEOVER:

sta = "GameOver";

break;

}

statusLabel.setText(sta);

scoreLabel.setText("" + snake.score);

try {

Thread.sleep(100);

} catch (Exception e) {

}

}

}

private JLabel scoreLabel;

private JLabel statusLabel;

private Snake snake;

}

// ----------蛇运动以及记录分数的线程

class SnakeRunnable implements Runnable {

public SnakeRunnable(Snake snake, Component component) {

this.snake = snake;

this点抗 ponent = component;

}

public void run() {

while (true) {

try {

snake.move();

component.repaint();

Thread.sleep(snake.speed);

} catch (Exception e) {

}

}

}

private Snake snake;

private Component component;

}

class Snake {

boolean isRun;// ---------是否运动中

ArrayListNode body;// -----蛇体

Node food;// --------食物

int derection;// --------方向

int score;

int status;

int speed;

public static final int SLOW = 500;

public static final int MID = 300;

public static final int FAST = 100;

public static final int RUNNING = 1;

public static final int PAUSED = 2;

public static final int GAMEOVER = 3;

public static final int LEFT = 1;

public static final int UP = 2;

public static final int RIGHT = 3;

public static final int DOWN = 4;

public Snake() {

speed = Snake.SLOW;

score = 0;

isRun = false;

status = Snake.PAUSED;

derection = Snake.RIGHT;

body = new ArrayListNode();

body.add(new Node(60, 20));

body.add(new Node(40, 20));

body.add(new Node(20, 20));

makeFood();

}

// ------------判断食物是否被蛇吃掉

// -------如果食物在蛇运行方向的正前方,并且与蛇头接触,则被吃掉

private boolean isEaten() {

Node head = body.get(0);

if (derection == Snake.RIGHT (head.x + Node.W) == food.x

head.y == food.y)

return true;

if (derection == Snake.LEFT (head.x - Node.W) == food.x

head.y == food.y)

return true;

if (derection == Snake.UP head.x == food.x

(head.y - Node.H) == food.y)

return true;

if (derection == Snake.DOWN head.x == food.x

(head.y + Node.H) == food.y)

return true;

else

return false;

}

// ----------是否碰撞

private boolean isCollsion() {

Node node = body.get(0);

// ------------碰壁

if (derection == Snake.RIGHT node.x == 280)

return true;

if (derection == Snake.UP node.y == 0)

return true;

if (derection == Snake.LEFT node.x == 0)

return true;

if (derection == Snake.DOWN node.y == 380)

return true;

// --------------蛇头碰到蛇身

Node temp = null;

int i = 0;

for (i = 3; i body.size(); i++) {

temp = body.get(i);

if (temp.x == node.x temp.y == node.y)

break;

}

if (i body.size())

return true;

else

return false;

}

// -------在随机的地方产生食物

public void makeFood() {

Node node = new Node(0, 0);

boolean isInBody = true;

int x = 0, y = 0;

int X = 0, Y = 0;

int i = 0;

while (isInBody) {

x = (int) (Math.random() * 15);

y = (int) (Math.random() * 20);

X = x * Node.W;

Y = y * Node.H;

for (i = 0; i body.size(); i++) {

if (X == body.get(i).x Y == body.get(i).y)

break;

}

if (i body.size())

isInBody = true;

else

isInBody = false;

}

food = new Node(X, Y);

}

// ---------改变运行方向

public void changeDerection(int newDer) {

if (derection % 2 != newDer % 2)// -------如果与原来方向相同或相反,则无法改变

derection = newDer;

}

public void move() {

if (isEaten()) {// -----如果食物被吃掉

body.add(0, food);// --------把食物当成蛇头成为新的蛇体

score += 10;

makeFood();// --------产生食物

} else if (isCollsion())// ---------如果碰壁或自身

{

isRun = false;

status = Snake.GAMEOVER;// -----结束

} else if (isRun) {// ----正常运行(不吃食物,不碰壁,不碰自身)

Node node = body.get(0);

int X = node.x;

int Y = node.y;

// ------------蛇头按运行方向前进一个单位

switch (derection) {

case 1:

X -= Node.W;

break;

case 2:

Y -= Node.H;

break;

case 3:

X += Node.W;

break;

case 4:

Y += Node.H;

break;

}

body.add(0, new Node(X, Y));

// ---------------去掉蛇尾

body.remove(body.size() - 1);

}

}

}

// ---------组成蛇身的单位,食物

class Node {

public static final int W = 20;

public static final int H = 20;

int x;

int y;

public Node(int x, int y) {

this.x = x;

this.y = y;

}

}

// ------画板

class SnakePanel extends JPanel {

Snake snake;

public SnakePanel(Snake snake) {

this.snake = snake;

}

public void paintComponent(Graphics g) {

super.paintComponent(g);

Node node = null;

for (int i = 0; i snake.body.size(); i++) {// ---红蓝间隔画蛇身

if (i % 2 == 0)

g.setColor(Color.blue);

else

g.setColor(Color.yellow);

node = snake.body.get(i);

g.fillRect(node.x, node.y, node.H, node.W);// *******************试用*********************

}

node = snake.food;

g.setColor(Color.red);

g.fillRect(node.x, node.y, node.H, node.W);

}

}

class SnakeFrame extends JFrame {

private JLabel statusLabel;

private JLabel speedLabel;

private JLabel scoreLabel;

private JPanel snakePanel;

private Snake snake;

private JMenuBar bar;

JMenu gameMenu;

JMenu helpMenu;

JMenu speedMenu;

JMenuItem newItem;

JMenuItem pauseItem;

JMenuItem beginItem;

JMenuItem helpItem;

JMenuItem aboutItem;

JMenuItem slowItem;

JMenuItem midItem;

JMenuItem fastItem;

public SnakeFrame() {

init();

ActionListener l = new ActionListener() {

public void actionPerformed(ActionEvent e) {

if (e.getSource() == pauseItem)

snake.isRun = false;

if (e.getSource() == beginItem)

snake.isRun = true;

if (e.getSource() == newItem) {

newGame();

}

// ------------菜单控制运行速度

if (e.getSource() == slowItem) {

snake.speed = Snake.SLOW;

speedLabel.setText("Slow");

}

if (e.getSource() == midItem) {

snake.speed = Snake.MID;

speedLabel.setText("Mid");

}

if (e.getSource() == fastItem) {

snake.speed = Snake.FAST;

speedLabel.setText("Fast");

}

}

};

pauseItem.addActionListener(l);

beginItem.addActionListener(l);

newItem.addActionListener(l);

aboutItem.addActionListener(l);

slowItem.addActionListener(l);

midItem.addActionListener(l);

fastItem.addActionListener(l);

addKeyListener(new KeyListener() {

public void keyPressed(KeyEvent e) {

switch (e.getKeyCode()) {

// ------------方向键改变蛇运行方向

case KeyEvent.VK_DOWN://

snake.changeDerection(Snake.DOWN);

break;

case KeyEvent.VK_UP://

snake.changeDerection(Snake.UP);

break;

case KeyEvent.VK_LEFT://

snake.changeDerection(Snake.LEFT);

break;

case KeyEvent.VK_RIGHT://

snake.changeDerection(Snake.RIGHT);

break;

// 空格键,游戏暂停或继续

case KeyEvent.VK_SPACE://

if (snake.isRun == true) {

snake.isRun = false;

snake.status = Snake.PAUSED;

break;

}

if (snake.isRun == false) {

snake.isRun = true;

snake.status = Snake.RUNNING;

break;

}

}

}

public void keyReleased(KeyEvent k) {

}

public void keyTyped(KeyEvent k) {

}

});

}

private void init() {

speedLabel = new JLabel();

snake = new Snake();

setSize(380, 460);

setLayout(null);

this.setResizable(false);

bar = new JMenuBar();

gameMenu = new JMenu("Game");

newItem = new JMenuItem("New Game");

gameMenu.add(newItem);

pauseItem = new JMenuItem("Pause");

gameMenu.add(pauseItem);

beginItem = new JMenuItem("Continue");

gameMenu.add(beginItem);

helpMenu = new JMenu("Help");

aboutItem = new JMenuItem("About");

helpMenu.add(aboutItem);

speedMenu = new JMenu("Speed");

slowItem = new JMenuItem("Slow");

fastItem = new JMenuItem("Fast");

midItem = new JMenuItem("Middle");

speedMenu.add(slowItem);

speedMenu.add(midItem);

speedMenu.add(fastItem);

bar.add(gameMenu);

bar.add(helpMenu);

bar.add(speedMenu);

setJMenuBar(bar);

statusLabel = new JLabel();

scoreLabel = new JLabel();

snakePanel = new JPanel();

snakePanel.setBounds(0, 0, 300, 400);

snakePanel.setBorder(BorderFactory.createLineBorder(Color.darkGray));

add(snakePanel);

statusLabel.setBounds(300, 25, 60, 20);

add(statusLabel);

scoreLabel.setBounds(300, 20, 60, 20);

add(scoreLabel);

JLabel temp = new JLabel("状态");

temp.setBounds(310, 5, 60, 20);

add(temp);

temp = new JLabel("分数");

temp.setBounds(310, 105, 60, 20);

add(temp);

temp = new JLabel("速度");

temp.setBounds(310, 55, 60, 20);

add(temp);

speedLabel.setBounds(310, 75, 60, 20);

add(speedLabel);

}

private void newGame() {

this.remove(snakePanel);

this.remove(statusLabel);

this.remove(scoreLabel);

speedLabel.setText("Slow");

statusLabel = new JLabel();

scoreLabel = new JLabel();

snakePanel = new JPanel();

snake = new Snake();

snakePanel = new SnakePanel(snake);

snakePanel.setBounds(0, 0, 300, 400);

snakePanel.setBorder(BorderFactory.createLineBorder(Color.darkGray));

Runnable r1 = new SnakeRunnable(snake, snakePanel);

Runnable r2 = new StatusRunnable(snake, statusLabel, scoreLabel);

Thread t1 = new Thread(r1);

Thread t2 = new Thread(r2);

t1.start();

t2.start();

add(snakePanel);

statusLabel.setBounds(310, 25, 60, 20);

add(statusLabel);

scoreLabel.setBounds(310, 125, 60, 20);

add(scoreLabel);

}

}

斗兽棋的玩法

斗兽棋的正确玩法:游戏开始时,红方先走,然后轮饥毕流走棋。每次可走动一只兽,每只兽每次走一方格,除己方兽穴和小河以外,前后左右均可。

斗兽棋是一款非常有趣的对战皮手棋类游戏,游戏的基本还是利用传统的对战的方式,但是,游戏却没有用传统的文字作为棋子,而是创造性的将棋子改成了动物,真正的符合了斗兽棋这个名字,趣味无穷。 游戏分为红蓝两方,每方8颗棋子,棋子按照大小顺序象狮虎豹狼狗猫鼠进行吃子,鼠能吃象。谁的燃肢嫌棋子最先被吃完,谁就输掉了这场比赛


网页题目:斗兽棋java小程序代码 斗兽棋python
文章路径:http://6mz.cn/article/ddpihho.html

其他资讯