既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
if (map[i][j].type > 0)
{
//int x = 256 + j \* 81;
//int y = 179 + i\*102+14;
int Zhiwutype = map[i][j].type - 1;
int index = map[i][j].frameIndex;
//putimagePNG(x, y, imgZhiwu[Zhiwutype][index]);
putimagePNG(map[i][j].x, map[i][j].y,imgZhiwu[Zhiwutype][index]);
}
}
}
//渲染拖动过程中的植物
if (curZhiwu)
{
IMAGE\* img = imgZhiwu[curZhiwu - 1][0];
putimagePNG(curX - img->getwidth()/2, curY - img->getheight()/2, img);
}
drawSunshines();//绘制阳光
char scoreText[8];
sprintf\_s(scoreText, sizeof(scoreText),"%d",sunshine);
outtextxy(276,67,scoreText);//输出阳光分数
drawZM();//渲染僵尸
//渲染阳光
int bulletMax = sizeof(bullets) / sizeof(bullets[0]);
for (int i = 0; i < bulletMax; i++)
{
if (bullets[i].used)
{
if (bullets[i].blast)
{
IMAGE\* img = &imgBallBlast[bullets[i].frameIndex];
putimagePNG(bullets[i].x, bullets[i].y, img);
}
else
{
putimagePNG(bullets[i].x, bullets[i].y, &imgBulletNormal);
}
}
}
EndBatchDraw();//结束双缓冲
}
void collectSunshine(ExMessage* msg)
{
int count = sizeof(balls) / sizeof(balls[0]);
int w = imgSunshineBall[0].getwidth();
int h = imgSunshineBall[0].getheight();
for (int i = 0; i < count; i++)
{
if (balls[i].used)
{
/*int x = balls[i].x;
int y = balls[i].y;*/
int x = balls[i].pCur.x;
int y = balls[i].pCur.y;
if (msg->x > x && msg->x<x + w && msg->y>y && msg->y < y + h)
{
balls[i].used = false;
balls[i].status = SUNSHINE_COLLECT;
sunshine += 25;
mciSendString("play res/sunshine.mp3",0,0,0);//加载音乐文件
//设置阳光球的偏移量
balls[i].p1 = balls[i].pCur;
balls[i].p4 = vector2(262, 0);
balls[i].t = 0;
float distance = dis(balls[i].p1 - balls[i].p4);
float off = 8.0;
balls[i].speed = 1.0/(distance/off);
}
}
}
}
void userClick()
{
ExMessage msg;//参数是消息类型
static int status = 0;
//如果消息有值则保存在peekmessage函数中,即为真
if (peekmessage(&msg))
{
if (msg.message == WM_LBUTTONDOWN)//WM_LBUTTONDOWN左键按下去的意思
{
if (msg.x > 338 && msg.x < 338 + 65*ZHI_WU_COUNT && msg.y < 96)//定义坐标判断点击的是否为植物
{
int index = (msg.x - 338) / 65;
status = 1;
curZhiwu = index + 1;
}
else
{
collectSunshine(&msg);
}
}
else if (msg.message == WM_MOUSEMOVE&&status==1)//WM_MOUSEMOVE鼠标移动
{
//记录当前位置
curX = msg.x;
curY = msg.y;
}
//鼠标抬动植物就种下去
else if (msg.message == WM_LBUTTONUP)
{
if (msg.x > 256 && msg.y > 179 && msg.y < 489)
{
int row = (msg.y - 179) / 102;
int col = (msg.x - 256) / 81;
if (map[row][col].type == 0)
{
map[row][col].type = curZhiwu;
map[row][col].frameIndex = 0;
//int x = 256 + j \* 81;
//int y = 179 + i\*102+14;
map[row][col].x = 256 + col \* 81;
map[row][col].y = 179 + row \* 102+14;
}
}
curZhiwu = 0;
status = 0;
}
}
}
void creatSunshine()
{
static int count = 0;
static int fre = 400;
count++;
if (count >= fre )
{
fre = 200 + rand() % 200;
count = 0;//满了计数器清0
//从阳光池中去一个可以使用的
int ballMax = sizeof(balls) / sizeof(balls[0]);
int i =