c语言问题 总是报错 请求大神帮忙能够这样 谢谢你帮忙

代码如下&证书文件是有效的
headers&=&{'Content-Type':&'application/json'}
response&=&requests.post(url,&data=data,&headers=headers,&cert=('./credoo_stg.crt','./credoo_stg.key'),verify=True)
Enter&PEM&pass&phrase:
Traceback&(most&recent&call&last):
&&File&"test.py",&line&31,&in&&module&
&&&&response&=&requests.post(url,&data=data,&headers=headers,&cert=('./credoo_stg.crt','./credoo_stg.key'),verify=True)
&&File&"/usr/local/lib/python2.7/site-packages/requests/api.py",&line&109,&in&post
&&&&return&request('post',&url,&data=data,&json=json,&**kwargs)
&&File&"/usr/local/lib/python2.7/site-packages/requests/api.py",&line&50,&in&request
&&&&response&=&session.request(method=method,&url=url,&**kwargs)
&&File&"/usr/local/lib/python2.7/site-packages/requests/sessions.py",&line&465,&in&request
&&&&resp&=&self.send(prep,&**send_kwargs)
&&File&"/usr/local/lib/python2.7/site-packages/requests/sessions.py",&line&573,&in&send
&&&&r&=&adapter.send(request,&**kwargs)
&&File&"/usr/local/lib/python2.7/site-packages/requests/adapters.py",&line&431,&in&send
&&&&raise&SSLError(e,&request=request)
requests.exceptions.SSLError:&[SSL:&UNKNOWN_PROTOCOL]&unknown&protocol&(_ssl.c:590)
回答: python用requests库给https发请求报ssl异常,请大神帮忙进来看下,谢谢!
1.&检查SSL版本&
2.&要保证底层的socket模块是支持ssl的编译模式,即编译时ssl选项的开关是开着的。
3.&端口错误,检查一下。
Q 上传一个文件到HTTP服务器,WinHttpSetOption(hTempRequest,&WINHTTP_OPTION_SEND_TIMEOUT,&&dwData,&dwSize)设置请求超时时间50s,但WinHttpSendRequest总还是在默认的30秒返回。(为了测试网络状况不好的情况,特意限制的程序的上传速度让其在超时之前无法上传成功)使用::WinHttpSetTimeouts却可以得到期待的结果。
WINHTTP_OPTION_CONNECT_TIMEOUT
WINHTTP_OPTION_RECEIVE_TIMEOUT
也设置一下看看能不能得到预期结果
这是文件,是读取和解压压缩文件的内容的,我这边做的软件需要使用里面的VPKFile
头文件和源文件在HLLib
里面有lib库,我添加库之后编译提示
添加为静态的话提示
而且也没法include里面的头文件,本人第一次使用lib库,不太懂
求大神帮帮忙
这种用法是错的……中间嵌入盘符,找不到路径的。
Q 我的需求是用密钥文件签名,用公钥文件验签。
python的代码我已经实现了,已经签名和验签成功。但是c版本的一直搞不定。
下面是python的代码
from&Crypto.PublicKey&import&RSA
from&Crypto.Hash&import&SHA
from&Crypto.Signature&import&PKCS1_v1_5&as&pk
import&base64
#rsa-sha1签名
def&sha1Sign(key,&data&=&None):
if&data&==&None:
return&None
privateKey=RSA.importKey(open(key,'r').read())
h=SHA.new(data)&
signer&=&pk.new(privateKey)&
signn=signer.sign(h)&
return&base64.b64encode(signn)&
请帮忙看下用c语言版本怎么实现,python的PKCS1_v1_5&对应crypto库的RSA_PKCS1_PADDING吧。
仅供参考:#pragma&comment(lib,&"crypt32.lib")
#pragma&comment(lib,&"advapi32.lib")
#define&_WIN32_WINNT&0x0400
#include&&stdio.h&
#include&&windows.h&
#include&&wincrypt.h&
#define&KEYLENGTH&&0x
void&HandleError(char&*s);
//--------------------------------------------------------------------
//&&These&additional&#define&statements&are&required.
#define&ENCRYPT_ALGORITHM&CALG_RC4
#define&ENCRYPT_BLOCK_SIZE&8
//&&&Declare&the&function&EncryptFile.&The&function&definition
//&&&follows&main.
BOOL&EncryptFile(
&&&&PCHAR&szSource,
&&&&PCHAR&szDestination,
&&&&PCHAR&szPassword);
//--------------------------------------------------------------------
//&&&Begin&main.
void&main(void)&{
&&&&CHAR&szSource[100];
&&&&CHAR&szDestination[100];
&&&&CHAR&szPassword[100];
&&&&printf("Encrypt&a&file.&\n\n");
&&&&printf("Enter&the&name&of&the&file&to&be&encrypted:&");
&&&&scanf("%s",szSource);
&&&&printf("Enter&the&name&of&the&output&file:&");
&&&&scanf("%s",szDestination);
&&&&printf("Enter&the&password:");
&&&&scanf("%s",szPassword);
&&&&//--------------------------------------------------------------------
&&&&//&Call&EncryptFile&to&do&the&actual&encryption.
&&&&if(EncryptFile(szSource,&szDestination,&szPassword))&{
&&&&&&&&printf("Encryption&of&the&file&%s&was&a&success.&\n",&szSource);
&&&&&&&&printf("The&encrypted&data&is&in&file&%s.\n",szDestination);
&&&&}&else&{
&&&&&&&&HandleError("Error&encrypting&file!");
}&//&End&of&main
//--------------------------------------------------------------------
//&&&Code&for&the&function&EncryptFile&called&by&main.
static&BOOL&EncryptFile(
&&&&PCHAR&szSource,
&&&&PCHAR&szDestination,
&&&&PCHAR&szPassword)
//--------------------------------------------------------------------
//&&&Parameters&passed&are:
//&&&&&szSource,&the&name&of&the&input,&a&plaintext&file.
//&&&&&szDestination,&the&name&of&the&output,&an&encrypted&file&to&be
//&&&&&&&&&created.
//&&&&&szPassword,&the&password.
&&&&//--------------------------------------------------------------------
&&&&//&&&Declare&and&initialize&local&variables.
&&&&FILE&*hS
&&&&FILE&*hD
&&&&HCRYPTPROV&hCryptP
&&&&HCRYPTKEY&hK
&&&&HCRYPTHASH&hH
&&&&PBYTE&pbB
&&&&DWORD&dwBlockL
&&&&DWORD&dwBufferL
&&&&DWORD&dwC
&&&&//--------------------------------------------------------------------
&&&&//&Open&source&file.
&&&&if(hSource&=&fopen(szSource,"rb"))&{
&&&&&&&&printf("The&source&plaintext&file,&%s,&is&open.&\n",&szSource);
&&&&}&else&{
&&&&&&&&HandleError("Error&opening&source&plaintext&file!");
&&&&//--------------------------------------------------------------------
&&&&//&Open&destination&file.
&&&&if(hDestination&=&fopen(szDestination,"wb"))&{
&&&&&&&&printf("Destination&file&%s&is&open.&\n",&szDestination);
&&&&}&else&{
&&&&&&&&HandleError("Error&opening&destination&ciphertext&file!");
&&&&//以下获得一个CSP句柄
&&&&if(CryptAcquireContext(
&&&&&&&&&&&&&&&&&hCryptProv,
&&&&&&&&&&&&&&&&NULL,&&&&&&&&&&&&&&&//NULL表示使用默认密钥容器,默认密钥容器名
&&&&&&&&&&&&&&&&//为用户登陆名
&&&&&&&&&&&&&&&&NULL,
&&&&&&&&&&&&&&&&PROV_RSA_FULL,
&&&&&&&&&&&&&&&&0))&{
&&&&&&&&printf("A&cryptographic&provider&has&been&acquired.&\n");
&&&&}&else&{
&&&&&&&&if(CryptAcquireContext(
&&&&&&&&&&&&&&&&&&&&&hCryptProv,
&&&&&&&&&&&&&&&&&&&&NULL,
&&&&&&&&&&&&&&&&&&&&NULL,
&&&&&&&&&&&&&&&&&&&&PROV_RSA_FULL,
&&&&&&&&&&&&&&&&&&&&CRYPT_NEWKEYSET))//创建密钥容器
&&&&&&&&&&&&//创建密钥容器成功,并得到CSP句柄
&&&&&&&&&&&&printf("A&new&key&container&has&been&created.\n");
&&&&&&&&}&else&{
&&&&&&&&&&&&HandleError("Could&not&create&a&new&key&container.\n");
&&&&//--------------------------------------------------------------------
&&&&//&创建一个会话密钥(session&key)
&&&&//&会话密钥也叫对称密钥,用于对称加密算法。
&&&&//&(注:&一个Session是指从调用函数CryptAcquireContext到调用函数
&&&&//&&&CryptReleaseContext&期间的阶段。会话密钥只能存在于一个会话过程)
&&&&//--------------------------------------------------------------------
&&&&//&Create&a&hash&object.
&&&&if(CryptCreateHash(
&&&&&&&&&&&&&&&&hCryptProv,
&&&&&&&&&&&&&&&&CALG_MD5,
&&&&&&&&&&&&&&&&0,
&&&&&&&&&&&&&&&&0,
&&&&&&&&&&&&&&&&&hHash))&{
&&&&&&&&printf("A&hash&object&has&been&created.&\n");
&&&&}&else&{
&&&&&&&&HandleError("Error&during&CryptCreateHash!\n");
&&&&//--------------------------------------------------------------------
&&&&//&用输入的密码产生一个散列
&&&&if(CryptHashData(
&&&&&&&&&&&&&&&&hHash,
&&&&&&&&&&&&&&&&(BYTE&*)szPassword,
&&&&&&&&&&&&&&&&strlen(szPassword),
&&&&&&&&&&&&&&&&0))&{
&&&&&&&&printf("The&password&has&been&added&to&the&hash.&\n");
&&&&}&else&{
&&&&&&&&HandleError("Error&during&CryptHashData.&\n");
&&&&//--------------------------------------------------------------------
&&&&//&通过散列生成会话密钥
&&&&if(CryptDeriveKey(
&&&&&&&&&&&&&&&&hCryptProv,
&&&&&&&&&&&&&&&&ENCRYPT_ALGORITHM,
&&&&&&&&&&&&&&&&hHash,
&&&&&&&&&&&&&&&&KEYLENGTH,
&&&&&&&&&&&&&&&&&hKey))&{
&&&&&&&&printf("An&encryption&key&is&derived&from&the&password&hash.&\n");
&&&&}&else&{
&&&&&&&&HandleError("Error&during&CryptDeriveKey!\n");
&&&&//--------------------------------------------------------------------
&&&&//&Destroy&the&hash&object.
&&&&CryptDestroyHash(hHash);
&&&&hHash&=&NULL;
&&&&//--------------------------------------------------------------------
&&&&//&&The&session&key&is&now&ready.
&&&&//--------------------------------------------------------------------
&&&&//&因为加密算法是按ENCRYPT_BLOCK_SIZE&大小的块加密的,所以被加密的
&&&&//&数据长度必须是ENCRYPT_BLOCK_SIZE&的整数倍。下面计算一次加密的
&&&&//&数据长度。
&&&&dwBlockLen&=&1000&-&1000&%&ENCRYPT_BLOCK_SIZE;
&&&&//--------------------------------------------------------------------
&&&&//&Determine&the&block&size.&If&a&block&cipher&is&used,
&&&&//&it&must&have&room&for&an&extra&block.
&&&&if(ENCRYPT_BLOCK_SIZE&&&1)
&&&&&&&&dwBufferLen&=&dwBlockLen&+&ENCRYPT_BLOCK_SIZE;
&&&&&&&&dwBufferLen&=&dwBlockL
&&&&//--------------------------------------------------------------------
&&&&//&Allocate&memory.
&&&&if(pbBuffer&=&(BYTE&*)malloc(dwBufferLen))&{
&&&&&&&&printf("Memory&has&been&allocated&for&the&buffer.&\n");
&&&&}&else&{
&&&&&&&&HandleError("Out&of&memory.&\n");
&&&&//--------------------------------------------------------------------
&&&&//&In&a&do&loop,&encrypt&the&source&file&and&write&to&the&destination&file.
&&&&&&&&//--------------------------------------------------------------------
&&&&&&&&//&Read&up&to&dwBlockLen&bytes&from&the&source&file.
&&&&&&&&dwCount&=&fread(pbBuffer,&1,&dwBlockLen,&hSource);
&&&&&&&&if(ferror(hSource))&{
&&&&&&&&&&&&HandleError("Error&reading&plaintext!\n");
&&&&&&&&//--------------------------------------------------------------------
&&&&&&&&//&加密数据
&&&&&&&&if(!CryptEncrypt(
&&&&&&&&&&&&&&&&&&&&hKey,&&&&&&&&&&&//密钥
&&&&&&&&&&&&&&&&&&&&0,&&&&&&&&&&&&&&//如果数据同时进行散列和加密,这里传入一个
&&&&&&&&&&&&&&&&&&&&//散列对象
&&&&&&&&&&&&&&&&&&&&feof(hSource),&&//如果是最后一个被加密的块,输入TRUE.如果不是输.
&&&&&&&&&&&&&&&&&&&&//入FALSE这里通过判断是否到文件尾来决定是否为
&&&&&&&&&&&&&&&&&&&&//最后一块。
&&&&&&&&&&&&&&&&&&&&0,&&&&&&&&&&&&&&//保留
&&&&&&&&&&&&&&&&&&&&pbBuffer,&&&&&&&//输入被加密数据,输出加密后的数据
&&&&&&&&&&&&&&&&&&&&&dwCount,&&&&&&&//输入被加密数据实际长度,输出加密后数据长度
&&&&&&&&&&&&&&&&&&&&dwBufferLen))&&&//pbBuffer的大小。
&&&&&&&&&&&&HandleError("Error&during&CryptEncrypt.&\n");
&&&&&&&&//--------------------------------------------------------------------
&&&&&&&&//&Write&data&to&the&destination&file.
&&&&&&&&fwrite(pbBuffer,&1,&dwCount,&hDestination);
&&&&&&&&if(ferror(hDestination))&{
&&&&&&&&&&&&HandleError("Error&writing&ciphertext.");
&&&&}&while(!feof(hSource));
&&&&//--------------------------------------------------------------------
&&&&//&&End&the&do&loop&when&the&last&block&of&the&source&file&has&been
&&&&//&&read,&encrypted,&and&written&to&the&destination&file.
&&&&//--------------------------------------------------------------------
&&&&//&Close&files.
&&&&if(hSource)
&&&&&&&&fclose(hSource);
&&&&if(hDestination)
&&&&&&&&fclose(hDestination);
&&&&//--------------------------------------------------------------------
&&&&//&Free&memory.
&&&&if(pbBuffer)
&&&&&&&&free(pbBuffer);
&&&&//--------------------------------------------------------------------
&&&&//&Destroy&session&key.
&&&&if(hKey)
&&&&&&&&CryptDestroyKey(hKey);
&&&&//--------------------------------------------------------------------
&&&&//&Destroy&hash&object.
&&&&if(hHash)
&&&&&&&&CryptDestroyHash(hHash);
&&&&//--------------------------------------------------------------------
&&&&//&Release&provider&handle.
&&&&if(hCryptProv)
&&&&&&&&CryptReleaseContext(hCryptProv,&0);
&&&&return(TRUE);
}&//&End&of&Encryptfile
//--------------------------------------------------------------------
//&&This&example&uses&the&function&HandleError,&a&simple&error
//&&handling&function,&to&print&an&error&message&to&the&standard&error
//&&(stderr)&file&and&exit&the&program.
//&&For&most&applications,&replace&this&function&with&one
//&&that&does&more&extensive&error&reporting.
void&HandleError(char&*s)&{
&&&&fprintf(stderr,"An&error&occurred&in&running&the&program.&\n");
&&&&fprintf(stderr,"%s\n",s);
&&&&fprintf(stderr,&"Error&number&%x.\n",&GetLastError());
&&&&fprintf(stderr,&"Program&terminating.&\n");
&&&&exit(1);
}&//&End&of&HandleError
Q 现在有100多个文件,里面有很多个.c和.h文件,请问如何将他们编译成一个.so文件,且能让我的另外一个程序能够调用里面的函数?我看了网上的方法,都是说一两个.c文件的编译成.so文件的,关键是我现在有很多文件,虽然我成功的把他们编译成了一个.so,但是我在编译另外一个程序里面加上了链接这个.so的选项(-l&xx.so?),编译通不过,说的是我程序用的函数全部没有声明,这些函数在各个.h文件里声明,难道我要把这么多头文件include吗?有没有方法不这么做,一个so搞定,我看人家的项目是可以的,但是不知道怎么做,求高手帮忙.
声明还是要include的,你可以写一个头文件比如A.h,在那个A.h头文件里面包含其他的头文件,这样你就只需要包含你这个A.h就可以了,很多库就是这样做的。
Q &System.Net.Mail.MailMessage&msg&=&new&System.Net.Mail.MailMessage();
&&&&&&&&&&&&msg.To.Add(EmployManage.GetUserUserNoByName(txtApp.Text.Trim()).Rows[0]["Email"].ToString());
&&&&&&&&&&&&msg.From&=&new&MailAddress(CurrentUser.Email,&toDoList.EmpName,&System.Text.Encoding.UTF8);
&&&&&&&&&&&&/*&上面3个参数分别是发件人地址,发件人姓名,编码*/
&&&&&&&&&&&&msg.Subject&=&"申请请假";//邮件标题&&&
&&&&&&&&&&&&msg.SubjectEncoding&=&System.Text.Encoding.UTF8;//邮件标题编码&&&
&&&&&&&&&&&&msg.Body&=toDoList.ToString();//邮件内容&&&
&&&&&&&&&&&&msg.BodyEncoding&=&System.Text.Encoding.UTF8;//邮件内容编码&&&
&&&&&&&&&&&&msg.IsBodyHtml&=&//是否是HTML邮件&&&
&&&&&&&&&&&&msg.Priority&=&MailPriority.H//邮件优先级&&&
&&&&&&&&&&&&SmtpClient&client&=&new&SmtpClient();
&&&&&&&&&&&&client.Credentials&=&new&System.Net.NetworkCredential(CurrentUser.Email,txtpassword.Text.ToString().Trim());
&&&&&&&&&&&&client.Port&=&25;//SMTP服务器地址&587/465
&&&&&&&&&&&&client.Host&=&"smtp.";//smtp服务器地址
&&&&&&&&&&&&client.EnableSsl&=&//经过ssl加密&&&
&&&&&&&&&&&&client.DeliveryMethod&=&SmtpDeliveryMethod.N
&&&&&&&&&&&&object&userState&=&
&&&&&&&&&&&&try
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&client.Send(msg);
&&&&&&&&&&&&&&&&Console.Write("发送成功");
&&&&&&&&&&&&}
&&&&&&&&&&&&catch&(System.Net.Mail.SmtpException&ex)
&&&&&&&&&&&&{
&&&&&&&&&&&&&&&&Console.Write("发送失败");
&&&&&&&&&&&&}
一般端口为Port&=&25的&不用SSL加密(特殊情况除外)
设置client.EnableSsl&=&
还有就是发送不出去,断点&这句话&&&client.Send(msg);&看返回值啊&或者看抛出的异常
Q private&String&genKey(String&key1,&String&key2)&{
int&key&=&Long.valueOf(key1,&16).intValue();
key&^=&0xA55AA5A5;
return&key2&+&Long.toHexString(key);
请各位帮忙看看?
def&genKey(key1,&key2):&&#&private&String&genKey(String&key1,&String&key2)&{
&&&&key&=&int(key1,&16)&&#&&&int&key&=&Long.valueOf(key1,&16).intValue();
&&&&key&^=&0xA55AA5A5&&&&#&&&key&^=&0xA55AA5A5;
&&&&return&key2&+&hex(key)&#&&&return&key2&+&Long.toHexString(key);
Q 我本地IIS链接服务器的数据库能够正常链接很运行,但是我把网站上传到服务空间就不能链接数据库。而提示:“provider:&TCP&Provider,&error:&0&-&由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。”
求各路大神帮忙解决,是什么原因导致的?
版主说得对啊
Q 最近开发需要模拟访问某网站,
需要使用Cookie
找不到合适的库,请大神们推荐~
CHttpFile 可以吗
CWebbrowser 
CHttpFile提供向HTTP服务器中请求和读取的功能。&  
如果Internet会话要从一个HTTP服务器中读取数据,则必须构造一个CHttpFile实例。&  
#include&&afxinet.h&&
Q 一日无聊,想写个俄罗斯方块,突然一想既然无聊,何不放在圆中玩俄罗斯,于是就有了这个俄罗斯扇块。
只是初学javascript和HTML5,代码质量就呵呵了,两月以后来看总觉实在太烂,于是想请大神们指教指教。
各位可以拿着代码去试试,纯javascript+HTML5,支持触屏,操作很简单就是键盘的上下左右。
代码太长,做三次发。
&!DOCTYPE&html&PUBLIC&"-//W3C//DTD&XHTML&1.0&Transitional//EN"&"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&
&html&xmlns="http://www.w3.org/1999/xhtml"&
&meta&charset="gb2312"&
&title&俄罗斯扇块&/title&
&body&style="margin:0padding:0"&
&meta&name="viewport"&content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"&/&
&canvas&id="c"&&/canvas&
var&c=document.getElementById("c");
var&ctx=c.getContext("2d");
var&screenwidth=document.width,screenheight=document.
c.width=document.
c.height=document.
var&r=~~(Math.min(screenwidth,screenheight)/2);
var&rot=0.0,app=0,approaching=
var&grid=false,inverse=true,shadow=
var&keys=[];
var&frame=0,mode=0,str="";
var&HOME=0,GAME=1,CONTROLS=2,SETTINGS=3,GAMEOVER=4,DEMO=5;
var&squares=[];
var&score=0,times=0;
var&int=40;
var&touchxsec=6,touchysec=8;
var&jcur=0,typecur=0,poscur=0,typenext=0,posnext=0;
var&button=[];
var&shapes=
[&[-1,0],[0,0],[1,0],[2,0]&],
[&[0,2],[0,1],[0,0],[0,-1]&],
[&[-1,0],[0,0],[1,0],[2,0]&],
[&[0,2],[0,1],[0,0],[0,-1]&],
[&[0,0],[0,-1],[-1,0],[-1,-1]&],
[&[0,0],[0,-1],[-1,0],[-1,-1]&],
[&[0,0],[0,-1],[-1,0],[-1,-1]&],
[&[0,0],[0,-1],[-1,0],[-1,-1]&],
[&[-1,0],[0,0],[0,1],[1,0]&],
[&[0,1],[0,0],[0,-1],[1,0]&],
[&[-1,0],[0,0],[0,-1],[1,0]&],
[&[0,1],[0,0],[0,-1],[-1,0]&],
[&[-1,1],[-1,0],[0,0],[1,0]&],
[&[0,1],[0,0],[0,-1],[1,1]&],
[&[-1,0],[0,0],[1,0],[1,-1]&],
[&[0,1],[0,0],[0,-1],[-1,-1]&],
[&[1,1],[1,0],[0,0],[-1,0]&],
[&[0,1],[0,0],[0,-1],[1,-1]&],
[&[1,0],[0,0],[-1,0],[-1,-1]&],
[&[0,1],[0,0],[0,-1],[-1,1]&],
[&[0,-1],[0,0],[1,0],[1,1]&],
[&[-1,0],[0,0],[0,-1],[1,-1]&],
[&[0,-1],[0,0],[1,0],[1,1]&],
[&[-1,0],[0,0],[0,-1],[1,-1]&],
[&[0,-1],[0,0],[-1,0],[-1,1]&],
[&[1,0],[0,0],[0,-1],[-1,-1]&],
[&[0,-1],[0,0],[-1,0],[-1,1]&],
[&[1,0],[0,0],[0,-1],[-1,-1]&]
var&color=["#000","#FF0000","#00FF00","#0000FF","#FFFF00","FF00FF","#00FFFF"];
var&imgbg=new&Image();
imgbg.src="background.jpg";
var&buttons=function()
var&xp=0.0,yp=0.0,wp=0.0,hp=0.0;
var&border=true,bordercolor="#FFFFFF";
var&text="",txp=0.0,typ=0.0,fzp=0.0,fc="#FFFFFF";
this.setpos=function(sxp,syp,swp,shp,sborder,sbordercolor)
if(sborder!==undefined){border=}
if(sbordercolor!==undefined){bordercolor=}
this.settext=function(stext,stxp,styp,sfzp,sfc)
if(stxp!==undefined){txp=}
if(styp!==undefined){typ=}
if(sfzp!==undefined){fzp=}
if(sfc!==undefined){fc=}
this.clickevent=function(){}
this.onclick=function(x,y)
if(x&r*xp&&x&r*(xp+wp)&&y&r*yp&&y&r*(yp+hp))
this.clickevent();
this.draw=function()
ctx.fillStyle=
ctx.strokeStyle=
if(border){ctx.strokeRect(r*xp,r*yp,r*wp,r*hp);}
ctx.font=~~(fzp*r)+"px&Comic&Sans&MS";
ctx.fillText(text,r*(txp+xp),r*(typ+yp));
//loadhomepagebuttons
function&loadhomepagebuttons()
button=[];
button[0]=new&buttons();
with(button[0])
setpos(0.7,0.6,0.6,0.2,false);
settext("START",0.04,0.15,0.15);
clickevent=function(){newgame();}
button[1]=new&buttons();
with(button[1])
setpos(0.7,0.85,0.6,0.2,false);
settext("Controls",0.0,0.15,0.15);
clickevent=function(){loadcontrolsbuttons();mode=CONTROLS;}
button[2]=new&buttons();
with(button[2])
setpos(0.7,1.1,0.6,0.2,false);
settext("Settings",0.0,0.15,0.15);
clickevent=function(){loadsettingsbuttons();mode=SETTINGS;}
//loadcontrolsbuttons
function&loadcontrolsbuttons()
button=[];
button[0]=new&buttons();
with(button[0])
setpos(0.8,1.45,0.4,0.1);
settext("BACK",0.1,0.08,0.08);
clickevent=function(){loadhomepagebuttons();mode=HOME;}
//loadgameoverbuttons
function&loadgameoverbuttons()
button=[];
button[0]=new&buttons();
with(button[0])
setpos(0.4,1.4,0.4,0.1,true,"#000");
settext("MENU",0.08,0.08,0.08,"#000");
clickevent=function(){loadhomepagebuttons();mode=HOME;}
button[1]=new&buttons();
with(button[1])
setpos(1.0,1.4,0.4,0.1,true,"#000");
settext("RESTART",0.02,0.08,0.08,"#000");
clickevent=function(){newgame();}
//loaddemobuttons
function&loaddemobuttons()
button=[];
button[0]=new&buttons();
with(button[0])
setpos(0.8,1.6,0.4,0.1);
settext("BACK",0.1,0.08,0.08);
clickevent=function(){loadhomepagebuttons();mode=HOME;}
//loadsettingsbuttons
function&loadsettingsbuttons()
button=[];
button[0]=new&buttons();
with(button[0])
setpos(1.3,0.7,0.3,0.1);
if(grid){settext("ON",0.08,0.08,0.08);}else{settext("OFF",0.08,0.08,0.08);}
clickevent=function(){
if(grid){settext("ON");}else{settext("OFF");}
button[1]=new&buttons();
with(button[1])
setpos(1.3,0.9,0.3,0.1);
if(shadow){settext("ON",0.08,0.08,0.08);}else{settext("OFF",0.08,0.08,0.08);}
clickevent=function(){
if(shadow){settext("ON");}else{settext("OFF");}
button[2]=new&buttons();
with(button[2])
setpos(1.3,1.1,0.3,0.1);
if(inverse){settext("ON",0.08,0.08,0.08);}else{settext("OFF",0.08,0.08,0.08);}
clickevent=function(){
if(inverse){settext("ON");}else{settext("OFF");}
button[3]=new&buttons();
with(button[3])
setpos(0.8,1.5,0.4,0.1);
settext("BACK",0.1,0.08,0.08);
clickevent=function(){loadhomepagebuttons();mode=HOME;}
var&clickx=0,clicky=0,clickevent=
function&mousedown(e)
function&mouseup(e)
clickevent=
clickx=e.pageX;
clicky=e.pageY;
var&touchstartx=0,touchstarty=0,touch=false,multitouch=
function&touchmove(e)
var&x=e.targetTouches[0].pageX,y=e.targetTouches[0].pageY;
e.preventDefault();
clickx=e.targetTouches[0].pageX;
clicky=e.targetTouches[0].pageY;
if(multitouch)
if(x-touchstartx&c.width/touchxsec)
touchstartx=x;
touchstarty=y;
}else&if(touchstartx-x&c.width/touchxsec)
touchstartx=x;
touchstarty=y;
if((y-touchstarty&c.height/touchysec)&&touch)
touch=false
touchstartx=x;
touchstarty=y;
}else&if(touchstarty-y&c.height/touchysec)
touchstartx=x;
touchstarty=y;
function&touchend(e)
multitouch=
clickevent=
function&touchstart(e)
e.preventDefault();
touchstartx=e.targetTouches[0].pageX;
touchstarty=e.targetTouches[0].pageY;
clickx=e.targetTouches[0].pageX;
clicky=e.targetTouches[0].pageY;
if(e.targetTouches.length&1){multitouch=}else{multitouch=}
//clearevents
function&clearevents()
clickevent=
touchstartx=0;
touchstarty=0;
multitouch=
//drawfalling
function&drawfalling(j,type,pos,c)
drawsquare(12+shapes[4*type+pos%4][0][0],j+shapes[4*type+pos%4][0][1],c,0);
drawsquare(12+shapes[4*type+pos%4][1][0],j+shapes[4*type+pos%4][1][1],c,0);
drawsquare(12+shapes[4*type+pos%4][2][0],j+shapes[4*type+pos%4][2][1],c,0);
drawsquare(12+shapes[4*type+pos%4][3][0],j+shapes[4*type+pos%4][3][1],c,0);
function&clear()
var&i=0,j=0,ul=0;
var&blankline=
for(j=1;j&16;j++)
for(i=0;i&16;i++)
if(squares[i][j]==""){}
for(;j&16;j++)
for(i=0;i&16;i++)
if(squares[i][j+1]!="")
blankline=
squares[i][j]=squares[i][j+1];
if(blankline){}
blankline=
for(i=0;i&16;i++){squares[i][j]="";}
return&clear()+1;
//fastsettle
function&fastsettle(type,pos)
var&i=-1,j=-1,sj=-1,si=-1;
for(var&s=0;s&4;s++)
i=(28+shapes[4*type+pos%4][s][0]-app%16)%16;
for(j=15;j&0;j--)
if(squares[i][j]!=""){}
if(j-shapes[4*type+pos%4][s][1]&sj)
sj=j-shapes[4*type+pos%4][s][1];
si=i-shapes[4*type+pos%4][s][0];
squares[(16+si+shapes[4*type+pos%4][0][0])%16][sj+shapes[4*type+pos%4][0][1]]=color[type];
squares[(16+si+shapes[4*type+pos%4][1][0])%16][sj+shapes[4*type+pos%4][1][1]]=color[type];
squares[(16+si+shapes[4*type+pos%4][2][0])%16][sj+shapes[4*type+pos%4][2][1]]=color[type];
squares[(16+si+shapes[4*type+pos%4][3][0])%16][sj+shapes[4*type+pos%4][3][1]]=color[type];
generatefalling();
i=clear();
times+=i&0;
score+=i*(i+1)/2;
function&settle(j,type,pos)
if(squares[(28+shapes[4*type+pos%4][0][0]-app%16)%16][j+shapes[4*type+pos%4][0][1]-1]!=""||
squares[(28+shapes[4*type+pos%4][1][0]-app%16)%16][j+shapes[4*type+pos%4][1][1]-1]!=""||
squares[(28+shapes[4*type+pos%4][2][0]-app%16)%16][j+shapes[4*type+pos%4][2][1]-1]!=""||
squares[(28+shapes[4*type+pos%4][3][0]-app%16)%16][j+shapes[4*type+pos%4][3][1]-1]!="")
squares[(28+shapes[4*type+pos%4][0][0]-app%16)%16][j+shapes[4*type+pos%4][0][1]]=color[type];
squares[(28+shapes[4*type+pos%4][1][0]-app%16)%16][j+shapes[4*type+pos%4][1][1]]=color[type];
squares[(28+shapes[4*type+pos%4][2][0]-app%16)%16][j+shapes[4*type+pos%4][2][1]]=color[type];
squares[(28+shapes[4*type+pos%4][3][0]-app%16)%16][j+shapes[4*type+pos%4][3][1]]=color[type];
generatefalling();
i=clear();
times+=i&0;
score+=i*(i+1)/2;
楼主的代码活该不兼容&
一点都不规范}

我要回帖

更多关于 谢谢你的帮忙 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信