導航:首頁 > 源碼編譯 > 精品游戲源碼

精品游戲源碼

發布時間:2023-04-10 22:29:31

A. 想要java開發手機游戲的源代碼,什麼游戲都行,貪吃蛇,俄羅斯方塊都OK,

那你這個就是安卓開發

B. 求"貪吃蛇"小游戲JAVA源代碼一份

貪吃蛇
import
java.awt.*;
import
java.awt.event.*;
public
class
GreedSnake
//主類
{
/**
*
@param
args
*/
public
static
void
main(String[]
args)
{
//
TODO
Auto-generated
method
stub
new
MyWindow();
}
}
class
MyPanel
extends
Panel
implements
KeyListener,Runnable//自定義面板類,繼承了鍵盤和線程介面
{
Button
snake[];
//定義蛇按鈕
int
shu=0;
//蛇的節數
int
food[];
//食物數組
boolean
result=true;
//判定結果是輸
還是贏
Thread
thread;
//定義線程
static
int
weix,weiy;
//食物位置
boolean
t=true;
//判定游戲是否結束
int
fangxiang=0;
//蛇移動方向
int
x=0,y=0;
//蛇頭位置
MyPanel()
{
setLayout(null);
snake=new
Button[20];
food=new
int
[20];
thread=new
Thread(this);
for(int
j=0;j<20;j++)
{
food[j]=(int)(Math.random()*99);//定義20個隨機食物
}
weix=(int)(food[0]*0.1)*60;
//十位*60為橫坐標
weiy=(int)(food[0]%10)*40;
//個位*40為縱坐標
for(int
i=0;i<20;i++)
{
snake[i]=new
Button();
}
add(snake[0]);
snake[0].setBackground(Color.black);
snake[0].addKeyListener(this);
//為蛇頭添加鍵盤監視器
snake[0].setBounds(0,0,10,10);
setBackground(Color.cyan);
}
public
void
run()
//接收線程
{
while(t)
{
if(fangxiang==0)//向右
{
try
{
x+=10;
snake[0].setLocation(x,
y);//設置蛇頭位置
if(x==weix&&y==weiy)
//吃到食物
{
shu++;
weix=(int)(food[shu]*0.1)*60;
weiy=(int)(food[shu]%10)*40;
repaint();
//重繪下一個食物
add(snake[shu]);
//增加蛇節數和位置
snake[shu].setBounds(snake[shu-1].getBounds());
}
thread.sleep(100);
//睡眠100ms
}
catch(Exception
e){}
}
else
if(fangxiang==1)//向左
{
try
{
x-=10;
snake[0].setLocation(x,
y);
if(x==weix&&y==weiy)
{
shu++;
weix=(int)(food[shu]*0.1)*60;
weiy=(int)(food[shu]%10)*40;
repaint();
add(snake[shu]);
snake[shu].setBounds(snake[shu-1].getBounds());
}
thread.sleep(100);
}
catch(Exception
e){}
}
else
if(fangxiang==2)//向上
{
try
{
y-=10;
snake[0].setLocation(x,
y);
if(x==weix&&y==weiy)
{
shu++;
weix=(int)(food[shu]*0.1)*60;
weiy=(int)(food[shu]%10)*40;
repaint();
add(snake[shu]);
snake[shu].setBounds(snake[shu-1].getBounds());
}
thread.sleep(100);
}
catch(Exception
e){}
}
else
if(fangxiang==3)//向下
{
try
{
y+=10;
snake[0].setLocation(x,
y);
if(x==weix&&y==weiy)
{
shu++;
weix=(int)(food[shu]*0.1)*60;
weiy=(int)(food[shu]%10)*40;
repaint();
add(snake[shu]);
snake[shu].setBounds(snake[shu-1].getBounds());
}
thread.sleep(100);
}
catch(Exception
e){}
}
int
num1=shu;
while(num1>1)//判斷是否咬自己的尾巴
{
if(snake[num1].getBounds().x==snake[0].getBounds().x&&snake[num1].getBounds().y==snake[0].getBounds().y)
{
t=false;
result=false;
repaint();
}
num1--;
}
if(x<0||x>=this.getWidth()||y<0||y>=this.getHeight())//判斷是否撞牆
{
t=false;
result=false;
repaint();
}
int
num=shu;
while(num>0)
//設置蛇節位置
{
snake[num].setBounds(snake[num-1].getBounds());
num--;
}
if(shu==15)
//如果蛇節數等於15則勝利
{
t=false;
result=true;
repaint();
}
}
}
public
void
keyPressed(KeyEvent
e)
//按下鍵盤方向鍵
{
if(e.getKeyCode()==KeyEvent.VK_RIGHT)//右鍵
{
if(fangxiang!=1)//如果先前方向不為左
fangxiang=0;
}
else
if(e.getKeyCode()==KeyEvent.VK_LEFT)
{
if(fangxiang!=0)
fangxiang=1;
}
else
if(e.getKeyCode()==KeyEvent.VK_UP)
{
if(fangxiang!=3)
fangxiang=2;
}
else
if(e.getKeyCode()==KeyEvent.VK_DOWN)
{
if(fangxiang!=2)
fangxiang=3;
}
}
public
void
keyTyped(KeyEvent
e)
{
}
public
void
keyReleased(KeyEvent
e)
{
}
public
void
paint(Graphics
g)
//在面板上繪圖
{
int
x1=this.getWidth()-1;
int
y1=this.getHeight()-1;
g.setColor(Color.red);
g.fillOval(weix,
weiy,
10,
10);//食物
g.drawRect(0,
0,
x1,
y1);
//牆
if(t==false&&result==false)
g.drawString("GAME
OVER!",
250,
200);//輸出遊戲失敗
else
if(t==false&&result==true)
g.drawString("YOU
WIN!",
250,
200);//輸出遊戲成功
}
}
class
MyWindow
extends
Frame
implements
ActionListener//自定義窗口類
{
MyPanel
my;
Button
btn;
Panel
panel;
MyWindow()
{
super("GreedSnake");
my=new
MyPanel();
btn=new
Button("begin");
panel=new
Panel();
btn.addActionListener(this);
panel.add(new
Label("begin後請按Tab鍵選定蛇"));
panel.add(btn);
panel.add(new
Label("按上下左右鍵控制蛇行動"));
add(panel,BorderLayout.NORTH);
add(my,BorderLayout.CENTER);
setBounds(100,100,610,500);
setVisible(true);
validate();
addWindowListener(new
WindowAdapter()
{
public
void
windowClosing(WindowEvent
e)
{
System.exit(0);
}
});
}
public
void
actionPerformed(ActionEvent
e)//按下begin按鈕
{
if(e.getSource()==btn)
{
try
{
my.thread.start();
//開始線程
my.validate();
}
catch(Exception
ee){}
}
}
}

