forked from CAU-LetsCode/OOP-Proj4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add : Jumper.cpp Modify : a lot
- Loading branch information
Showing
182 changed files
with
6,709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "d3dUtility.h" | ||
#include "CBorder.h" | ||
|
||
// 테두리의 생성자 | ||
CBorder::CBorder(D3DXCOLOR color) | ||
{ | ||
D3DXMatrixIdentity(&m_mLocal); | ||
ZeroMemory(&m_mtrl, sizeof(m_mtrl)); | ||
mesh = nullptr; | ||
|
||
m_mtrl.Ambient = color; | ||
m_mtrl.Diffuse = color; | ||
m_mtrl.Specular = color; | ||
m_mtrl.Emissive = d3d::BLACK; | ||
m_mtrl.Power = 5.0f; | ||
} | ||
|
||
// 테두리의 소멸자 | ||
CBorder::~CBorder() | ||
{ | ||
d3d::Release<ID3DXMesh*>(mesh); | ||
|
||
for (int i = 0; i < Textures.size(); i++) | ||
{ | ||
d3d::Release<IDirect3DTexture9*>(Textures[i]); | ||
} | ||
} | ||
|
||
bool CBorder::create(IDirect3DDevice9* pDevice, float ix, float iz, float iwidth, float iheight, float idepth, D3DXCOLOR color = d3d::WHITE) | ||
{ | ||
if (NULL == pDevice) | ||
return false; | ||
|
||
m_mtrl.Ambient = color; | ||
m_mtrl.Diffuse = color; | ||
m_mtrl.Specular = color; | ||
m_mtrl.Emissive = d3d::BLACK; | ||
m_mtrl.Power = 5.0f; | ||
|
||
m_width = iwidth; | ||
m_depth = idepth; | ||
|
||
if (FAILED(D3DXCreateBox(pDevice, iwidth, iheight, idepth, &m_pBoundMesh, NULL))) | ||
return false; | ||
return true; | ||
} | ||
|
||
// 벽을 화면에서 소멸시킴 | ||
void CBorder::destroy() | ||
{ | ||
if (mesh != nullptr) | ||
{ | ||
mesh->Release(); | ||
mesh = nullptr; | ||
} | ||
} | ||
|
||
// 테두리를 화면에 그려냄 | ||
void CBorder::draw(IDirect3DDevice9* pDevice, const D3DXMATRIX& mWorld) | ||
{ | ||
if (NULL == pDevice) | ||
return; | ||
pDevice->SetTransform(D3DTS_WORLD, &mWorld); | ||
pDevice->MultiplyTransform(D3DTS_WORLD, &m_mLocal); | ||
pDevice->SetMaterial(&m_mtrl); | ||
m_pBoundMesh->DrawSubset(0); | ||
} | ||
|
||
void CBorder::setPosition(float x, float y, float z) | ||
{ | ||
D3DXMATRIX m; | ||
/*this->m_x = x; | ||
this->m_z = z;*/ | ||
this->center_x = x; | ||
this->center_y = y; | ||
this->center_z = z; | ||
|
||
D3DXMatrixTranslation(&m, x, y, z); | ||
setLocalTransform(m); | ||
} | ||
void CBorder::setLocalTransform(const D3DXMATRIX& mLocal) { m_mLocal = mLocal; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef _CBORDER_ | ||
#define _CBORDER_ | ||
|
||
#include "d3dUtility.h" | ||
#include <vector> | ||
|
||
// ----------------------------------------------------------------------------- | ||
// CBorder class definition | ||
// 당구대(다이)의 테두리에 관련한 클래스에 대한 정의 (3ds max와 maya로 작업) | ||
// ----------------------------------------------------------------------------- | ||
class CBorder | ||
{ | ||
private: | ||
float m_width; | ||
float m_depth; | ||
float center_x, center_y, center_z; | ||
D3DMATERIAL9 m_mtrl; | ||
D3DXMATRIX m_mLocal; | ||
ID3DXMesh* mesh; | ||
std::vector<D3DMATERIAL9> Mtrls; | ||
std::vector<IDirect3DTexture9*> Textures; | ||
ID3DXMesh* m_pBoundMesh; | ||
void setLocalTransform(const D3DXMATRIX& mLocal); | ||
public: | ||
CBorder(D3DXCOLOR color); // 테두리의 생성자 | ||
~CBorder(); // 테두리의 소멸자 | ||
void setPosition(float x, float y, float z); | ||
bool create(IDirect3DDevice9* pDevice, float ix, float iz, float iwidth, float iheight, float idepth, D3DXCOLOR color); // 테두리를 화면에 생성함 | ||
void draw(IDirect3DDevice9* pDevice, const D3DXMATRIX& mWorld); // 테두리를 화면에 그려냄 | ||
void destroy(); // 테두리를 화면에서 소멸시킴 | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "CBottomWall.h" | ||
|
||
CBottomWall::CBottomWall(float iwidth, float iheight, float idepth, D3DXCOLOR color) | ||
: CWall(iwidth, iheight, idepth, color) { | ||
} | ||
|
||
bool CBottomWall::hasIntersected(CSphere& ball) const noexcept { | ||
if (ball.getPosition().x > this->center_x - (this->m_width / 2) && | ||
ball.getPosition().x < this->center_x + (this->m_width / 2)) { | ||
if (ball.getPosition().z - ball.getRadius() < this->center_z + (this->m_depth / 2)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
void CBottomWall::hitBy(CSphere& ball) noexcept { | ||
if (hasIntersected(ball)) { | ||
this->adjustPosition(ball); | ||
ball.setPower(ball.getVelocity_X() * (1 - LOSS_RATIO), -ball.getVelocity_Z() * (1 - LOSS_RATIO)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef _CBOTTOMWALL_ | ||
#define _CBOTTOMWALL_ | ||
#include "CWall.h" | ||
|
||
class CBottomWall : public CWall | ||
{ | ||
public: | ||
CBottomWall(float iwidth, float iheight, float idepth, D3DXCOLOR color); | ||
bool hasIntersected(CSphere& ball) const noexcept; | ||
void hitBy(CSphere& ball) noexcept; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#include "CFloor.h" | ||
#include "CSphere.h" | ||
#include <iostream> | ||
using namespace std; | ||
|
||
#define M_RADIUS 0.21 | ||
#define PI 3.14159265 | ||
#define M_HEIGHT 0.01 | ||
#define DECREASE_RATE 0.9982 | ||
|
||
const float CFloor::LOSS_RATIO = 0.006; | ||
|
||
CFloor::CFloor(void) { | ||
D3DXMatrixIdentity(&m_mLocal); | ||
ZeroMemory(&m_mtrl, sizeof(m_mtrl)); | ||
m_width = 0; | ||
m_depth = 0; | ||
m_pBoundMesh = NULL; | ||
} | ||
|
||
CFloor::CFloor(float iwidth, float iheight, float idepth, D3DXCOLOR color) { | ||
D3DXMatrixIdentity(&m_mLocal); | ||
ZeroMemory(&m_mtrl, sizeof(m_mtrl)); | ||
|
||
m_mtrl.Ambient = color; | ||
m_mtrl.Diffuse = color; | ||
m_mtrl.Specular = color; | ||
m_mtrl.Emissive = d3d::BLACK; | ||
m_mtrl.Power = 5.0f; | ||
m_width = iwidth; | ||
m_height = iheight; | ||
m_depth = idepth; | ||
m_pBoundMesh = nullptr; | ||
} | ||
|
||
CFloor::~CFloor(void) {} | ||
|
||
bool CFloor::create(IDirect3DDevice9* pDevice, float ix, float iz, float iwidth, float iheight, float idepth, D3DXCOLOR color = d3d::WHITE) { | ||
if (NULL == pDevice) | ||
return false; | ||
|
||
m_mtrl.Ambient = color; | ||
m_mtrl.Diffuse = color; | ||
m_mtrl.Specular = color; | ||
m_mtrl.Emissive = d3d::BLACK; | ||
m_mtrl.Power = 5.0f; | ||
|
||
m_width = iwidth; | ||
m_depth = idepth; | ||
|
||
if (FAILED(D3DXCreateBox(pDevice, iwidth, iheight, idepth, &m_pBoundMesh, NULL))) | ||
return false; | ||
return true; | ||
} | ||
|
||
void CFloor::destroy(void) { | ||
if (m_pBoundMesh != NULL) { | ||
m_pBoundMesh->Release(); | ||
m_pBoundMesh = NULL; | ||
} | ||
} | ||
|
||
void CFloor::draw(IDirect3DDevice9* pDevice, const D3DXMATRIX& mWorld) { | ||
if (NULL == pDevice) | ||
return; | ||
pDevice->SetTransform(D3DTS_WORLD, &mWorld); | ||
pDevice->MultiplyTransform(D3DTS_WORLD, &m_mLocal); | ||
pDevice->SetMaterial(&m_mtrl); | ||
m_pBoundMesh->DrawSubset(0); | ||
} | ||
|
||
|
||
void CFloor::setPosition(float x, float y, float z) { | ||
D3DXMATRIX m; | ||
this->m_x = x; | ||
this->m_z = z; | ||
|
||
D3DXMatrixTranslation(&m, x, y, z); | ||
setLocalTransform(m); | ||
} | ||
|
||
float CFloor::getHeight(void) const { return M_HEIGHT; } | ||
|
||
void CFloor::setLocalTransform(const D3DXMATRIX& mLocal) { m_mLocal = mLocal; } | ||
|
||
void CFloor::setType(int type) { type = type; } | ||
|
||
D3DXVECTOR3 CFloor::getPosition() const { | ||
D3DXVECTOR3 org(center_x, center_y, center_z); | ||
return org; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef _CFloor_ | ||
#define _CFloor_ | ||
|
||
#include "d3dUtility.h" | ||
#include "CSphere.h" | ||
|
||
|
||
class CFloor | ||
{ | ||
protected: | ||
float m_x; | ||
float m_z; | ||
float m_width; | ||
float m_depth; | ||
float m_height; | ||
|
||
int type; | ||
|
||
D3DXMATRIX m_mLocal; | ||
D3DMATERIAL9 m_mtrl; | ||
ID3DXMesh* m_pBoundMesh; | ||
|
||
float center_x, center_y, center_z; | ||
|
||
void setLocalTransform(const D3DXMATRIX& mLocal); | ||
|
||
public: | ||
static const float LOSS_RATIO; | ||
CFloor(void); | ||
CFloor(float iwidth, float iheight, float idepth, D3DXCOLOR color); | ||
~CFloor(void); | ||
bool create(IDirect3DDevice9* pDevice, float ix, float iz, float iwidth, float iheight, float idepth, D3DXCOLOR color); | ||
void destroy(void); | ||
void draw(IDirect3DDevice9* pDevice, const D3DXMATRIX& mWorld); | ||
void setPosition(float x, float y, float z); | ||
float getHeight(void) const; | ||
void setType(int type); | ||
D3DXVECTOR3 getPosition() const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "CHandSphere.h" | ||
|
||
CHandSphere::CHandSphere(const char* ballImageFileName) : CSphere("0") { | ||
this->firstHitBallType = BallType::NONE; | ||
} | ||
|
||
BallType CHandSphere::getFirstHitBallType() const noexcept { | ||
return this->firstHitBallType; | ||
} | ||
|
||
void CHandSphere::setFirstHitBallType(BallType ballType) noexcept { | ||
this->firstHitBallType = ballType; | ||
} | ||
|
||
void CHandSphere::hitBy(CSphere& ball) noexcept { | ||
if (this->hasIntersected(ball)) { | ||
if (this->firstHitBallType == BallType::NONE) { | ||
this->firstHitBallType = ball.getBallType(); | ||
} | ||
super::hitBy(ball); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef _CHANDSPHERE_ | ||
#define _CHANDSPHERE_ | ||
#include "CSphere.h" | ||
|
||
class CHandSphere : public CSphere | ||
{ | ||
private: | ||
BallType firstHitBallType; | ||
public: | ||
CHandSphere(const char* ballImageFileName); | ||
BallType getFirstHitBallType() const noexcept; | ||
void setFirstHitBallType(BallType ballType) noexcept; | ||
void hitBy(CSphere& ball) noexcept; | ||
}; | ||
#endif |
Oops, something went wrong.