当前位置:首页 > 代码 > 正文

vb6连连看小游戏代码(vb小游戏程序代码)

admin 发布:2022-12-19 21:10 170


今天给各位分享vb6连连看小游戏代码的知识,其中也会对vb小游戏程序代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

求一个简单的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;//消除方法控制

public void init(){

mainFrame=new JFrame("JKJ连连看");

thisContainer = mainFrame.getContentPane();

thisContainer.setLayout(new BorderLayout());

centerPanel=new JPanel();

southPanel=new JPanel();

northPanel=new JPanel();

thisContainer.add(centerPanel,"Center");

thisContainer.add(southPanel,"South");

thisContainer.add(northPanel,"North");

centerPanel.setLayout(new GridLayout(6,5));

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));

diamondsButton[cols][rows].addActionListener(this);

centerPanel.add(diamondsButton[cols][rows]);

}

}

exitButton=new JButton("退出");

exitButton.addActionListener(this);

resetButton=new JButton("重列");

resetButton.addActionListener(this);

newlyButton=new JButton("再来一局");

newlyButton.addActionListener(this);

southPanel.add(exitButton);

southPanel.add(resetButton);

southPanel.add(newlyButton);

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));

northPanel.add(fractionLable);

mainFrame.setBounds(280,100,500,450);

mainFrame.setVisible(true);

}

public void randomBuild() {

int randoms,cols,rows;

for(int twins=1;twins=15;twins++) {

randoms=(int)(Math.random()*25+1);

for(int alike=1;alike=2;alike++) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=randoms;

}

}

}

public void fraction(){

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));

}

public void reload() {

int save[] = new int[30];

int n=0,cols,rows;

int grid[][]= new int[8][7];

for(int i=0;i=6;i++) {

for(int j=0;j=5;j++) {

if(this.grid[i][j]!=0) {

save[n]=this.grid[i][j];

n++;

}

}

}

n=n-1;

this.grid=grid;

while(n=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=save[n];

n--;

}

mainFrame.setVisible(false);

pressInformation=false; //这里一定要将按钮点击信息归为初始

init();

for(int i = 0;i 6;i++){

for(int j = 0;j 5;j++ ){

if(grid[i+1][j+1]==0)

diamondsButton[i][j].setVisible(false);

}

}

}

public void estimateEven(int placeX,int placeY,JButton bz) {

if(pressInformation==false) {

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

pressInformation=true;

}

else {

x0=x;

y0=y;

fristMsg=secondMsg;

firstButton=secondButton;

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

if(fristMsg==secondMsg secondButton!=firstButton){

xiao();

}

}

}

public void xiao() { //相同的情况下能不能消去。仔细分析,不一条条注释

if((x0==x (y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)(y0==y))){ //判断是否相邻

remove();

}

else{

for (j=0;j7;j++ ) {

if (grid[x0][j]==0){ //判断第一个按钮同行哪个按钮为空

if (yj) { //如果第二个按钮的Y坐标大于空按钮的Y坐标说明第一按钮在第二按钮左边

for (i=y-1;i=j;i-- ){ //判断第二按钮左侧直到第一按钮中间有没有按钮

if (grid[x][i]!=0) {

k=0;

break;

}

else{ k=1; } //K=1说明通过了第一次验证

}

if (k==1) {

linePassOne();

}

}

if (yj){ //如果第二个按钮的Y坐标小于空按钮的Y坐标说明第一按钮在第二按钮右边

for (i=y+1;i=j ;i++ ){ //判断第二按钮左侧直到第一按钮中间有没有按钮

if (grid[x][i]!=0){

k=0;

break;

}

else { k=1; }

}

if (k==1){

linePassOne();

}

}

if (y==j ) {

linePassOne();

}

}

if (k==2) {

if (x0==x) {

remove();

}

if (x0x) {

for (n=x0;n=x-1;n++ ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x-1) {

remove();

}

}

}

if (x0x) {

for (n=x0;n=x+1 ;n-- ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x+1) {

remove();

}

}

}

}

}

for (i=0;i8;i++ ) { //列

if (grid[i][y0]==0) {

if (xi) {

for (j=x-1;j=i ;j-- ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else { k=1; }

}

if (k==1) {

rowPassOne();

}

}

if (xi) {

for (j=x+1;j=i;j++ ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else { k=1; }

}

if (k==1) {

rowPassOne();

}

}

if (x==i) {

rowPassOne();

}

}

if (k==2){

if (y0==y) {

remove();

}

if (y0y) {

for (n=y0;n=y-1 ;n++ ) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y-1) {

remove();

}

}

}