C. 跪求用C++語言編寫的小游戲的源代碼

像素射擊:int anim abc_fade_in 0x7f010001
int anim abc_fade_out 0x7f010002
int anim abc_grow_fade_in_from_bottom 0x7f010003
int anim abc_popup_enter 0x7f010004
int anim abc_popup_exit 0x7f010005
int anim abc_shrink_fade_out_from_bottom 0x7f010006
int anim abc_slide_in_bottom 0x7f010007
int anim abc_slide_in_top 0x7f010008
int anim abc_slide_out_bottom 0x7f010009
int anim abc_slide_out_top 0x7f01000a
int anim abc_tooltip_enter 0x7f01000b
int anim abc_tooltip_exit 0x7f01000c
int attr actionBarDivider 0x7f040001
int attr actionBarItemBackground 0x7f040002
int attr actionBarPopupTheme 0x7f040003
int attr actionBarSize 0x7f040004
int attr actionBarSplitStyle 0x7f040005
int attr actionBarStyle 0x7f040006
int attr actionBarTabBarStyle 0x7f040007
int attr actionBarTabStyle 0x7f040008
int attr actionBarTabTextStyle 0x7f040009
int attr actionBarTheme 0x7f04000a
int attr actionBarWidgetTheme 0x7f04000b
int attr actionButtonStyle 0x7f04000c
int attr actionDropDownStyle 0x7f04000d
int attr actionLayout 0x7f04000e
int attr actionMenuTextAppearance 0x7f04000f
int attr actionMenuTextColor 0x7f040010
int attr actionModeBackground 0x7f040011
int attr actionModeCloseButtonStyle 0x7f040012
int attr actionModeCloseDrawable 0x7f040013
int attr actionModeCopyDrawable 0x7f040014
int attr actionModeCutDrawable 0x7f040015
int attr actionModeFindDrawable 0x7f040016
int attr actionModePasteDrawable 0x7f040017
int attr actionModePopupWindowStyle 0x7f040018
int attr actionModeSelectAllDrawable 0x7f040019
int attr actionModeShareDrawable 0x7f04001a
int attr actionModeSplitBackground 0x7f04001b
int attr actionModeStyle 0x7f04001c
int attr actionModeWebSearchDrawable 0x7f04001d
int attr actionOverflowButtonStyle 0x7f04001e
int attr actionOverflowMenuStyle 0x7f04001f
int attr actionProviderClass 0x7f040020
int attr actionViewClass 0x7f040021
int attr activityChooserViewStyle 0x7f040022
int attr alertDialogButtonGroupStyle 0x7f040023
int attr alertDialogCenterButtons 0x7f040024
int attr alertDialogStyle 0x7f040025
int attr alertDialogTheme 0x7f040026
int attr allowStacking 0x7f040027
int attr alpha 0x7f040028
int attr alphabeticModifiers 0x7f040029
int attr arrowHeadLength 0x7f04002a
int attr arrowShaftLength 0x7f04002b
int attr autoCompleteTextViewStyle 0x7f04002c
int attr autoSizeMaxTextSize 0x7f04002d
int attr autoSizeMinTextSize 0x7f04002e
int attr autoSizePresetSizes 0x7f04002f
int attr autoSizeStepGranularity 0x7f040030
int attr autoSizeTextType 0x7f040031
int attr background 0x7f040032
int attr backgroundSplit 0x7f040033
int attr backgroundStacked 0x7f040034
int attr backgroundTint 0x7f040035
int attr backgroundTintMode 0x7f040036
int attr barLength 0x7f040037
int attr borderlessButtonStyle 0x7f040038
int attr buttonBarButtonStyle 0x7f040039
int attr buttonBarNegativeButtonStyle 0x7f04003a
int attr buttonBarNeutralButtonStyle 0x7f04003b
int attr buttonBarPositiveButtonStyle 0x7f04003c
int attr buttonBarStyle 0x7f04003d
int attr buttonGravity 0x7f04003e
int attr buttonIconDimen 0x7f04003f
int attr buttonPanelSideLayout 0x7f040040
int attr buttonStyle 0x7f040041
int attr buttonStyleSmall 0x7f040042
int attr buttonTint 0x7f040043
int attr buttonTintMode 0x7f040044
int attr checkboxStyle 0x7f040045
int attr checkedTextViewStyle 0x7f040046
int attr closeIcon 0x7f040047
int attr closeItemLayout 0x7f040048
int attr collapseContentDescription 0x7f040049
int attr collapseIcon 0x7f04004a
int attr color 0x7f04004b
int attr colorAccent 0x7f04004c
int attr colorBackgroundFloating 0x7f04004d
int attr colorButtonNormal 0x7f04004e
int attr colorControlActivated 0x7f04004f
int attr colorControlHighlight 0x7f040050
int attr colorControlNormal 0x7f040051
int attr colorError 0x7f040052
int attr colorPrimary 0x7f040053
int attr colorPrimaryDark 0x7f040054
int attr colorSwitchThumbNormal 0x7f040055
int attr commitIcon 0x7f040056
int attr contentDescription 0x7f040057
int attr contentInsetEnd 0x7f040058
int attr contentInsetEndWithActions 0x7f040059
int attr contentInsetLeft 0x7f04005a
int attr contentInsetRight 0x7f04005b
int attr contentInsetStart 0x7f04005c
int attr 0x7f04005d
int attr controlBackground 0x7f04005e
int attr coordinatorLayoutStyle 0x7f04005f
int attr customNavigationLayout 0x7f040060
int attr defaultQueryHint 0x7f040061
int attr dialogCornerRadius 0x7f040062
int attr dialogPreferredPadding 0x7f040063
int attr dialogTheme 0x7f040064
int attr displayOptions 0x7f040065
int attr divider 0x7f040066
int attr dividerHorizontal 0x7f040067
int attr dividerPadding 0x7f040068
int attr dividerVertical 0x7f040069
int attr drawableSize 0x7f04006a
int attr drawerArrowStyle 0x7f04006b
int attr dropDownListViewStyle 0x7f04006c
int attr 0x7f04006d
int attr editTextBackground 0x7f04006e
int attr editTextColor 0x7f04006f
int attr editTextStyle 0x7f040070
int attr elevation 0x7f040071
int attr 0x7f040072
int attr firstBaselineToTopHeight 0x7f040073
int attr font 0x7f040074
int attr fontFamily 0x7f040075
int attr fontProviderAuthority 0x7f040076
int attr fontProviderCerts 0x7f040077
int attr fontProviderFetchStrategy 0x7f040078
int attr fontProviderFetchTimeout 0x7f040079
int attr fontProviderPackage 0x7f04007a
int attr fontProviderQuery 0x7f04007b
int attr fontStyle 0x7f04007c
int attr fontVariationSettings 0x7f04007d
int attr fontWeight 0x7f04007e
int attr gapBetweenBars 0x7f04007f
int attr goIcon 0x7f040080
int attr height 0x7f040081
int attr hideOnContentScroll 0x7f040082
int attr homeAsUpIndicator 0x7f040083
int attr homeLayout 0x7f040084
int attr icon 0x7f040085
int attr iconTint 0x7f040086
int attr iconTintMode 0x7f040087
int attr iconifiedByDefault 0x7f040088
int attr imageButtonStyle 0x7f040089
int attr indeterminateProgressStyle 0x7f04008a
int attr initialActivityCount 0x7f04008b
int attr isLightTheme 0x7f04008c
int attr itemPadding 0x7f04008d
int attr keylines 0x7f04008e
int attr lastBaselineToBottomHeight 0x7f04008f
int attr layout 0x7f040090
int attr layout_anchor 0x7f040091
int attr layout_anchorGravity 0x7f040092
int attr layout_behavior 0x7f040093
int attr layout_dodgeInsetEdges 0x7f040094
int attr layout_insetEdge 0x7f040095
int attr layout_keyline 0x7f040096
int attr lineHeight 0x7f040097
int attr listChoiceBackgroundIndicator 0x7f040098
int attr listDividerAlertDialog 0x7f040099
int attr listItemLayout 0x7f04009a
int attr listLayout 0x7f04009b
int attr listMenuViewStyle 0x7f04009c
int attr listPopupWindowStyle 0x7f04009d
int attr listPreferredItemHeight 0x7f04009e
int attr listPreferredItemHeightLarge 0x7f04009f
int attr listPreferredItemHeightSmall 0x7f0400a0
int attr listPreferredItemPaddingLeft 0x7f0400a1
int attr listPreferredItemPaddingRight 0x7f0400a2
int attr logo 0x7f0400a3
int attr logoDescription 0x7f0400a4
int attr maxButtonHeight 0x7f0400a5
int attr measureWithLargestChild 0x7f0400a6
int attr multiChoiceItemLayout 0x7f0400a7
int attr navigationContentDescription 0x7f0400a8
int attr navigationIcon 0x7f0400a9
int attr navigationMode 0x7f0400aa
int attr numericModifiers 0x7f0400ab
int attr overlapAnchor 0x7f0400ac
int attr paddingBottomNoButtons 0x7f0400ad
int attr paddingEnd 0x7f0400ae
int attr paddingStart 0x7f0400af
int attr paddingTopNoTitle 0x7f0400b0
int attr panelBackground 0x7f0400b1
int attr panelMenuListTheme 0x7f0400b2
int attr panelMenuListWidth 0x7f0400b3
int attr popupMenuStyle 0x7f0400b4
int attr popupTheme 0x7f0400b5
int attr popupWindowStyle 0x7f0400b6
int attr preserveIconSpacing 0x7f0400b7
int attr progressBarPadding 0x7f0400b8
int attr progressBarStyle 0x7f0400b9
int attr queryBackground 0x7f0400ba
int attr queryHint 0x7f0400bb
int attr radioButtonStyle 0x7f0400bc
int attr ratingBarStyle 0x7f0400bd
int attr ratingBarStyleIndicator 0x7f0400be
int attr ratingBarStyleSmall 0x7f0400bf
int attr searchHintIcon 0x7f0400c0
int attr searchIcon 0x7f0400c1
int attr searchViewStyle 0x7f0400c2
int attr seekBarStyle 0x7f0400c3
int attr selectableItemBackground 0x7f0400c4
int attr 0x7f0400c5
int attr showAsAction 0x7f0400c6
int attr showDividers 0x7f0400c7
int attr showText 0x7f0400c8
int attr showTitle 0x7f0400c9
int attr singleChoiceItemLayout 0x7f0400ca
int attr spinBars 0x7f0400cb
int attr spinnerDropDownItemStyle 0x7f0400cc
int attr spinnerStyle 0x7f0400cd
int attr splitTrack 0x7f0400ce
int attr srcCompat 0x7f0400cf
int attr state_above_anchor 0x7f0400d0
int attr statusBarBackground 0x7f0400d1
int attr subMenuArrow 0x7f0400d2
int attr submitBackground 0x7f0400d3
int attr subtitle 0x7f0400d4
int attr subtitleTextAppearance 0x7f0400d5
int attr subtitleTextColor 0x7f0400d6
int attr subtitleTextStyle 0x7f0400d7
int attr suggestionRowLayout 0x7f0400d8
int attr switchMinWidth 0x7f0400d9
int attr switchPadding 0x7f0400da
int attr switchStyle 0x7f0400db
int attr switchTextAppearance 0x7f0400dc
int attr textAllCaps 0x7f0400dd
int attr textAppearanceLargePopupMenu 0x7f0400de
int attr textAppearanceListItem 0x7f0400df
int attr 0x7f0400e0
int attr textAppearanceListItemSmall 0x7f0400e1
int attr textAppearancePopupMenuHeader 0x7f0400e2
int attr 0x7f0400e3
int attr 0x7f0400e4
int attr textAppearanceSmallPopupMenu 0x7f0400e5
int attr textColorAlertDialogListItem 0x7f0400e6
int attr textColorSearchUrl 0x7f0400e7
int attr theme 0x7f0400e8
int attr thickness 0x7f0400e9
int attr thumbTextPadding 0x7f0400ea
int attr thumbTint 0x7f0400eb
int attr thumbTintMode 0x7f0400ec
int attr tickMark 0x7f0400ed
int attr tickMarkTint 0x7f0400ee
int attr tickMarkTintMode 0x7f0400ef
int attr tint 0x7f0400f0
int attr tintMode 0x7f0400f1
int attr title 0x7f0400f2
int attr titleMargin 0x7f0400f3
int attr titleMarginBottom 0x7f0400f4
int attr titleMarginEnd 0x7f0400f5
int attr titleMarginStart 0x7f0400f6
int attr titleMarginTop 0x7f0400f7
int attr titleMargins 0x7f0400f8
int attr titleTextAppearance 0x7f0400f9
int attr titleTextColor 0x7f

D. 網路游戲的源代碼是什麼

網路游戲源代碼就是游戲的基礎,在外行人眼裡是無數行的英文和數字,其實就是一組程序。x0dx0ax0dx0a作用當然是開發游戲啦。x0dx0a手上擁有了源代碼就可以製作游戲,當然如果你啥都不改,那功能就和原來的游戲沒什麼兩樣。x0dx0a現在網上你可以搜索一下網路游戲的源代碼還是非常多的,但是大多數都是不完整的,也就是說你即便得到了也無法用。x0dx0a另外只要這款游戲是國產的,你如果一模一樣也不行,因為違反版權。x0dx0a所以就算你拿到了源代碼,你也要有完整的美術資源,需要讓程序貼圖替換上去,達到視覺上不一樣的效果。世界背景和故事都要換,所有這些的成本當然不是一般的高。x0dx0a好吧,即便你搞好了,那接下來你還要運營吧,運營的成本就更高了。

E. 大神們 急求基於eclipse的java小游戲程序的源碼,程序不要多復雜啊。像坦克大戰,五子棋,掃雷之類的謝謝


import java.util.Scanner;


public class Wuziqi {

/**

* 棋盤

*/

private final int[][] qipan;

/**

* 步數

*/

private int bushu;

/**

* 構造方法,設置棋盤規格

* @param x

* @param y

*/

public Wuziqi(int x, int y) {

if (x < 1 || y < 1) {

System.out.println("棋盤規格應不小於1,使用默認規格");

qipan = new int[9][9];

} else {

qipan = new int[y][x];

}

}

/**

* 游戲開始

*/

public void play() {

int[] zuobiao = null;

//如果游戲沒有結束

while (!end(zuobiao)) {

//落子,並取得坐標

zuobiao = luozi();

//輸出棋盤

out();

}

}

/**

* 輸出棋盤和棋子

*/

private void out() {

for (int i = 0; i < qipan.length; i++) {

for (int j = 0; j < qipan[i].length; j++) {

if (qipan[i][j] == 0) {

System.out.print(" +");

}else if (qipan[i][j] == -1) {

System.out.print(" 白");

}else if (qipan[i][j] == 1) {

System.out.print(" 黑");

}

}

System.out.println(" ");

}

}

/**

* 落子

*/

private int[] luozi() {

int[] zuobiao;

bushu++;

if (bushu % 2 == 1) {

System.out.println("請黑方落子");

zuobiao = input();

qipan[zuobiao[1]][zuobiao[0]] = 1;

}else {

System.out.println("請白方落子");

zuobiao = input();

qipan[zuobiao[1]][zuobiao[0]] = -1;

}

return zuobiao;

}

/**

* 輸入坐標

* @return

*/

private int[] input() {

Scanner sc = new Scanner(System.in);

System.out.println("請輸入x軸坐標");

String x = sc.next();

System.out.println("請輸入y軸坐標");

String y = sc.next();

//如果沒有通過驗證,則再次執行input(),遞歸演算法

if (!validate(x, y)) {

return input();

}

int int_x = Integer.valueOf(x);

int int_y = Integer.valueOf(y);

return new int[] {int_x, int_y};

}

/**

* 校驗數據

* @param x

* @param y

* @return

*/

private boolean validate(String x, String y) {

Integer int_x = null;

Integer int_y = null;

//異常處理的方式判斷字元串是否是一個整數

try {

int_x = Integer.valueOf(x);

int_y = Integer.valueOf(y);

} catch (NumberFormatException e) {

System.out.println("坐標格式錯誤,坐標應為整數");

return false;

}

if (int_x < 0 || int_y < 0 || int_x >= qipan[0].length || int_y >= qipan.length) {

System.out.println("坐標越界");

return false;

}

if (qipan[int_y][int_x] == 0) {

return true;

} else {

System.out.println("坐標上已有棋子");

}

return false;

};

/**

* 結束條件

* @return

*/

private boolean end(int[] zuobiao) {

if (zuobiao == null) {

return false;

}

//計數器

//表示棋盤上經過最近落子坐標的4條線上的連續(和最近落子顏色相同的)棋子的個數

//如果某條線上連續的棋子大於等於4(加上最近落子本身,大於等於5),則游戲結束,符合五子棋規則

int[] jieguo = new int[4];

int x = zuobiao[0];

int y = zuobiao[1];

//定義八個方向

final int[][] fangxiang = {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}};

//最近落子的坐標上的棋子顏色

int number = qipan[y][x];

//搜索最近落子坐標為中心最遠4的距離

for (int i = 1; i <= 4; i++) {

//每次搜索不同的距離都搜索八個方向

for (int j = 0; j < fangxiang.length; j++) {

//約定如果某個方向為null時,不再搜索這個方向。關鍵字continue是跳過本次(一次)循環的意思

if (fangxiang[j] == null) {

continue;

}

int mubiao_x = x + i * fangxiang[j][0];

int mubiao_y = y + i * fangxiang[j][1];

//如果搜索坐標相對於棋盤越界,則不再搜索這個方向

if (mubiao_y >= qipan.length || mubiao_y < 0 || mubiao_x >= qipan[0].length || mubiao_x < 0) {

fangxiang[j] = null;

continue;

}

//如果最近落子坐標上的值等於目標坐標上的值(顏色相同),則計數器上某條線加1

//否則認為這個方向沒有棋子或有別的顏色的棋子,不再搜索這個方向

if (number == qipan[mubiao_y][mubiao_x]) {

jieguo[j % 4]++;

}else {

fangxiang[j] = null;

}

}

}

//查看計數器上是否有比3更大的數(查看是否有一方勝出)

for (int i : jieguo) {

if (i > 3) {

System.out.println("游戲結束");

if (bushu % 2 == 1) {

System.out.println("黑方勝");

} else {

System.out.println("白方勝");

}

return true;

}

}

//沒有勝出者的情況下,查看棋盤上是否還有空位置,如果有,則游戲可以繼續

for (int[] arr : qipan) {

for (int i : arr) {

if (i == 0) {

return false;

}

}

}

//如果沒有空位置,則平局

System.out.println("游戲結束,平局");

return true;

}


}

