Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Enemies::respawnRandomEnemy(){
- byte direction = 0, type= 0, color= 0;
- int w= 0, h= 0;
- float x= 0, y= 0, scale= 0, speed= 0;
- //Random type
- type = RandomInt(1, 2);
- //Depending on the type, the scale and the speed changes and calculate the w and h
- switch( type ){
- case T_CIRCLE:
- scale = RandomFloat(0.4 , 0.6);
- speed = RandomFloat(1, 2);
- break;
- case T_SQUARE:
- scale = RandomFloat(0.2 , 0.4);
- speed = RandomFloat(0.5, 1.5);
- break;
- }
- w = (int)(64 * scale);
- h = (int)(64 * scale);
- //Random color
- color = RandomInt(1, 2);
- switch( direction ){
- case D_UP:
- x = RandomFloat(w, limitX - w);
- y = limitY-1;
- break;
- case D_DOWN:
- x = RandomFloat(w, limitX - w);
- y = -h+1;
- break;
- case D_RIGHT:
- x = -w+1;
- y = RandomFloat(h, limitY - h);
- break;
- case D_LEFT:
- x = limitX-1;
- y = RandomFloat(h, limitY - h);
- break;
- }
- //Add the enemy to the list!
- enemyList.push_back( Enemy(x, y, scale, speed, type, color, direction));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement