Home > Back-end >  Novice [turned] small programs written in easyX graphics library caton runtime
Novice [turned] small programs written in easyX graphics library caton runtime

Time:02-11

As title, their learning c + + and easyX recently, write a lot of small procedures, want to try to use the c + + and similar flappybird easyX write procedures,
And immediately set out to write a proof of concept of small programs, namely only flappybird birds move up and down and birds shows part of the,

Results after the program written, found that the run time will be caton, the card is random, time and caton time are random, the frequency is very random,
Almost immediately their online search solution, tried to change the solution configuration to release, but there is no use to search the along while, screening of trying asm, trying to find the causes of caton, also can not find......

Hope to have a great god see, still hope light spray,

 
#include
#include

using namespace std;

Void IMAGEdsp (int x, int y, LPCSTR IMAGEy, LPCSTR IMAGE1)//picture shows function
{
IMAGE img.
Loadimage (& amp; Img, _T (IMAGEy));
Putimage (x, y, & amp; Img, SRCAND);
Loadimage (& amp; Img, _T (IMAGE1));
Putimage (x, y, & amp; Img, SRCPAINT);
}

Void catup1 (int x, int y) {//three convenient image the function called
IMAGEdsp (x, y, "E: \ \ \ \ c + + NotPaper \ \ pictures material \ \ catup1Y BMP", "E: \ \ \ \ c + + NotPaper \ \ pictures material \ \ catup1 BMP");
}

Void catup2 (int x, int y) {
IMAGEdsp (x, y, "E: \ \ \ \ c + + NotPaper \ \ pictures material \ \ catup2Y BMP", "E: \ \ \ \ c + + NotPaper \ \ pictures material \ \ catup2 BMP");
}

Void catdown (int x, int y) {
IMAGEdsp (x, y, "E: \ \ \ \ c + + NotPaper \ \ pictures material \ \ catdownY BMP", "E: \ \ \ \ c + + NotPaper \ \ pictures material \ \ catdown BMP");
}

Int main ()
{
Int X=270, Y=150;//X, Y is the coordinates of the picture
Double dY=150.000000;//dY the same image coordinates, but only used to calculate the
Double aY;//used to convert
A double V=0.000;//move speed, positive upward

Initgraph (640, 480);
Setbkcolor (WHITE);
Cleardevice ();

Clock_t delay;//set delay
Double the SEC=0.05;
Delay=the SEC * CLOCKS_PER_SEC;
Clock_t start=clock ();

Bool hit=false;//used to test
the mouse,MOUSEMSG ms;

While (Y & lt; 420)
{
Clock_t start=clock ();
V -=200 * SEC;//speed, coordinate operations
DY -=V * (SEC);

If (hit) V=200;//click and give up speed
Hit=false;
AY=Y;

If (dY & gt; AY + 1=| | dY & lt; AY of=1) {//only when the mobile is greater than 1 pixel to the drawing
BeginBatchDraw ();
Y=dY;
Cleardevice ();
If (V & gt;=0)
{
If (V & gt;=120) catup1 (X, Y);
The else
Catup2 (X, Y);
}
If (V & lt; 0) catdown (X, Y);
EndBatchDraw ();
}
While (clock () - start & lt; Delay) {//delay to detect where the mouse
Ms=GetMouseMsg ();
If (Ms. UMsg==WM_LBUTTONDOWN) hit=true;
If (Ms. UMsg==WM_RBUTTONDOWN) goto the end;
}
}
End: closegraph ();
}

  • Related