if (y0y) {

for (n=y0;n=y+1 ;n--) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y+1) {

remove();

}

}

}

}

}

}

}

public void linePassOne(){

if (y0j){ //第一按钮同行空按钮在左边

for (i=y0-1;i=j ;i-- ){ //判断第一按钮同左侧空按钮之间有没按钮

if (grid[x0][i]!=0) {

k=0;

break;

}

else { k=2; } //K=2说明通过了第二次验证

}

}

if (y0j){ //第一按钮同行空按钮在与第二按钮之间

for (i=y0+1;i=j ;i++){

if (grid[x0][i]!=0) {

k=0;

break;

}

else{ k=2; }

}

}

}

public void rowPassOne(){

if (x0i) {

for (j=x0-1;j=i ;j-- ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else { k=2; }

}

}

if (x0i) {

for (j=x0+1;j=i ;j++ ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else { k=2; }

}

}

}

public void remove(){

firstButton.setVisible(false);

secondButton.setVisible(false);

fraction();

pressInformation=false;

k=0;

grid[x0][y0]=0;

grid[x][y]=0;

}

public void actionPerformed(ActionEvent e) {

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

int grid[][] = new int[8][7];

this.grid = grid;

randomBuild();

mainFrame.setVisible(false);

pressInformation=false;

init();

}

if(e.getSource()==exitButton)

System.exit(0);

if(e.getSource()==resetButton)

reload();

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

if(e.getSource()==diamondsButton[cols][rows])

estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);

}

}

}

public static void main(String[] args) {

lianliankan llk = new lianliankan();

llk.randomBuild();

llk.init();

}

}

//old 998 lines

//new 318 lines

跪求用vb6.0制作小游戏的源代码

Option Explicit

Private WithEvents Timer1 As Timer

Private WithEvents Label1 As Label

Dim GFangXiang As Boolean

Dim HWB As Single

Dim She() As ShenTi

Dim X As Long, Y As Long

Dim ZhuangTai(23, 23) As Long

Private Type ShenTi

F As Long

X As Long

Y As Long

End Type

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Dim C As Long

If KeyCode = 27 Then End

If KeyCode = 32 Then

If Timer1.Enabled = True Then

Timer1.Enabled = False

Label1.Visible = True

Else

Timer1.Enabled = True

Label1.Visible = False

End If

End If

C = UBound(She)

If GFangXiang = True Then Exit Sub

Select Case KeyCode

Case 37

If She(C).F = 2 Then Exit Sub

She(C).F = 0

GFangXiang = True

Case 38

If She(C).F = 3 Then Exit Sub

She(C).F = 1

GFangXiang = True

Case 39

If She(C).F = 0 Then Exit Sub

She(C).F = 2

GFangXiang = True

Case 40

If She(C).F = 1 Then Exit Sub

She(C).F = 3

GFangXiang = True

End Select

End Sub

Private Sub Form_Load()

Me.AutoRedraw = True

Me.BackColor = HC000

Me.FillColor = 255

Me.FillStyle = 0

Me.ScaleWidth = 24

Me.ScaleHeight = 24

Me.WindowState = 2

Set Timer1 = Controls.Add("VB.Timer", "Timer1")

Set Label1 = Controls.Add("VB.Label", "Label1")

Label1.AutoSize = True

Label1.BackStyle = 0

Label1 = "暂停"

Label1.ForeColor = RGB(255, 255, 0)

Label1.FontSize = 50

ChuShiHua

End Sub

Private Sub Form_Resize()

On Error GoTo 1:

With Me

If .WindowState 1 Then

.Cls

.ScaleMode = 3

HWB = .ScaleHeight / .ScaleWidth

.ScaleWidth = 24

.ScaleHeight = 24

Label1.Move (Me.ScaleWidth - Label1.Width) / 2, (Me.ScaleHeight - Label1.Height) / 2

HuaTu

Me.Line (X, Y)-(X + 1, Y + 1), RGB(255, 255, 0), BF

End If

End With

1:

End Sub

Private Sub Timer1_Timer()

Dim C As Long, I As Long

On Error GoTo 2:

QingChu

C = UBound(She)

Select Case She(C).F

Case 0

If ZhuangTai(She(C).X - 1, She(C).Y) = 2 Then

C = C + 1

ReDim Preserve She(C)

She(C).F = She(C - 1).F

She(C).X = She(C - 1).X - 1

She(C).Y = She(C - 1).Y

ChanShengShiWu

GoTo 1:

ElseIf ZhuangTai(She(C).X - 1, She(C).Y) = 1 Then

GoTo 2:

End If

Case 1

If ZhuangTai(She(C).X, She(C).Y - 1) = 2 Then

C = C + 1