F. 怎樣獲得一款游戲的源代碼

源碼可以找游戲公司要,比如夢幻誅仙為什麼那麼多私服,就是源碼搭出來的

G. 用c++來編寫一個小游戲的源代碼,要100-200行就可以了,可以再vc環境下運行就可。。。本人急需!~!~!

//作者:小斌
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
//using namespace std;

const char LEFT=0x4b;
const char RIGHT=0x4d;
const char DOWN=0x50;
const char UP=0x48;
const char ESC=0x1b;
const char ENTER=0x0d;

const int BX=200;
const int BY=170;
const int SQ=30;

const int SQCL=10;
const int BkCl=BLUE;
const int SHAP1=2;
const int SHAP2=3;
const int SHAP3=4;
const int SHAP4=5;

void drawxiao(int &x, int &y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SQCL);
bar(a+1, b+1, a+SQ-1, b+SQ-1);
}

void clearxiao(int &x, int &y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, BkCl);
bar(a+1, b+1, a+SQ-1, b+SQ-1);
}

void goleft(int &x, int &y)
{
if(x>0)
{
clearxiao(x, y);
drawxiao(--x, y);
}
}

void goright(int &x, int &y)
{
if(x<7)
{
clearxiao(x, y);
drawxiao(++x, y);
}
}

