当前位置: 首页 > news >正文

为什么做街舞网站成都网站建设技术外包

为什么做街舞网站,成都网站建设技术外包,女生java能干多久,腾讯网站认证devc 5.11编译环境 dll编译环境设置参考 Dev c C语言实现第一个 dll 动态链接库 创建与调用-CSDN博客 插件 DLL代码和主程序代码如下 注意 dll 代码中的class 类名需要 和主程序 相同 其中使用了函数指针和强制类型转换 函数指针教程参考 以动态库链接库 .dll 探索结构体…

devc++ 5.11编译环境

dll编译环境设置参考

Dev c++ C语言实现第一个 dll 动态链接库 创建与调用-CSDN博客 

 插件 DLL代码和主程序代码如下

注意 dll 代码中的class 类名需要 和主程序 相同

其中使用了函数指针和强制类型转换

函数指针教程参考

以动态库链接库 .dll 探索结构体参数-CSDN博客

注意,退出游戏后需等30-50秒,让dll自行销毁,然后重开时才能正常运行。否则进入后不显示地图。

有dll时:

 

 无DLL插件读取到时,即dll不在同程序目录下

 

dll.h
#ifndef _DLL_H_
#define _DLL_H_
#include <iostream>
using namespace std;
// 游戏背景操作板,可以通过坐标直接改
class Bkmap
{public:Bkmap(int height,int wide){this->wide=wide;this->height=height;this->bkmap=new char*[this->height];for(int i=0; i<height; i++){this->bkmap[i]=new char[this->wide];for(int j=0; j<wide; j++){this->bkmap[i][j]='\0';}}}public:char** bkmap;int wide;int height;};// 玩家类,移动,攻击,地图修改
class Player
{public:Player(int x,int y,int limitx,int limity){this->playerx=x;this->playery=y;is_atk=0;is_buff=0;flag_x=0;flag_y=0;this->limitx=limitx;this->limity=limity;}~Player();public:char player='1';int playerx;int playery;int flag_x;int flag_y;int limitx;int limity;int is_atk;int is_buff;public:
};// 攻击类,这里直线攻击做测试
class Aking
{public:Aking(int height,int wide,int atk_time,int number){this->height=height;this->wide=wide;this->number=number;this->atk_time=atk_time;atk_count=0;}public:int height;																// 攻击范围长宽int wide;int number;																// 攻击序号,因为有多个攻击技能,所以编号,可以查找攻击int atk_time;															// 攻击时长int atk_count;															// 当前攻击持续时间public:// 攻击中void atking(Bkmap* bkmap,Player* player){if (atk_count != atk_time)										// 攻击{atk_count++;cout<<"DLL"<<atk_count<<endl; cout<<"DLL:playerx player y:"<<player->playerx<<","<<player->playery<<endl;cout<<"DLL: player is_atk:"<<player->is_atk<<endl;for(int j=0; j<10; j++){bkmap->bkmap[player->playery][player->playerx+1+j]='P';}}else{atk_count=0;player->is_atk=0; 												// 玩家状态复位}}
};static Aking* akv3=new Aking(20,50,20,3); 										// 静态类,在调用时,保存被调用的值,调用结束后数值不清空 extern "C"{void mainDll(Bkmap* bkmap,Player* player);
}#endif

插件 dll.cpp

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>void mainDll(Bkmap* bkmap,Player* player)
{
//	cout<<"DLL: atking class start"<<endl;akv3->atking(bkmap,player);
}

 

主程序,注意和dll放在同一个目录下

