當前位置:首頁 » 編程語言 » java游戲源代碼

java游戲源代碼

發布時間: 2022-04-25 23:24:56

『壹』 求"大家來找茬"游戲的java源代碼

其實不難,原理如下:

建立數據結構,此結構應該有的屬性為:

1。圖A(原圖),
2。圖B(有差別的圖),
3。不同點的坐標區域

原理:窗口中顯示兩個圖,在每個圖上添加滑鼠點擊事件,在滑鼠點擊後在判斷坐標是否在坐標區域內

用NetBeans半小時應該就能做好,程序不難,麻煩的是圖片的製作或者尋找,然後規定坐標區域

回答完畢,如果你想要程序我又時間了可以考慮給你做一個

『貳』 求java小游戲源代碼

[最佳答案] 連連看java源代碼 import javax.swing.*; import java.awt.*; import java.awt.event.*; pu... int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位...

『叄』 急需基於eclipse的JAVA小游戲源代碼!!!

單人版五子棋,不用導入,直接新建一個mywindow類就行,然後把一下代碼粘貼就Ok了。或者,直接用dos就可以了。。
---------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class mypanel extends Panel implements MouseListener
{
int chess[][] = new int[11][11];
boolean Is_Black_True;
mypanel()
{
Is_Black_True = true;
for(int i = 0;i < 11;i++)
{
for(int j = 0;j < 11;j++)
{
chess[i][j] = 0;
}
}
addMouseListener(this);
setBackground(Color.BLUE);
setBounds(0, 0, 360, 360);
setVisible(true);
}
public void mousePressed(MouseEvent e)
{
int x = e.getX();
int y = e.getY();

if(x < 25 || x > 330 + 25 ||y < 25 || y > 330+25)
{
return;
}
if(chess[x/30-1][y/30-1] != 0)
{
return;
}
if(Is_Black_True == true)
{
chess[x/30-1][y/30-1] = 1;
Is_Black_True = false;
repaint();
Justisewiner();
return;
}
if(Is_Black_True == false)
{
chess[x/30-1][y/30-1] = 2;
Is_Black_True = true;
repaint();
Justisewiner();
return;
}
}
void Drawline(Graphics g)
{
for(int i = 30;i <= 330;i += 30)
{
for(int j = 30;j <= 330; j+= 30)
{
g.setColor(Color.WHITE);
g.drawLine(i, j, i, 330);
}
}

for(int j = 30;j <= 330;j += 30)
{
g.setColor(Color.WHITE);
g.drawLine(30, j, 330, j);
}

}
void Drawchess(Graphics g)
{
for(int i = 0;i < 11;i++)
{
for(int j = 0;j < 11;j++)
{
if(chess[i][j] == 1)
{
g.setColor(Color.BLACK);
g.fillOval((i + 1) * 30 - 8, (j + 1) * 30 - 8, 16, 16);
}
if(chess[i][j] == 2)
{
g.setColor(Color.WHITE);
g.fillOval((i + 1) * 30 - 8, (j + 1) * 30 - 8, 16, 16);
}
}
}
}
void Justisewiner()
{
int black_count = 0;
int white_count = 0;
int i = 0;

for(i = 0;i < 11;i++)//橫向判斷
{
for(int j = 0;j < 11;j++)
{
if(chess[i][j] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[i][j] == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}

for(i = 0;i < 11;i++)//豎向判斷
{
for(int j = 0;j < 11;j++)
{
if(chess[j][i] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[j][i] == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}

for(i = 0;i < 7;i++)//左向右斜判斷
{
for(int j = 0;j < 7;j++)
{
for(int k = 0;k < 5;k++)
{
if(chess[i + k][j + k] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[i + k][j + k] == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}
}

for(i = 4;i < 11;i++)//右向左斜判斷
{
for(int j = 6;j >= 0;j--)
{
for(int k = 0;k < 5;k++)
{
if(chess[i - k][j + k] == 1)
{
black_count++;
if(black_count == 5)
{
JOptionPane.showMessageDialog(this, "黑棋勝利");
Clear_Chess();
return;
}
}
else
{
black_count = 0;
}
if(chess[i - k][j + k] == 2)
{
white_count++;
if(white_count == 5)
{
JOptionPane.showMessageDialog(this, "白棋勝利");
Clear_Chess();
return;
}
}
else
{
white_count = 0;
}
}
}
}

}
void Clear_Chess()
{
for(int i=0;i<11;i++)
{
for(int j=0;j<11;j++)
{
chess[i][j]=0;
}
}
repaint();
}
public void paint(Graphics g)
{
Drawline(g);
Drawchess(g);
}
public void mouseExited(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseClicked(MouseEvent e){}

}

class myframe extends Frame implements WindowListener
{
mypanel panel;
myframe()
{
setLayout(null);
panel = new mypanel();
add(panel);
panel.setBounds(0,23, 360, 360);
setTitle("單人版五子棋");
setBounds(200, 200, 360, 383);
setVisible(true);
addWindowListener(this);

}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public void windowDeactivated(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
}
public class mywindow
{
public static void main(String argc [])
{
myframe f = new myframe();
}
}

『肆』 游戲軟體怎麼查看源代碼

源代碼是看不成的,因為游戲軟體打包好做成app的話,是沒法看源碼的,雖然存在一些特殊情況下,我們可以推測出exe程序是用什麼程序寫的。但是多數情況下,我們是無法只根據一個exe程序就判斷出來的。

根據exe程序我們是無法直接得到程序的源碼的。雖然也有一些用於逆向工程的辦法,但那不可能把已經是exe的程序反回到它原始的源碼情況。而且這些工具都很難用。你可以用「反編譯」搜到很多工具,但是說實話,即便是這方面的專家,要看懂反編譯以後的程序也不是一件輕松的事情。

『伍』 求JAVA編寫打字游戲源代碼!

package chen;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.Vector;
import javax.swing.JFrame;

public class keyTest extends Window implements KeyListener, Runnable {

int width, height;
BufferedImage buf;
Graphics gc;
boolean play = true;
Vector<oneChar> keys = new Vector<oneChar>();
int ok = 0, fail = 0, error = 0, sum = 0;
Font small = new Font("宋體", 0, 30);
Font big = new Font("宋體", 0, 50);
long time = System.currentTimeMillis();

keyTest(Frame f) {
super(f);
Dimension s = getToolkit().getScreenSize();
width = (int) s.getWidth();
height = (int) s.getHeight();
this.setBounds(0, 0, width, height);
this.buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
gc = buf.getGraphics();
this.setVisible(true);
this.setAlwaysOnTop(true);
this.buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
gc = buf.getGraphics();
new Thread(this).start();

}

public static void main(String s[]) {
JFrame help = new JFrame("打字練習");
help.setVisible(true);
help.setDefaultCloseOperation(3);
help.addKeyListener(new keyTest(help));

}

public void keyTyped(KeyEvent e) {
}

public synchronized void keyPressed(KeyEvent e) {
if (e.getKeyCode() == 27) {
play = false;
this.dispose();
System.exit(0);
}
char s = e.getKeyChar();
if (s >= 'a' && s <= 'z' || (s >= 'A' && s <= 'Z')) {
String l = "" + s;
for (int i = 0; i < keys.size(); i++) {
if (l.equals(((oneChar) keys.elementAt(i)).s)) {
keys.removeElementAt(i);
ok++;
return;
}
}
error++;
}
}

public void keyReleased(KeyEvent e) {
}

@Override
public void update(Graphics g) {

gc.setColor(Color.BLACK);
gc.fillRect(0, 0, width, height);
gc.setColor(Color.red);
int l = (ok + error) > 0 ? (ok * 100 / (ok + error)) : 100;
gc.setFont(small);
gc.drawString("成功:" + ok + " 錯誤:" + error + " 失敗:" + fail + " 正確率:" + l + "% 時間:" + (System.currentTimeMillis() - time) / 1000, 10, height - 30);
gc.setFont(big);
oneChar o;
for (int i = 0; i < keys.size(); i++) {
o = keys.elementAt(i);
gc.setColor(o.c);
gc.drawString(o.s, o.x, o.y += 6);
if (o.y > height - 10) {
fail++;
keys.removeElementAt(i);
}
}
g.drawImage(buf, 0, 0, null);
}

public void run() {
while (play) {
try {
sum++;
if (sum % 5 == 0) {
newchar();
}
Thread.sleep(80);
repaint();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}

private void newchar() {
keys.add(oneChar.getinstance(width));
}
}
package chen;

import java.awt.Color;

public class oneChar {

static java.util.Random r = new java.util.Random();

public static oneChar getinstance(int maxX) {
oneChar a = new oneChar();
int b = r.nextInt(26);
a.s = "" + (char) (b + (r.nextInt(4) > 1 ? 'a' : 'A'));
a.x = r.nextInt(maxX - 30);
a.c = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256));
return a;
}
int x, y;
Color c;
String s;
}

『陸』 小游戲十滴水的java源代碼,急

第一個Java文件: import java.util.Scanner; public class GameA_B {
public static void main(String[] args) {
Scanner reader=new Scanner(System.in);
int area;
System.out.println("Game Start…………Please enter the area:(1-9)" + '\n'+"1,2,3 means easy"+'\n'+"4,5,6 means middle"+'\n'+ "7,8,9 means hard"+'\n'+"Please choose:");
area=reader.nextInt();
switch((area1)/3) {
case 0:System.out.println("You choose easy! ");break;
case 1:System.out.println("You choose middle! ");break; case 2:System.out.println("You choose hard! ");break; } System.out.println("Good Luck!"); GameProcess game1=new GameProcess(area); game1.process(); } } 第二個Java文件: import java.util.Random; import java.util.Scanner; public class GameProcess { int area,i,arrcount,right,midright,t; int base[]=new int[arrcount],userNum[]=new int[area],sysNum[]=new int[area]; Random random=new Random(); Scanner reader=new Scanner(System.in); GameProcess(int a) { area=a; arrcount=10; right=0; midright=0; t=0; base=new int[arrcount]; userNum=new int[area]; sysNum=new int[area]; for(int i=0;i<arrcount;i++) { base[i]=i; //System.out.println(base[i]); } } void process() { rand(); while(right!=area) { scanf(); compare(); print(); check(); } } void rand() { for(i=0;i<area;i++) { t=random.nextInt(arrcount); //System.out.println(t); sysNum[i]=base[t]; System.out.println(base[t]); delarr(t); } } void delarr(int t) { for(int j=t;j<arrcount-1;j++) base[j]=base[j+1]; arrcount--; } void scanf() { System.out.println("The system number has created!"+"\n"+"Please enter "+area+" Numbers"); for(int i=0;i<area;i++){ userNum[i]=reader.nextShort(); } } void check() { if(right==area) System.out.println("You win…………!"); } boolean check(int i) { return true; } void compare() { int i=0,j=0; right=midright=0; for(i=0;i<area;i++) { for(j=0;j<area;j++) { if(userNum[i]==sysNum[j]) { if(i==j) right++; else midright++; } } } } void print() { System.out.println(" A "+right+" B "+midright); } }

自己慢慢分吧!!!!!!!

『柒』 求一個簡單又有趣的JAVA小游戲代碼

具體如下:

連連看的小源碼

package Lianliankan;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class lianliankan implements ActionListener

{

JFrame mainFrame; //主面板

Container thisContainer;

JPanel centerPanel,southPanel,northPanel; //子面板

JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數組

JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕

JLabel fractionLable=new JLabel("0"); //分數標簽

JButton firstButton,secondButton; //

分別記錄兩次被選中的按鈕

int grid[][] = new int[8][7];//儲存游戲按鈕位置

static boolean pressInformation=false; //判斷是否有按鈕被選中

int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標

int i,j,k,n;//消除方法控制

代碼(code)是程序員用開發工具所支持的語言寫出來的源文件,是一組由字元、符號或信號碼元以離散形式表示信息的明確的規則體系。

對於字元和Unicode數據的位模式的定義,此模式代表特定字母、數字或符號(例如 0x20 代表一個空格,而 0x74 代表字元「t」)。一些數據類型每個字元使用一個位元組;每個位元組可以具有 256 個不同的位模式中的一個模式。

在計算機中,字元由不同的位模式(ON 或 OFF)表示。每個位元組有 8 位,這 8 位可以有 256 種不同的 ON 和 OFF 組合模式。對於使用 1 個位元組存儲每個字元的程序,通過給每個位模式指派字元可表示最多 256 個不同的字元。2 個位元組有 16 位,這 16 位可以有 65,536 種唯一的 ON 和 OFF 組合模式。使用 2 個位元組表示每個字元的程序可表示最多 65,536 個字元。

單位元組代碼頁是字元定義,這些字元映射到每個位元組可能有的 256 種位模式中的每一種。代碼頁定義大小寫字元、數字、符號以及 !、@、#、% 等特殊字元的位模式。每種歐洲語言(如德語和西班牙語)都有各自的單位元組代碼頁。

雖然用於表示 A 到 Z 拉丁字母表字元的位模式在所有的代碼頁中都相同,但用於表示重音字元(如"é"和"á")的位模式在不同的代碼頁中卻不同。如果在運行不同代碼頁的計算機間交換數據,必須將所有字元數據由發送計算機的代碼頁轉換為接收計算機的代碼頁。如果源數據中的擴展字元在接收計算機的代碼頁中未定義,那麼數據將丟失。

如果某個資料庫為來自許多不同國家的客戶端提供服務,則很難為該資料庫選擇這樣一種代碼頁,使其包括所有客戶端計算機所需的全部擴展字元。而且,在代碼頁間不停地轉換需要花費大量的處理時間。

熱點內容
帝來哪個配置值得購買 發布:2025-05-16 21:12:29 瀏覽:461
什麼是nodejs前端伺服器 發布:2025-05-16 21:12:17 瀏覽:404
編譯選項立即綁定未定義符號 發布:2025-05-16 20:55:13 瀏覽:905
linuxmysql慢日誌 發布:2025-05-16 20:47:58 瀏覽:270
村兩委有哪些配置 發布:2025-05-16 20:34:47 瀏覽:292
我的世界有什麼伺服器好玩的 發布:2025-05-16 20:28:57 瀏覽:483
c語言按位與運算 發布:2025-05-16 20:24:10 瀏覽:754
蘋果手機如何修改密碼安全 發布:2025-05-16 20:23:34 瀏覽:193
圖片文字識別演算法 發布:2025-05-16 20:21:54 瀏覽:46
校園ftp伺服器 發布:2025-05-16 20:19:38 瀏覽:72