////////////////comet snake////////////////////////////////////
////////////////////////////////////////////////////////
//Compilator :Microsoft Visual C++
//
//Created by :Dani (Indonesia)
//My Email :dani_marchitect@yahoo.co.id
//My Graduate is Architech
//
/////This is still practice program for me/////////
/////so, many bugs are maybe found////////////////
///////////////////////////////////////////////////////
#include<windows.h>
#include<stdio.h>
#include<time.h>
#include<math.h>
struct tm *local(){
time_t t;
t = time(NULL);
return localtime(&t);
}
const char *ClsName = "BitmapLoading";
const char *WndName = "Easy bitmaploading!";
MSG Msg;
HWND hWnd;
WNDCLASSEX WndClsEx;
HINSTANCE hInstance;
int main(void)
{
GetSystemMenu(GetForegroundWindow(),1);
ShowWindow(GetForegroundWindow(),1);
int D=100;
int m,n;
MoveWindow(GetForegroundWindow(),0,0,0,0,1);
MessageBox(GetForegroundWindow(), "To close the screen running, you can move the cursor on the program taskbar. Right click & then click close ","Users Guide - lonely night rain",MB_ICONASTERISK);
RegisterClassEx(&WndClsEx);
// Create the window object
hWnd = CreateWindow(ClsName,
WndName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
GetForegroundWindow(),
CreatePopupMenu(),
hInstance,
NULL);
HDC hdc=GetDC(hWnd);
for(m=0;m<=(local()->tm_hour*5)+local()->tm_min;m++)rand();//Random based on time
char *Label=" ScreenMove.SoftEng2010 - Copyright 2020 ";
int a[35],b[35],c[35],d[35],e=0;
for(n=1;n<=21;n++){
a[n]=(10+n)*n;
b[n]=(10+n)*n;
c[n]=1,d[n]=1;
}
do{
for(n=1;n<=21;n++){
if(a[n]+(6+n+n)<=740 && a[n]>=0 && c[n]==1)a[n]++;
else{ a[n]--;c[n]=0; }
if(a[n]<=0)c[n]=1;
if(b[n]+(6+n+n)<=1000 && b[n]>=0 && d[n]==1)b[n]++;
else{ b[n]--;d[n]=0; }
if(b[n]<=0)d[n]=1;
e++;
if(e==4)e=0;
RoundRect(hdc,b[n]+(2+n+n)+e,a[n]+(2+n+n)+e,b[n],a[n],b[n],a[n]);
TextOut(hdc,360,10,Label,43);//TEXT
}
for(m=0;m<=D*4;m++)Rectangle(hdc,1300,0,1350,50);
for(n=100;n>=0;n--)LineTo(hdc,rand()%1100,rand()%740);
SetTextColor(hdc,rand());
}while(1);
return 0;
}
答案 0 :(得分:2)
您可能想要进行错误处理 - 检查您正在调用的各种win32 apis的返回值。像CreateWindow这样的函数可能会失败。
另外(主观的个人意见),考虑写作
if(b[n]<=0)
d[n]=1;
而不是
if(b[n]<=0)d[n]=1;
并且,使用标志而不是替换它们的值。例如考虑写作:
ShowWindow(GetForegroundWindow(),SW_SHOWNORMAL);
而不是
ShowWindow(GetForegroundWindow(),1);
和更好的变量名称。
int D = 100;
什么是D?理想情况下,我应该通过查看名称来弄清楚变量代表什么。
最后,在整个代码中一致地缩进。
答案 1 :(得分:0)
我的观点:这看起来很棒! :)虽然,据我所知,这仍然是你的练习计划。