Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Updates objects
- VOID Updater()
- {
- // Update the shots
- // Update shots2
- else if(iShots==1)
- {
- for(long index=0; index < (long)shots2.vshots.size(); ++index)
- {
- shots2.vshots[index].y-=2;
- shots2.vshots[index].x-=2;
- // Delete shots2
- if(shots2.vshots[index].y<-11||shots2.vshots[index].x<-11)
- {
- shots2.vshots.erase(shots2.vshots.begin()+index);
- }
- }
- for(long index=0; index < (long)shots2.v2shots.size(); ++index)
- {
- shots2.v2shots[index].y-=2;
- shots2.v2shots[index].x+=2;
- // Delete shots2
- if(shots2.v2shots[index].y<-11||shots2.v2shots[index].x>236)
- {
- shots2.v2shots.erase(shots2.v2shots.begin()+index);
- }
- }
- }
- // Update bounce
- if(bounce.aBounce==0)
- {
- if(bounce.vBounce[0].x<250)
- {
- bounce.vBounce[0].x+=2;
- bounce.vBounce[0].y+=2;
- }
- else{ bounce.aBounce=1; }
- }
- // Update New shots
- if(newshot.aNshots==0)
- {
- if(newshot.vNshots[0].x<250)
- {
- newshot.vNshots[0].x+=2;
- newshot.vNshots[0].y+=2;
- }
- else{ newshot.aNshots=1; }
- }
- // Update enemies
- // Enemy1
- if(Enemy1.aEnemy==0)
- {
- for(long index=0; index < (long)Enemy1.vS1Enemy.size(); index++)
- {
- Enemy1.vS1Enemy[index].x+=2;
- Enemy1.vS1Enemy[index].y+=2;
- if(Enemy1.vS1Enemy[index].x>225)
- {
- Enemy1.vS1Enemy.erase(Enemy1.vS1Enemy.begin()+index);
- }
- }
- for(long index=0; index < (long)Enemy1.vS2Enemy.size(); index++)
- {
- Enemy1.vS2Enemy[index].x-=2;
- Enemy1.vS2Enemy[index].y+=2;
- if(Enemy1.vS2Enemy[index].x<-21)
- {
- Enemy1.vS2Enemy.erase(Enemy1.vS2Enemy.begin()+index);
- }
- }
- }
- // Enemy2
- for(long index=0; index < (long)Enemy2.vS1Enemy.size(); index++)
- {
- Enemy2.vS1Enemy[index].y+=2;
- if(Enemy2.vS1Enemy[index].y>325)
- {
- Enemy2.vS1Enemy.erase(Enemy2.vS1Enemy.begin()+index);
- }
- }
- for(long index=0; index < (long)Enemy2.vS2Enemy.size(); index++)
- {
- Enemy2.vS2Enemy[index].y+=2;
- if(Enemy2.vS2Enemy[index].y>325)
- {
- Enemy2.vS2Enemy.erase(Enemy2.vS2Enemy.begin()+index);
- }
- }
- }
- /////////////////////////////////////
- case WM_PAINT:
- hdc = BeginPaint(hWnd, &ps);
- Paint(hdc, hWnd);
- EndPaint(hWnd, &ps);
- break;
- case WM_LBUTTONDOWN:
- GetCursorPos(&pt);
- ScreenToClient(hWnd, &pt);
- if(conno==1)
- {
- if(cursor==0)
- {
- conno++;
- }
- else if(cursor==1)
- {
- pt.x+=2;
- conno++;
- }
- if(iShots==1)
- {
- shots2.vshots.push_back(pt);
- }
- }
- else
- {
- if(cursor==0)
- {
- pt.x+=18;
- }
- else if(cursor==1)
- {
- pt.x+=15;
- }
- conno--;
- if(iShots==1)
- {
- shots2.v2shots.push_back(pt);
- }
- }
- if(iShots==0)
- {
- RegularShots.vshots.push_back(pt);
- }
- SetTimer(hWnd, LBUTTONDOWN_ID, 350, NULL);
- InvalidateRect(hWnd, rect, false);
- break;
- case WM_LBUTTONUP:
- KillTimer(hWnd, LBUTTONDOWN_ID);
- break;
- case WM_KEYDOWN:
- SetTimer(hWnd, EVERYTHING_ID, 1, NULL);
- break;
- case WM_TIMER:
- switch(wParam)
- {
- case EVERYTHING_ID:
- if(Enemy1.e1==true)
- {
- Enemy1.now=time(NULL);
- Enemy1.tEnemy=Enemy1.now+1;
- Enemy1.e1=false;
- }
- Enemy1.now=time(NULL);
- if(Enemy1.now==Enemy1.tEnemy)
- {
- SetTimer(hWnd, TAENEMIE1_ID, 30, NULL);
- InvalidateRect(hWnd, rect, false);
- }
- break;
- case LBUTTONDOWN_ID:
- GetCursorPos(&pt);
- ScreenToClient(hWnd, &pt);
- if(conno==1)
- {
- if(cursor==0)
- {
- conno++;
- }
- else if(cursor==1)
- {
- pt.x+=2;
- conno++;
- }
- if(iShots==1)
- {
- shots2.vshots.push_back(pt);
- }
- }
- else
- {
- if(cursor==0)
- {
- pt.x+=18;
- }
- else if(cursor==1)
- {
- pt.x+=15;
- }
- conno--;
- if(iShots==1)
- {
- shots2.v2shots.push_back(pt);
- }
- }
- if(iShots==0)
- {
- RegularShots.vshots.push_back(pt);
- }
- break;
- case TAENEMIE1_ID:
- KillTimer(hWnd, EVERYTHING_ID);
- Timer();
- Updater();
- CreateEnemies(pt2, x, y, x2, y2);
- if(pHits!=550)
- {
- pHits+=50;
- }
- // if regular cursor
- GetCursorPos(&pt);
- ScreenToClient(hWnd, &pt);
- if(cursor==0)
- {
- // player hits
- if(pHits==550)
- {
- // Bounce
- if(bounce.aBounce==0)
- {
- if(.......)
- bounce.vBounce.erase(bounce.vBounce.begin());
- score+=1000;
- bounce.aBounce=1;
- pHits=0;
- break;
- }
- }
- // New shots
- if(newshot.aNshots==0)
- {
- if(......)
- {
- newshot.vNshots.erase(newshot.vNshots.begin());
- iShots++;
- newshot.aNshots=1;
- pHits=0;
- break;
- }
- }
- // Enemy1
- for(long index=0; index < (long)Enemy1.vS1Enemy.size(); index++)
- {
- if(....)
- {
- Enemy1.vS1Enemy[index].y=326;
- health+=30;
- pHits=0;
- break;
- }
- }
- for(long index=0; index < (long)Enemy1.vS2Enemy.size(); index++)
- {
- if(....)
- {
- Enemy1.vS2Enemy[index].y=326;
- health+=30;
- pHits=0;
- break;
- }
- }
- // Enemy2
- for(long index=0; index < (long)Enemy2.vS1Enemy.size(); index++)
- {
- if(....)
- {
- Enemy2.vS1Enemy[index].y=326;
- health+=30;
- pHits=0;
- break;
- }
- }
- for(long index=0; index < (long)Enemy2.vS2Enemy.size(); index++)
- {
- if(.....)
- {
- Enemy2.vS2Enemy[index].y=326;
- health+=30;
- pHits=0;
- break;
- }
- }
- }
- }
- ..........
- // Hits
- ........
- else if(iShots==1)
- {
- // Enemy1
- // shots side one
- for(long index=0; index < (long)shots2.vshots.size(); index++)
- {
- for(long indexs=0; indexs < (long)Enemy1.vS1Enemy.size(); indexs++)
- {
- if(.....)
- {
- Enemy1.vS1Enemy[indexs].x=226;
- shots2.vshots[index].y=-17;
- score+=100;
- break;
- }
- }
- for(long indexs=0; indexs < (long)Enemy1.vS2Enemy.size(); indexs++)
- {
- if(.....)
- {
- Enemy1.vS2Enemy[indexs].x=-25;
- shots2.vshots[index].y=-17;
- score+=100;
- break;
- }
- }
- }
- // shots side two
- for(long index=0; index < (long)shots2.v2shots.size(); index++)
- {
- for(long indexs=0; indexs < (long)Enemy1.vS1Enemy.size(); indexs++)
- {
- if(......)
- {
- Enemy1.vS1Enemy[indexs].x=226;
- shots2.v2shots[index].y=-17;
- score+=100;
- break;
- }
- }
- for(long indexs=0; indexs < (long)Enemy1.vS2Enemy.size(); indexs++)
- {
- if(.....)
- {
- Enemy1.vS2Enemy[indexs].x=-25;
- shots2.v2shots[index].y=-17;
- score+=100;
- break;
- }
- }
- }
- // Enemy2
- if(Enemy2.aEnemy==0)
- {
- // shots side one
- for(long index=0; index < (long)shots2.vshots.size(); index++)
- {
- for(long indexs=0; indexs < (long)Enemy2.vS1Enemy.size(); indexs++)
- {
- if(.....)
- {
- Enemy2.vS1Enemy[indexs].y=326;
- shots2.vshots[index].y=-17;
- score+=100;
- break;
- }
- }
- for(long indexs=0; indexs < (long)Enemy2.vS2Enemy.size(); indexs++)
- {
- if(....)
- {
- Enemy2.vS2Enemy[indexs].y=326;
- shots2.vshots[index].y=-17;
- score+=100;
- break;
- }
- }
- }
- // shots side two
- for(long index=0; index < (long)shots2.v2shots.size(); index++)
- {
- for(long indexs=0; indexs < (long)Enemy2.vS1Enemy.size(); indexs++)
- {
- if(.....)
- {
- Enemy2.vS1Enemy[indexs].y=326;
- shots2.v2shots[index].y=-17;
- score+=100;
- break;
- }
- }
- for(long indexs=0; indexs < (long)Enemy2.vS2Enemy.size(); indexs++)
- {
- if(.....)
- {
- Enemy2.vS2Enemy[indexs].y=326;
- shots2.v2shots[index].y=-17;
- score+=100;
- break;
- }
- }
- }
- }
- }
- if(Enemy1.vS1Enemy.size()==0&&Enemy1.vS2Enemy.size()==0&&Enemy2.cEnemy==0)
- {
- Enemy2.cEnemy=1;
- Enemy2.dEnemy=true;
- }
- if(health>225)
- {
- cursor=1;
- SetTimer(hWnd, PROTECTED_ID, 1000, NULL);
- life--;
- health=0;
- }
- InvalidateRect(hWnd, rect, false);
- break;
- case PROTECTED_ID:
- protect++;
- break;
- }
- break;
- case WM_SETCURSOR:
- SetCursor(hCursor[cursor]);
- return 0;
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement