ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • C 게임프로그래밍 8
    프로그래밍 2013. 11. 9. 19:34
    반응형
    #include 
    #include 
    #include 
    
    #define PLAYER_BULLET_MAX 5
    
    typedef struct _bullet
    {
    	int x;
    	int y;
    	bool fire;
    
    }BULLET;
    
    char bg[25][80];
    int playerX;
    int playerY;
    
    int enemyX;
    int enemyY;
    
    BULLET playerBullet[PLAYER_BULLET_MAX];
    
    
    void PrintfScreen(void);
    void ClearScreen(void);
    void GameMain(void);
    
    void KeyControl(void);
    void BulletDraw(void);
    void PlayerDraw(void);
    
    void EnemyDraw(void);
    void EnemyMove(void);
    
    void ClashEenmyAndBullet(void);
    
    void main(void)
    {
    	playerX = 0;
    	playerY = 12;
    
    	enemyX = 77;
    	enemyY = 12;
    
    	for(int i=0;i 75)
    				playerX = 75;
    			break;
    
    		case 80:
    			playerY++;
    			if(playerY > 23)
    				playerY = 23;
    			break;
    		case 32:
    			for(int i = 0; i 79)
    				{
    					playerBullet[i].fire = false;
    				}
    			}
    
    
    			
    	}
    }
    
    void PlayerDraw(void)
    {
    	bg[playerY - 1][playerX + 0] = '-';
    	bg[playerY - 1][playerX + 1] = '>';
    	bg[playerY + 0][playerX + 1] = '>';
    	bg[playerY + 0][playerX + 2] = '>';
    	bg[playerY + 0][playerX + 3] = '>';
    	bg[playerY + 1][playerX + 0] = '-';
    	bg[playerY + 1][playerX + 1] = '>';
    	
    
    }
    
    
    void EnemyDraw(void)
    {
    	bg[enemyY - 0][enemyX - 2] = '<';
    	bg[enemyY + 0][enemyX - 1] = '-';
    	bg[enemyY + 0][enemyX + 0] = '0';
    	bg[enemyY + 0][enemyX + 1] = '-';
    	bg[enemyY + 0][enemyX + 2] = '>';
    
    }
    
    
    void EnemyMove(void)
    {
    	enemyX--;
    
    	if(enemyX<2)
    	{
    		enemyX = 77;
    		enemyY = (rand()%20) + 2;
    
    	}
    }
    
    void ClashEenmyAndBullet(void)
    {
    	for(int i = 0; i= (enemyX-1)) &&(playerBullet[i].x <= (enemyX+1)))
    					{
    						enemyX = 77;
    						enemyY = (rand()%20) + 2;
    						playerBullet[i].fire = false;
    					}
    				}
    			
    		}
    	}
    }
    
    
    반응형

    '프로그래밍' 카테고리의 다른 글

    개인정보처리방침 구글 출시용  (0) 2021.06.10
    1 강. Direct3D 기본 환경 만들기  (0) 2013.11.14
    C 게임프로그래밍 7  (0) 2013.11.09
    C 게임프로그래밍 6  (0) 2013.11.09
    C 게임프로그래밍 5  (0) 2013.11.09
Designed by Tistory.