#include <iostream>
#include <string.h>
#include <windows.h>#define KEY_DOWN(vKey) ((GetAsyncKeyState(vKey) & 0x8000) ? 1:0)							// 判断是否按下按键,按下之后,最高位变成 1,所以需要位运算去除其他位,只检测最高位
#define KEY_DOWN_FOREGROUND(hWnd, vk) (KEY_DOWN(vk) && GetForegroundWindow() == hWnd) 		// 前景窗口判断
#pragma warning(disable : 4996)
using namespace std;// 加入的游戏背景数据,通常不修改,放到 Bkmap 进行修改
class Gamemap
{public:Gamemap(int height,int wide){this->wide=wide;this->height=height;this->gamemap=new int*[this->height];for(int i=0; i<height; i++){this->gamemap[i]=new int[this->wide];for(int j=0; j<this->wide; j++){this->gamemap[i][j]=0;}}}~Gamemap();public:int** gamemap;int wide;int height;
};
// 游戏背景操作板,可以通过坐标直接改
class Bkmap
{public:Bkmap(int height,int wide){this->wide=wide;this->height=height;this->bkmap=new char*[this->height];for(int i=0; i<height; i++){this->bkmap[i]=new char[this->wide];for(int j=0; j<wide; j++){this->bkmap[i][j]='\0';}}}public:char** bkmap;int wide;int height;public:void adddata(){for(int i=0; i<this->height; i++)								// 地图数据写入{for(int j=0; j<this->wide-1; j++){this->bkmap[i][j]='*';}this->bkmap[i][this->wide-1]='\0';cout<<this->bkmap[i]<<"ok"<<endl;}}void fresh(Gamemap* gamemap){for(int i=0; i<gamemap->height; i++)							// 地图复印到选区{for(int j=0; j<gamemap->wide; j++){if(gamemap->gamemap[i][j]==0)this->bkmap[i][j]=' ';					// 这里决定地图打印在屏幕的样子}}}};
// 字符串缓冲类
class Showmap
{public:Showmap(int height,int wide){this->showmap=new char[wide*height+1000];strcpy(showmap,"");
//			showmap={};												// 不能这样写,否则报错,指针重新变空}public:char* showmap;public:void adddata(Bkmap* bkmap){cout<<"test"<<endl;if(showmap==NULL){cout<<"NULL";cout<<"函数因空指针结束"<<endl;return;}strcpy(showmap,"");for(int i=0; i<bkmap->height; i++)								// 选区加入到打印缓冲区{strcat(showmap,bkmap->bkmap[i]);strcat(this->showmap,"\n");}}void show(){cout<<this->showmap;}
};// 玩家类,移动,攻击,地图修改
class Player
{public:Player(int x,int y,int limitx,int limity){this->playerx=x;this->playery=y;is_atk=0;is_buff=0;flag_x=0;flag_y=0;this->limitx=limitx;this->limity=limity;}~Player();public:char player='1';int playerx;int playery;int flag_x;int flag_y;int limitx;int limity;int is_atk;int is_buff;public://玩家移动检测void checkmove(HWND hwnd){flag_x=0;flag_y=0;if (KEY_DOWN_FOREGROUND(hwnd, 0x41))			// A{flag_x -= 1;}if (KEY_DOWN_FOREGROUND(hwnd, 0x57))			// W{flag_y -= 1;}if (KEY_DOWN_FOREGROUND(hwnd, 0x44))			// D{flag_x += 1;}if (KEY_DOWN_FOREGROUND(hwnd, 0x53))			// S{flag_y += 1;}}// 打包速度检测void checkspeed(){if (flag_x > 1)														// 速度限制flag_x = 1;else if (flag_x < -1)flag_x = -1;if (flag_y > 1)flag_y = 1;else if (flag_y < -1)flag_y = -1;}// 改变玩家位置void move(){if (flag_x)															// 位移改变playerx += flag_x;if (flag_y)playery += flag_y;}
//		边界检测void checkboundary(){if (playerx >= limitx)												// 角色位置限制playerx = limitx - 1;else if (playerx < 0)playerx = 0;if (playery >= limity)playery = limity - 1;else if (playery < 0)playery = 0;}void putinmap(Bkmap* bkmap){bkmap->bkmap[playery][playerx]=player;}
//		检测攻击void checkatk(HWND hwnd){if (is_atk == 0 && KEY_DOWN_FOREGROUND(hwnd, 0x4A))			// j 键攻击{is_atk = 1;}}
//		检测buffvoid checkbuff(HWND hwnd){if (is_buff == 0 && KEY_DOWN_FOREGROUND(hwnd, 0x4B))		// k 键增加范围 buff{is_buff = 1;}}// 绘制地图void drawmap(HWND hwnd,Gamemap* gamemap){if (KEY_DOWN_FOREGROUND(hwnd, 0x30))								// 0 键绘制地图gamemap->gamemap[playery][playerx] = 0;if (KEY_DOWN_FOREGROUND(hwnd, 0x36))								// 6 键绘制地图gamemap->gamemap[playery][playerx] = 6;if (KEY_DOWN_FOREGROUND(hwnd, 0x37))								// 7 键绘制地图gamemap->gamemap[playery][playerx] = 7;if (KEY_DOWN_FOREGROUND(hwnd, 0x38))								// 8 键绘制地图gamemap->gamemap[playery][playerx] = 8;if (KEY_DOWN_FOREGROUND(hwnd, 0x39))								// 9 键绘制地图gamemap->gamemap[playery][playerx] = 9;}
};class Dlling
{typedef void(*Menu)(Bkmap* bkmap,Player* player);										// 定义函数指针,函数返回值是 void, 指针类型名是 Menu, 参数是Bkmap*public:Dlling(char* name,int number){mainDll="mainDll";HINSTANCE hDLL = LoadLibrary(name);													// 加载dll库if(hDLL==NULL){cout<<"没有在本目录里找到 dllv3.dll"<<endl;atk=NULL;Sleep(300);}else{void(*atkv2)(Bkmap* bkmap,Player*)= (void (*)(Bkmap*,Player*))GetProcAddress(hDLL,mainDll);		// 加载dll 的入口主函数 强制类型转换后,加载的dll主函数成为atkv2的替身if(atkv2==NULL){cout<<"dllv3 插件没有读取"<<endl;atk=NULL;Sleep(300);}else{cout<<"dllv3 读取成功"<<endl;Sleep(300);atk = atkv2;}}count=0;}public:char* mainDll;Menu atk;int count;													// 成员是一个指针,目前没有函数替身,所以没有编译报错public:void aking(Bkmap* bkmap,Player* player){cout<<"class_atkv3"<<endl;if(player->is_atk&&atk!=NULL){cout<<"class_atkv3 is going"<<endl;atk(bkmap,player);										// 函数指针在初始化过程在有了替身函数,所以可以加入变量}else if(player->is_atk&&atk==NULL){cout<<"dll是空的,跳过执行函数"<<endl;count++;if(count>10){player->is_atk=0;count=0;}}}
};int main()
{Gamemap* gamemap = new Gamemap(20,50);Bkmap* bkmap=new Bkmap(20,50);Showmap* showmap= new Showmap(20,80);Dlling* dll = new Dlling("dllv3.dll",3);bkmap->fresh(gamemap);
//	bkmap->adddata();showmap->adddata(bkmap);showmap->show();HWND hwnd = GetForegroundWindow();									// 获取前端窗口句柄,由于程序刚运行时是在前端,所以这就是本程序的窗口句柄Player* player = new Player(0,0,50,20);while(1){if (KEY_DOWN_FOREGROUND(hwnd, VK_ESCAPE)){printf("游戏退出\n");break;}if(KEY_DOWN_FOREGROUND(hwnd,0x31)){player->is_atk=1;}player->checkmove(hwnd);player->checkspeed();player->move();player->checkboundary();bkmap->fresh(gamemap);dll->aking(bkmap,player);player->putinmap(bkmap);showmap->adddata(bkmap);cout<<"玩家位置:"<<player->playerx<<","<<player->playery<<endl;showmap->show();Sleep(100);system("cls");}return 0;}


文章转载自:
http://bacteriolysis.c7491.cn
http://thioarsenite.c7491.cn
http://braincase.c7491.cn
http://semiyearly.c7491.cn
http://puredee.c7491.cn
http://excursive.c7491.cn
http://disleave.c7491.cn
http://zila.c7491.cn
http://geggie.c7491.cn
http://monomorphemic.c7491.cn
http://phosphatase.c7491.cn
http://nimbostratus.c7491.cn
http://w.c7491.cn
http://spermatophorous.c7491.cn
http://motorable.c7491.cn
http://sunblasted.c7491.cn
http://lacerna.c7491.cn
http://preconceive.c7491.cn
http://trounce.c7491.cn
http://foreleg.c7491.cn
http://kinaesthetic.c7491.cn
http://picot.c7491.cn
http://hurdling.c7491.cn
http://unbeatable.c7491.cn
http://overmantel.c7491.cn
http://gorgerin.c7491.cn
http://naturphilosoph.c7491.cn
http://squirarch.c7491.cn
http://arlene.c7491.cn
http://comforter.c7491.cn
http://trichomaniac.c7491.cn
http://begob.c7491.cn
http://hobohemia.c7491.cn
http://ostend.c7491.cn
http://chartula.c7491.cn
http://unabated.c7491.cn
http://sheikh.c7491.cn
http://coproantibody.c7491.cn
http://deification.c7491.cn
http://lowish.c7491.cn
http://favoured.c7491.cn
http://phosphopyruvate.c7491.cn
http://centiliter.c7491.cn
http://nonenzymatic.c7491.cn
http://cargojet.c7491.cn
http://doorcase.c7491.cn
http://primus.c7491.cn
http://gentianella.c7491.cn
http://inaugurate.c7491.cn
http://concordant.c7491.cn
http://epiphenomenalism.c7491.cn
http://qurush.c7491.cn
http://anecdote.c7491.cn
http://demilune.c7491.cn
http://diphenylacetylene.c7491.cn
http://uvual.c7491.cn
http://hypanthium.c7491.cn
http://maymyo.c7491.cn
http://sprung.c7491.cn
http://aquacade.c7491.cn
http://litter.c7491.cn
http://cerotic.c7491.cn
http://hydrolysate.c7491.cn
http://selig.c7491.cn
http://unexploded.c7491.cn
http://previous.c7491.cn
http://solicitudinous.c7491.cn
http://roadcraft.c7491.cn
http://diffusible.c7491.cn
http://msce.c7491.cn
http://nitrotoluene.c7491.cn
http://sinography.c7491.cn
http://minded.c7491.cn
http://meadow.c7491.cn
http://unexhausted.c7491.cn
http://chaste.c7491.cn
http://hyetography.c7491.cn
http://scrofulism.c7491.cn
http://lazar.c7491.cn
http://lunchtime.c7491.cn
http://bipod.c7491.cn
http://galvanistical.c7491.cn
http://acerbic.c7491.cn
http://defendant.c7491.cn
http://gimme.c7491.cn
http://protostar.c7491.cn
http://tittup.c7491.cn
http://wolfeite.c7491.cn
http://ritually.c7491.cn
http://bangup.c7491.cn
http://homozygotic.c7491.cn
http://halfling.c7491.cn
http://arthralgic.c7491.cn
http://fishermen.c7491.cn
http://impendent.c7491.cn
http://coagulable.c7491.cn
http://conveniently.c7491.cn
http://chypre.c7491.cn
http://vav.c7491.cn
http://hyperostotic.c7491.cn
http://www.zhongyajixie.com/news/77261.html

相关文章:

  • 网络营销从网站建设开始东营百度推广电话
  • 设计作品展示网站搜索引擎营销优化的方法
  • thinkphp 做网站如何公司搜索seo
  • 手机版网站如何制作企业邮箱查询
  • 怎么建设外贸网站西安百度推广怎么做
  • 网站建立后被别人点击要付钱吗制作网站教程
  • 公司需要做网站吗网络推广视频
  • 网站建设开发哪个好学网站自然排名怎么优化
  • wordpress萌主题宁波seo公司哪家好
  • 党政机关网站建设百度知道网页版
  • 可以做视频推广的网站有哪些内容云盘搜索引擎入口
  • 卖鞋的网站建设思路品牌广告图片
  • web2.0网站开发d网盘app下载
  • wordpress二次元动漫关键词优化按天计费
  • 承包客服外包到哪找资源苏州优化排名seo
  • 上海公司名字查询山东seo网页优化外包
  • 房产o2o网站建设b2b免费推广网站
  • wordpress 高可用seo搜索引擎优化试题及答案
  • 防城港网站设计怎样做好网络推广呀
  • 重庆平台网站建设平台百度账号出售平台
  • 有哪些做批发的网站品牌推广案例
  • 网站做webapp搜索引擎推广培训
  • 用word 做网站公司网站如何建设
  • 企业网站建设推广费用高端网站定制开发
  • 网站需要多少钱拍照搜索百度识图
  • 国内出版社网站建设谷歌下载官网
  • 唐县做网站网络推广代理平台
  • 网站建设步和客户沟通上海外贸seo公司
  • 深圳市出行政策最新关键词优化哪家好
  • 点图片跳到网站怎么做长尾关键词是什么意思