void godown(int &x, int &y)
{
if(y<7)
{
clearxiao(x, y);
drawxiao(x, ++y);
}
}

void goup(int &x, int &y)
{
if(y>0)
{
clearxiao(x, y);
drawxiao(x, --y);
}
}

void end()
{
closegraph();
exit(1);
}

void move(int &x, int &y)
{
int n=1;
drawxiao(x, y);
while(n)
switch(getch())
{
case LEFT :goleft(x, y); break;
case RIGHT :goright(x, y); break;
case DOWN :godown(x, y); break;
case UP :goup(x, y); break;
case ENTER :n=0; break;
case ESC :end();
}
}

void qipan()
{
int i;
setbkcolor(BkCl);
setfillstyle(1, 15);

for(i=0; i<9; i++)
{
line(BX, i*SQ+BY, BX+8*SQ, i*SQ+BY);
line(i*SQ+BX, BY, i*SQ+BX, BY+8*SQ);
}
}

void shap1(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP1);
bar(a+1, b+1, a+SQ-1, b+2*SQ-1);
bar(a-SQ+1, b+1+SQ, a, b-1+2*SQ);
}

void shap2(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP2);
bar(a+1, b+1, a+SQ-1, b+2*SQ-1);
bar(a+SQ, b+SQ+1, a+2*SQ-1, b+2*SQ-1);
}