ReDim Preserve She(C)

She(C).F = She(C - 1).F

She(C).X = She(C - 1).X

She(C).Y = She(C - 1).Y - 1

ChanShengShiWu

GoTo 1:

ElseIf ZhuangTai(She(C).X, She(C).Y - 1) = 1 Then

GoTo 2:

End If

Case 2

If ZhuangTai(She(C).X + 1, She(C).Y) = 2 Then

C = C + 1

ReDim Preserve She(C)

She(C).F = She(C - 1).F

She(C).X = She(C - 1).X + 1

She(C).Y = She(C - 1).Y

ChanShengShiWu

GoTo 1:

ElseIf ZhuangTai(She(C).X + 1, She(C).Y) = 1 Then

GoTo 2:

End If

Case 3

If ZhuangTai(She(C).X, She(C).Y + 1) = 2 Then

C = C + 1

ReDim Preserve She(C)

She(C).F = She(C - 1).F

She(C).X = She(C - 1).X

She(C).Y = She(C - 1).Y + 1

ChanShengShiWu

GoTo 1:

ElseIf ZhuangTai(She(C).X, She(C).Y + 1) = 1 Then

GoTo 2:

End If

End Select

ZhuangTai(She(0).X, She(0).Y) = 0

For I = 0 To C

Select Case She(I).F

Case 0

She(I).X = She(I).X - 1

Case 1

She(I).Y = She(I).Y - 1

Case 2

She(I).X = She(I).X + 1

Case 3

She(I).Y = She(I).Y + 1

End Select

Next

TiaoZheng

1:

GFangXiang = False

ZhuangTai(She(C).X, She(C).Y) = 1

HuaTu

Exit Sub

2:

If MsgBox("游戏结束,点“是”重新开始游戏,点“否”", vbYesNo, "贪吃蛇") = vbYes Then

ChuShiHua

Else

End

End If

End Sub

Private Sub ChuShiHua()

Me.Cls

Timer1.Enabled = True

Timer1.Interval = 200

Erase ZhuangTai

ReDim She(2)

She(0).F = 2

She(0).X = 9

She(0).Y = 11

ZhuangTai(9, 11) = 1

She(1).F = 2

She(1).X = 10

She(1).Y = 11

ZhuangTai(10, 11) = 1

She(2).F = 2

She(2).X = 11

She(2).Y = 11

ZhuangTai(11, 11) = 1

HuaTu

ChanShengShiWu

End Sub

Private Sub QingChu()

Dim I As Long

For I = 0 To UBound(She)

Me.Line (She(I).X, She(I).Y)-(She(I).X + 1, She(I).Y + 1), Me.BackColor, BF

Next

End Sub

Private Sub HuaTu()

Dim I As Long

For I = 0 To UBound(She)

Me.Circle (She(I).X + 0.5, She(I).Y + 0.5), 0.49, RGB(255, 255, 0), , , HWB

Next

End Sub

Private Sub TiaoZheng()

Dim I As Long

For I = 0 To UBound(She) - 1

She(I).F = She(I + 1).F

Next

End Sub

Private Sub ChanShengShiWu()

Randomize Timer

1:

X = Int(Rnd * 24)

Y = Int(Rnd * 24)

If ZhuangTai(X, Y) 0 Then GoTo 1:

ZhuangTai(X, Y) = 2

Me.Line (X, Y)-(X + 1, Y + 1), RGB(255, 255, 0), BF

End Sub

贪吃蛇游戏,不用放任何东西

VB如何替换内存地址的值?

主要是使用ReadProcessMemory,WriteProcessMemory这两个函数。一个读一个写。

我这里有一段代码,自己写的,可供参考,仅供学习!

在VB.NET写通过,VB6。0应该也可以。

'API常量

Public Const PROCESS_ALL_ACCESS As Integer = 2035711

'获取连连看游戏窗口句柄

Dim QQllkhwnd As Integer

QQllkhwnd = FindWindow(vbNullString, "QQ连连看")

'判断连连看游戏是否打开

If QQllkhwnd 0 Then

'连连看游戏线程ID

Dim ProcessId As Integer

'根据连连看游戏窗口句柄获取对对碰游戏线程ID

l = GetWindowThreadProcessId(QQllkhwnd, ProcessId)

'判断是否获取连连看游戏线程ID

If l 0 Then

'根据线程ID打开连连看游戏线程

Dim hRemoteProcess As Integer = OpenProcess(PROCESS_ALL_ACCESS, CInt(True), ProcessId)

'判断是否打开连连看游戏线程

If hRemoteProcess 0 Then

'通过读取几个字节来看看是否是可以修改的版本

