今天给各位分享java游戏服务端源码的知识,其中也会对游戏客户端源码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
求java小游戏源代码
表1. CheckerDrag.java
// CheckerDrag.javaimport java.awt.*;import java.awt.event.*;public class CheckerDrag extends java.applet.Applet{ // Dimension of checkerboard square. // 棋盘上每个小方格的尺寸 final static int SQUAREDIM = 40; // Dimension of checkerboard -- includes black outline. // 棋盘的尺寸 – 包括黑色的轮廓线 final static int BOARDDIM = 8 * SQUAREDIM + 2; // Dimension of checker -- 3/4 the dimension of a square. // 棋子的尺寸 – 方格尺寸的3/4 final static int CHECKERDIM = 3 * SQUAREDIM / 4; // Square colors are dark green or white. // 方格的颜色为深绿色或者白色 final static Color darkGreen = new Color (0, 128, 0); // Dragging flag -- set to true when user presses mouse button over checker // and cleared to false when user releases mouse button. // 拖动标记 --当用户在棋子上按下鼠标按键时设为true, // 释放鼠标按键时设为false boolean inDrag = false; // Left coordinate of checkerboard's upper-left corner. // 棋盘左上角的左方向坐标 int boardx; // Top coordinate of checkerboard's upper-left corner. //棋盘左上角的上方向坐标 int boardy; // Left coordinate of checker rectangle origin (upper-left corner). // 棋子矩形原点(左上角)的左方向坐标 int ox; // Top coordinate of checker rectangle origin (upper-left corner). // 棋子矩形原点(左上角)的上方向坐标 int oy; // Left displacement between mouse coordinates at time of press and checker // rectangle origin. // 在按键时的鼠标坐标与棋子矩形原点之间的左方向位移 int relx; // Top displacement between mouse coordinates at time of press and checker // rectangle origin. // 在按键时的鼠标坐标与棋子矩形原点之间的上方向位移 int rely; // Width of applet drawing area. // applet绘图区域的宽度 int width; // Height of applet drawing area. // applet绘图区域的高度 int height; // Image buffer. // 图像缓冲 Image imBuffer; // Graphics context associated with image buffer. // 图像缓冲相关联的图形背景 Graphics imG; public void init () { // Obtain the size of the applet's drawing area. // 获取applet绘图区域的尺寸 width = getSize ().width; height = getSize ().height; // Create image buffer. // 创建图像缓冲 imBuffer = createImage (width, height); // Retrieve graphics context associated with image buffer. // 取出图像缓冲相关联的图形背景 imG = imBuffer.getGraphics (); // Initialize checkerboard's origin, so that board is centered. // 初始化棋盘的原点,使棋盘在屏幕上居中 boardx = (width - BOARDDIM) / 2 + 1; boardy = (height - BOARDDIM) / 2 + 1; // Initialize checker's rectangle's starting origin so that checker is // centered in the square located in the top row and second column from // the left. // 初始化棋子矩形的起始原点,使得棋子在第一行左数第二列的方格里居中 ox = boardx + SQUAREDIM + (SQUAREDIM - CHECKERDIM) / 2 + 1; oy = boardy + (SQUAREDIM - CHECKERDIM) / 2 + 1; // Attach a mouse listener to the applet. That listener listens for // mouse-button press and mouse-button release events. // 向applet添加一个用来监听鼠标按键的按下和释放事件的鼠标监听器 addMouseListener (new MouseAdapter () { public void mousePressed (MouseEvent e) { // Obtain mouse coordinates at time of press. // 获取按键时的鼠标坐标 int x = e.getX (); int y = e.getY (); // If mouse is over draggable checker at time // of press (i.e., contains (x, y) returns // true), save distance between current mouse // coordinates and draggable checker origin // (which will always be positive) and set drag // flag to true (to indicate drag in progress). // 在按键时如果鼠标位于可拖动的棋子上方 // (也就是contains (x, y)返回true),则保存当前 // 鼠标坐标与棋子的原点之间的距离(始终为正值)并且 // 将拖动标志设为true(用来表明正处在拖动过程中) if (contains (x, y)) { relx = x - ox; rely = y - oy; inDrag = true; } } boolean contains (int x, int y) { // Calculate center of draggable checker. // 计算棋子的中心位置 int cox = ox + CHECKERDIM / 2; int coy = oy + CHECKERDIM / 2; // Return true if (x, y) locates with bounds // of draggable checker. CHECKERDIM / 2 is the // radius. // 如果(x, y)仍处于棋子范围内则返回true // CHECKERDIM / 2为半径 return (cox - x) * (cox - x) + (coy - y) * (coy - y) CHECKERDIM / 2 * CHECKERDIM / 2; } public void mouseReleased (MouseEvent e) { // When mouse is released, clear inDrag (to // indicate no drag in progress) if inDrag is // already set. // 当鼠标按键被释放时,如果inDrag已经为true, // 则将其置为false(用来表明不在拖动过程中) if (inDrag) inDrag = false; } }); // Attach a mouse motion listener to the applet. That listener listens // for mouse drag events. //向applet添加一个用来监听鼠标拖动事件的鼠标运动监听器 addMouseMotionListener (new MouseMotionAdapter () { public void mouseDragged (MouseEvent e) { if (inDrag) { // Calculate draggable checker's new // origin (the upper-left corner of // the checker rectangle). // 计算棋子新的原点(棋子矩形的左上角) int tmpox = e.getX () - relx; int tmpoy = e.getY () - rely; // If the checker is not being moved // (at least partly) off board, // assign the previously calculated // origin (tmpox, tmpoy) as the // permanent origin (ox, oy), and // redraw the display area (with the // draggable checker at the new // coordinates). // 如果棋子(至少是棋子的一部分)没有被 // 移出棋盘,则将之前计算的原点 // (tmpox, tmpoy)赋值给永久性的原点(ox, oy), // 并且刷新显示区域(此时的棋子已经位于新坐标上) if (tmpox boardx tmpoy boardy tmpox + CHECKERDIM boardx + BOARDDIM tmpoy + CHECKERDIM boardy + BOARDDIM) { ox = tmpox; oy = tmpoy; repaint (); } } } }); } public void paint (Graphics g) { // Paint the checkerboard over which the checker will be dragged. // 在棋子将要被拖动的位置上绘制棋盘 paintCheckerBoard (imG, boardx, boardy); // Paint the checker that will be dragged. // 绘制即将被拖动的棋子 paintChecker (imG, ox, oy); // Draw contents of image buffer. // 绘制图像缓冲的内容 g.drawImage (imBuffer, 0, 0, this); } void paintChecker (Graphics g, int x, int y) { // Set checker shadow color. // 设置棋子阴影的颜色 g.setColor (Color.black); // Paint checker shadow. // 绘制棋子的阴影 g.fillOval (x, y, CHECKERDIM, CHECKERDIM); // Set checker color. // 设置棋子颜色 g.setColor (Color.red); // Paint checker. // 绘制棋子 g.fillOval (x, y, CHECKERDIM - CHECKERDIM / 13, CHECKERDIM - CHECKERDIM / 13); } void paintCheckerBoard (Graphics g, int x, int y) { // Paint checkerboard outline. // 绘制棋盘轮廓线 g.setColor (Color.black); g.drawRect (x, y, 8 * SQUAREDIM + 1, 8 * SQUAREDIM + 1); // Paint checkerboard. // 绘制棋盘 for (int row = 0; row 8; row++) { g.setColor (((row 1) != 0) ? darkGreen : Color.white); for (int col = 0; col 8; col++) { g.fillRect (x + 1 + col * SQUAREDIM, y + 1 + row * SQUAREDIM, SQUAREDIM, SQUAREDIM); g.setColor ((g.getColor () == darkGreen) ? Color.white : darkGreen); } } } // The AWT invokes the update() method in response to the repaint() method // calls that are made as a checker is dragged. The default implementation // of this method, which is inherited from the Container class, clears the // applet's drawing area to the background color prior to calling paint(). // This clearing followed by drawing causes flicker. CheckerDrag overrides // update() to prevent the background from being cleared, which eliminates // the flicker. // AWT调用了update()方法来响应拖动棋子时所调用的repaint()方法。该方法从 // Container类继承的默认实现会在调用paint()之前,将applet的绘图区域清除 // 为背景色,这种绘制之后的清除就导致了闪烁。CheckerDrag重写了update()来 // 防止背景被清除,从而消除了闪烁。 public void update (Graphics g) { paint (g); }}
跪求游戏java源代码
给你一个俄罗斯方块的把!!
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;
import javax.swing.Timer;
public class Tetris extends JFrame {
public Tetris() {
Tetrisblok a = new Tetrisblok();
addKeyListener(a);
add(a);
}
public static void main(String[] args) {
Tetris frame = new Tetris();
JMenuBar menu = new JMenuBar();
frame.setJMenuBar(menu);
JMenu game = new JMenu("游戏");
JMenuItem newgame = game.add("新游戏");
JMenuItem pause = game.add("暂停");
JMenuItem goon = game.add("继续");
JMenuItem exit = game.add("退出");
JMenu help = new JMenu("帮助");
JMenuItem about = help.add("关于");
menu.add(game);
menu.add(help);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(220, 275);
frame.setTitle("Tetris内测版");
// frame.setUndecorated(true);
frame.setVisible(true);
frame.setResizable(false);
}
}
// 创建一个俄罗斯方块类
class Tetrisblok extends JPanel implements KeyListener {
// blockType 代表方块类型
// turnState代表方块状态
private int blockType;
private int score = 0;
private int turnState;
private int x;
private int y;
private int i = 0;
int j = 0;
int flag = 0;
// 定义已经放下的方块x=0-11,y=0-21;
int[][] map = new int[13][23];
// 方块的形状 第一组代表方块类型有S、Z、L、J、I、O、T 7种 第二组 代表旋转几次 第三四组为 方块矩阵
private final int shapes[][][] = new int[][][] {
// i
{ { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 },
{ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 } },
// s
{ { 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 } },
// z
{ { 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 } },
// j
{ { 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// o
{ { 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// l
{ { 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
// t
{ { 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0 } } };
// 生成新方块的方法
public void newblock() {
blockType = (int) (Math.random() * 1000) % 7;
turnState = (int) (Math.random() * 1000) % 4;
x = 4;
y = 0;
if (gameover(x, y) == 1) {
newmap();
drawwall();
score = 0;
JOptionPane.showMessageDialog(null, "GAME OVER");
}
}
// 画围墙
public void drawwall() {
for (i = 0; i 12; i++) {
map[i][21] = 2;
}
for (j = 0; j 22; j++) {
map[11][j] = 2;
map[0][j] = 2;
}
}
// 初始化地图
public void newmap() {
for (i = 0; i 12; i++) {
for (j = 0; j 22; j++) {
map[i][j] = 0;
}
}
}
// 初始化构造方法
Tetrisblok() {
newblock();
newmap();
drawwall();
Timer timer = new Timer(1000, new TimerListener());
timer.start();
}
// 旋转的方法
public void turn() {
int tempturnState = turnState;
turnState = (turnState + 1) % 4;
if (blow(x, y, blockType, turnState) == 1) {
}
if (blow(x, y, blockType, turnState) == 0) {
turnState = tempturnState;
}
repaint();
}
// 左移的方法
public void left() {
if (blow(x - 1, y, blockType, turnState) == 1) {
x = x - 1;
}
;
repaint();
}
// 右移的方法
public void right() {
if (blow(x + 1, y, blockType, turnState) == 1) {
x = x + 1;
}
;
repaint();
}
// 下落的方法
public void down() {
if (blow(x, y + 1, blockType, turnState) == 1) {
y = y + 1;
delline();
}
;
if (blow(x, y + 1, blockType, turnState) == 0) {
add(x, y, blockType, turnState);
newblock();
delline();
}
;
repaint();
}
// 是否合法的方法
public int blow(int x, int y, int blockType, int turnState) {
for (int a = 0; a 4; a++) {
for (int b = 0; b 4; b++) {
if (((shapes[blockType][turnState][a * 4 + b] == 1) (map[x
+ b + 1][y + a] == 1))
|| ((shapes[blockType][turnState][a * 4 + b] == 1) (map[x
+ b + 1][y + a] == 2))) {
return 0;
}
}
}
return 1;
}
// 消行的方法
public void delline() {
int c = 0;
for (int b = 0; b 22; b++) {
for (int a = 0; a 12; a++) {
if (map[a][b] == 1) {
c = c + 1;
if (c == 10) {
score += 10;
for (int d = b; d 0; d--) {
for (int e = 0; e 11; e++) {
map[e][d] = map[e][d - 1];
}
}
}
}
}
c = 0;
}
}
// 判断你挂的方法
public int gameover(int x, int y) {
if (blow(x, y, blockType, turnState) == 0) {
return 1;
}
return 0;
}
// 把当前添加map
public void add(int x, int y, int blockType, int turnState) {
int j = 0;
for (int a = 0; a 4; a++) {
for (int b = 0; b 4; b++) {
if (map[x + b + 1][y + a] == 0) {
map[x + b + 1][y + a] = shapes[blockType][turnState][j];
}
;
j++;
}
}
}
// 画方块的的方法
public void paintComponent(Graphics g) {
super.paintComponent(g);
// 画当前方块
for (j = 0; j 16; j++) {
if (shapes[blockType][turnState][j] == 1) {
g.fillRect((j % 4 + x + 1) * 10, (j / 4 + y) * 10, 10, 10);
}
}
// 画已经固定的方块
for (j = 0; j 22; j++) {
for (i = 0; i 12; i++) {
if (map[i][j] == 1) {
g.fillRect(i * 10, j * 10, 10, 10);
}
if (map[i][j] == 2) {
g.drawRect(i * 10, j * 10, 10, 10);
}
}
}
g.drawString("score=" + score, 125, 10);
g.drawString("抵制不良游戏,", 125, 50);
g.drawString("拒绝盗版游戏。", 125, 70);
g.drawString("注意自我保护,", 125, 90);
g.drawString("谨防受骗上当。", 125, 110);
g.drawString("适度游戏益脑,", 125, 130);
g.drawString("沉迷游戏伤身。", 125, 150);
g.drawString("合理安排时间,", 125, 170);
g.drawString("享受健康生活。", 125, 190);
}
// 键盘监听
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_DOWN:
down();
break;
case KeyEvent.VK_UP:
turn();
break;
case KeyEvent.VK_RIGHT:
right();
break;
case KeyEvent.VK_LEFT:
left();
break;
}
}
// 无用
public void keyReleased(KeyEvent e) {
}
// 无用
public void keyTyped(KeyEvent e) {
}
// 定时器监听
class TimerListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
repaint();
if (blow(x, y + 1, blockType, turnState) == 1) {
y = y + 1;
delline();
}
;
if (blow(x, y + 1, blockType, turnState) == 0) {
if (flag == 1) {
add(x, y, blockType, turnState);
delline();
newblock();
flag = 0;
}
flag = 1;
}
;
}
}
}
求一个Java棋类游戏源码学习用,要求如下
import java.util.Scanner;
import java.util.Random;
public class Fangfa{
static int sum,sum1=0;
public static void main(String [] args){
int a=1,b=1,c=1;
int k=0,m=1;
int money =5000;
int zhu =0;
boolean flag = true;
Random rand = new Random();
Scanner input = new Scanner(System.in);
while(m==1){
while(flag){
System.out.println("掷色子开始!");
System.out.println("请下注 注:下注金额只能是50的倍数且不能超过1000");
zhu=input.nextInt();
if(zhu%50==0zhu=1000zhu=money){
System.out.println("下注成功");
System.out.println("买大请输入数字1,买小输入数字2");
k=input.nextInt();
a= rand.nextInt(6)+1;
b= rand.nextInt(6)+1;
c= rand.nextInt(6)+1;
sum=a+b+c;
if(k==1){
if(sum9){
money+=zhu;
System.out.println("恭喜您猜对了,骰子点数为"+sum+"结果是大"+"余额为"+money);
}else{
money-=zhu;
System.out.println("很遗憾,骰子点数为"+sum+"结果是小"+"余额为"+money);
}
}
if(k==2){
if(sum=9){
money+=zhu;
System.out.println("恭喜您猜对了,骰子点数为"+sum+"结果是小"+"余额为"+money);
}else{
money-=zhu;
System.out.println("很遗憾,骰子点数为"+sum+"结果是大"+"余额为"+money);
}
}
flag= false;
System.out.println("继续请按1,退出请按任意键");
m=input.nextInt();
if(m==1){
flag=true;
System.out.println("您选择的是继续");
}else{
flag=false;
System.out.println("欢迎您下次再来玩");
}
}else{
System.out.println("下注失败"+"余额为"+money);
}
}
}
}
}
怎样运行JAVA源代码
类似这样的?
啊,那个ABC和“原来的src”你就无视他吧,那是我后填上去的。。。这是开发手机游戏的程序WTK自动生成的目录样式(啊,也可能是eclipse生成的,但我只用过WTK)。简单说,src文件夹是装源代码的,res是装资源的,bin是装编译后的文件——jar和jad的。看样子你的bin文件夹是空的,也对,编译后的东西不属于源码嘛~你的这套文件很全,那只要安一个WTK然后把这些文件夹放在一个新的文件夹里——比如“文件夹A”——,然后把这个文件夹A放进你安装WTK的目录下的apps文件夹里,再运行WTK——打开项目——选中“文件夹A”——点击生成按钮,然后就可以去“文件夹A”的bin文件夹里找生成好的jar和jad了。 当然,运行WTK要有JDK,还要设置环境变量。不过你都能编译单个java文件了,这些应该已经做好了吧写是这么写了,不过很麻烦。安不安WTK看你了。不然你把下载链接给我,我下一套代码编译好了给你吧,正好我也想学习一下别人的代码。其实我很想看看那套代码,麻烦给我个下载链接吧 ……orz
谁有java游戏源码,给我发过来‘?
注意:源代码仅供个人作学习研究时的参考,不得在程序制作中直接抄录。
源代码一共两个文件:Mine.java,MGame.java,另外还有一些图片。
在JBuilder下建立一个新的工程,将两个源文件复制到工程目录下的src\mine目录中,将所有图片复制到src\images目录中就可以了。
要点分析
数据结构
首先要说明一下用来存放地雷信息的数组grid。
grid是一个二维数组,第一位对应表格的行,第二位对应表格的列,比如grid[y][x]表示第y行第x列。每个字节的含义分三段:0-9表示已经挖开;10-19表示仍然埋藏;20-29表示做了标记。每段中:0-8表示周围的地雷数量;9表示是地雷。
newGame()函数
这是用于开始一个新游戏的。
由于每次地雷的埋放地是随机的,应次开始新游戏之前先要生成新的地雷信息。
第一步是初始化grid,将所有内容都置成10,因为一开始所有格子都是埋藏的。
for(i=0;iHeight; i++)
{
for(j=0; jWidth; j++)
grid[j] = 10;
}
第二步是随机产生地雷。当然了,已经产生过地雷的地方要避开。
for(i=0; iMINECOUNT; i++)
{
while(true)
{
x = Math.abs(rand.nextInt()) % Width;
y = Math.abs(rand.nextInt()) % Height;
if (grid[y][x] != 19)
{
grid[y][x] = 19;
break;
}
}
}
最后就是无雷处计算周围的雷数了。怎么计算?一个一个加就是了。
挖雷与做标记
在看一下按键响应函数keyPressed(int kcode),按1键是挖开动作。
前半部分表示如果当前焦点在一个埋藏格(值介于10到19之间),那么将其值减10,表示现在挖开。当然如果地下不是雷而且周围没有雷(值等于0)那么需要自动展开,这里调用了Expand(),(selx,sely)是当前焦点的表格坐标。
后半部分表示如果当前焦点在一个已经挖开的格子上(值小于10),那么就调用SafeExp()来自动挖开周围未挖的格子。
按3键是做标记动作。如果当前格是埋藏格,就做上标记(值加10);如果当前格已经做了标记,那么就去掉标记(值减10)。
自动展开
Expand()是一个嵌套函数,他的作用是将周围不含地雷的格子周围全部挖开,如果挖开的部分中也有周围不含地雷的格子,那么对那些格子也重复前面的操作,直到把相关的格子都挖开。挖的顺序是左上、上、右上、左、右、左下、下、右下,如果遇到一个周围不含地雷的格子(值为0)那么马上嵌套调用Expand()对那个格子进行处理。
SafeExp()是一个自动挖开周围未挖格子的函数。当然要实现这个功能是有条件的,就是周围做了标记的格子数量必须等于当前格所标的数字,也就是说玩家把周围所有的地雷都标记了(不管是否标错)。函数中第一个部分就是做以上条件的判断。
第二部分是把周围埋藏的格子挖开。但是由于玩家的错误可能标记了没有地雷的格子,而把有地雷的格子漏标了,所以先要检查一下没做标而有地雷的格子和做错标记的格子。如果没有这些错误,那么可以安全的翻开了,同时也要检查是否挖到周围不含雷的格子,有的话就要调用Expand()了。
SafeExp()的返回值表示是否引爆了地雷,就是标记错误,true表示是,false表示否。这主要用于判断这次游戏是否要结束。
类介绍
图像缓存 ExtendedImage
ExtendedImage是Siemens自己扩展的一个专用类,只在Siemens的Java中存在。
这个类主要是用做图像的缓存。大家不知道还有没有印象,以前在PC上编程的时候由于显示的速度比较慢,往往会开一片显示缓存,先把要现实的内容画到这片缓存中,全部画好后再一次性显示出来,ExtendedImage类就起到了这个作用。其实Java本身的Image类也可以实现类似的功能,但是显示速度好象不如人意,而且ExtendedImage更好用,所以我基本上都采用这个类。当然这对通用性是不利的。
ExtendImage的主要函数有:
void clear(byte color);
用给定的颜色填充整个图形区域。
void blitToScreen(int x, int y);
将缓存内容贴到显示屏上,(x,y)是屏幕左上角坐标。
Image getImage();
返回一个标准的Image类。可以通过ExtendImage.getImage().getGraphics()得到与其相关的Graphics对象,用来往ExtendImage上面画图。
关于java游戏服务端源码和游戏客户端源码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
2、本站永久网址:https://www.yuanmacun.com
3、本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。
4、本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
5、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6、本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
源码村资源网 » java游戏服务端源码(游戏客户端源码)