1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| #include<easyx.h> #include<cstdio> #include<iostream> using namespace std; int main() { initgraph(400, 260,0); IMAGE picture1,picture2; ExMessage msg; int score = 0; char score_c[10] = {'0'}; loadimage(&picture1, "0.jpg", 400, 260); loadimage(&picture2, "0.jpg", 380, 240); putimage(0, 0, &picture1); BeginBatchDraw(); settextstyle(20, 0, "楷体"); settextcolor(WHITE); setbkmode(TRANSPARENT); outtextxy(320, 0, _T("功德:")); outtextxy(370, 0, _T(score_c)); while (true) { FlushBatchDraw(); msg = getmessage(EX_MOUSE); if (msg.message == WM_LBUTTONDOWN) { cleardevice(); putimage(10, 10, &picture2); outtextxy(10, 0, _T("功德+1")); score++; sprintf_s(score_c, "%d", score); } else if (msg.message == WM_LBUTTONUP) { cleardevice(); putimage(0, 0, &picture1); } outtextxy(320, 0, _T("功德:")); outtextxy(370, 0, score_c); } getmessage(EX_CHAR); EndBatchDraw(); closegraph(); return 0; }
|