Dim check_buffer(50) As Byte

l = ReadProcessMemory(hRemoteProcess, H40B468, check_buffer, 5, 0)

If l = 0 Or check_buffer(0) H3D Or _

check_buffer(1) HC9 Or _

check_buffer(2) HD5 Or _

check_buffer(3) H66 Or _

check_buffer(4) H1 Then

MsgBox("QQ 连连看版本不同,本程序无法处理!")

Application.Exit()

End If

'修改内存代码,让他忽略检测鼠标硬件单击

' Dim change_address As Integer = H40B46E

' Dim change_data As String = Chr(0)

'H40B46E为要修改的地址,chr(0) 是要改成的字节,1表示修改一个字节长度 0 表示不用

'检测WriteProcessMemory成功写入了多少字节

l = WriteProcessMemory(hRemoteProcess, H40B46E, Chr(0), 1, 0)

'判断是否将指定DLL写入指定线程

If l = 0 Then

MsgBox("WriteProcessMemory错误!")

End If

CloseHandle(hRemoteProcess)

' MsgBox("注入成功!")

Else

MsgBox(" 打开线程错误!")

End If

Else

MsgBox("获取线程ID错误!")

End If

Else

MsgBox("请打开连连看游戏!然后再单击 内存补丁 按钮 ")

End If

求一个VB程序代码,连连看的,谢谢

' '以下代码在 VB6 调试通过。

'一.将以下代码全部复制到窗体代码窗口内'以下代码在 VB6 调试通过。

'二.为窗体添加菜单

' 添加菜单 mFast,并为 mFast 添加子菜单 mmFast 和 mmTu

' 为 mmTu 添加子菜单 mmPic

' 将菜单 mmFast 和 mmPic 的索引设置为 0,其他属性不必设置。菜单结构如下:

' mFast

' ....mmFast 索引(index 属性)设置为 0

' ....mmTu

' ........mmPic 索引(index 属性)设置为 0

'三.在窗体中添加 7 个控件

' 4 个数组控件:Image1,Shape1,Label1,Line1,并将这四个控件的 Index 属性设置为 0

' 3 个单独控件:Picture1,Dir1,Timer1,都不用设置任何属性

'四.默认使用系统图标图案,如果要使用自己设置的图片(Ico文件),在工程所在目录下新建一个文件夹 Tu ,

' 在 Tu 下可建立多个文件夹,如“国旗”、“交通标准”等,然后将相应图标文件

' 放到其中,每个文件夹可放置 100 个文件。

Private Type tyTu

ImageNum As Integer 'Image 控件序号

Tu As Long '图片序号

Visible As Boolean '是否可见

End Type

Enum enTo

to_Up

to_Down

to_Left

to_Right

End Enum

Enum enTai

tai_Stop

tai_Play

tai_Auto

tai_Step

End Enum

Dim ctTu() As tyTu, ctH As Long, ctL As Long, ctGD() As Long, ctGDs As Long, ctBusy As Boolean '忙

Dim ctPicMax As Long, ctPicS As Long, ctPic() As Picture, ctNotePic() As String, ctSeBack() As Long

Dim ctTuType As String, ctSize As Long, ctX As Long, ctY As Long, ctTai As enTai

Dim ctHide() As Long, ctHideS As Long, ctStep As Long, ctStr As String, ctRefresh As Boolean

Dim ctMaxGD As Long, ctFen As Long, ctLife As Long, ctNote As Long

Dim ctFlashCi As Long, ctWait As Boolean, ctExit As Boolean

Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long

Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Private Function GetIcoToZu(nIco As String, Optional ReRead As Boolean) As Long

'提取图片,存入 ctPic(),并设置 ctNotePic()

Static UpIco As String

Dim F As String, S As Long, IcoID As Long, dl As Long, nPicS As Long

Dim nL As Long, nT As Long, pW As Long, pH As Long, nW As Long, nH As Long

Dim nPath As String, I As Long

If ReRead Then UpIco = "" '无条件重新读取图片文件

If UpIco = nIco Then GetIcoToZu = UBound(ctPic): Exit Function

UpIco = nIco

pW = Picture1.ScaleX(ctSize, Picture1.ScaleMode, 3) '转为像素

pH = Picture1.ScaleY(ctSize, Picture1.ScaleMode, 3) '转为像素

nW = 32: nH = 32

If pW 32 Then nW = pW

If pH 32 Then nH = pH

ReDim ctPic(1 To 1): ReDim ctNotePic(1 To 1)

Picture1.Move 0, 0, ctSize, ctSize

Picture1.Picture = LoadPicture()

关于vb6连连看小游戏代码和vb小游戏程序代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/24255.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载