void shap3(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP3);
bar(a+1, b+1, a+2*SQ-1, b+SQ-1);
bar(a+SQ+1, b+SQ, a+2*SQ-1, b+2*SQ-1);
}

void shap4(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP4);
bar(a+1, b+1, a+2*SQ-1, b+SQ-1);
bar(a+1, b+SQ, a+SQ-1, b+2*SQ-1);
}

void chessboard(int size, int tr, int tc, int dr, int dc)
{
if(size>=2)
{
size=size/2;
if(dc<tc+size)//左邊半個棋盤
{
if(dr<tr+size)//左上
{
shap1(tr+size, tc+size-1);
chessboard(size, tr, tc, dr, dc);
chessboard(size, tr+size, tc, tr+size, tc+size-1);
}
else//左下
{
shap2(tr+size-1, tc+size-1);
chessboard(size, tr, tc, tr+size-1, tc+size-1);
chessboard(size, tr+size, tc, dr, dc);
}
chessboard(size, tr, tc+size, tr+size-1, tc+size);
chessboard(size, tr+size, tc+size, tr+size, tc+size);
}
else//在右邊半個棋盤
{
if(dr<tr+size)//右上
{
shap3(tr+size-1, tc+size-1);
chessboard(size, tr, tc+size, dr, dc);
chessboard(size, tr+size, tc+size, tr+size, tc+size);
}
else//右下
{
shap4(tr+size-1, tc+size-1);
chessboard(size, tr, tc+size, tr+size-1, tc+size);
chessboard(size, tr+size, tc+size, dr, dc);
}
chessboard(size, tr, tc, tr+size-1, tc+size-1);
chessboard(size, tr+size, tc, tr+size, tc+size-1);
}
}
}

int main()
{
int driver=DETECT, mode;
int x=0, y=0;

initgraph(&driver, &mode, "C:\\JMSOFT\\DRV");

qipan();//畫棋盤
move(x, y);//移動特殊方格

chessboard(8, 0, 0, x, y);//覆蓋棋盤
getch();
return 0;
}

H. 推薦一些游戲源碼網站

v3源碼 。挺不錯的。種類齊全,源碼下載,學習娛樂 都可以

閱讀全文

與精品游戲源碼相關的資料

熱點內容
編譯iso 瀏覽:938
照片生成pdf格式 瀏覽:194
病歷轉pdf 瀏覽:835
雲伺服器配硬體 瀏覽:978
伺服器10k什麼意思 瀏覽:21
pdfeditor漢化 瀏覽:884
新科學pdf 瀏覽:746
現在還有c語言編譯嗎 瀏覽:674
哪裡買到單片機 瀏覽:480
linux文件打開數量 瀏覽:510
編譯原理中什麼是l屬性文法 瀏覽:371
硬碟加密時出現的問題 瀏覽:61
如何退域命令 瀏覽:108
看書的app哪裡看 瀏覽:291
伺服器怎麼調大 瀏覽:3
android天氣apijson 瀏覽:984
為什麼創建id會出現伺服器錯誤 瀏覽:837
代碼中有不必編譯的單詞嗎 瀏覽:563
鉤子與資料庫編程 瀏覽:563
安卓光遇錄歌怎麼設置 瀏覽:485