#include "stdafx.h"
#include "gameStudy.h"
gameStudy::gameStudy()
{
}
gameStudy::~gameStudy()
{
}
//초기화는 여기서 한다
HRESULT gameStudy::init()
{
gameNode::init();
srand((unsigned int)time(NULL));
rc1 = RectMake(100, 100, 50, 50);
rc2 = RectMake(200, 100, 50, 50);
rc3 = RectMake(300, 100, 50, 50);
rc4 = RectMake(150, 200, 50, 50);
rc5 = RectMake(250, 200, 50, 50);
return S_OK;
}
//메모리 해제는 여기서
void gameStudy::release()
{
gameNode::release();
}
//계속 무한 반복 되어야 할 것들 여기서
void gameStudy::update()
{
temp = RND->getInt(6);
if (KEYMANAGER->isStayDown(VK_LBUTTON))
{
if (rc1.top < 100)
{
if (PtInRect(&rc1, _ptMouse))
{
check1 = true;
score = score + 50;
}
}
if (rc2.top < 100)
{
if (PtInRect(&rc2, _ptMouse))
{
check2 = true;
score = score + 50;
}
}
if (rc3.top < 100)
{
if (PtInRect(&rc3, _ptMouse))
{
check3 = true;
score = score + 50;
}
}
if (rc4.top < 200)
{
if (PtInRect(&rc4, _ptMouse))
{
check4 = true;
score = score + 50;
}
}
if (rc5.top < 200)
{
if (PtInRect(&rc5, _ptMouse))
{
check5 = true;
score = score + 50;
}
}
}
gameNode::update();
}
//그려주는 건 여기서
void gameStudy::render(HDC hdc)
{
Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
Rectangle(hdc, rc1.left, rc1.top, rc1.right, rc1.bottom);
Rectangle(hdc, rc2.left, rc2.top, rc2.right, rc2.bottom);
Rectangle(hdc, rc3.left, rc3.top, rc3.right, rc3.bottom);
Rectangle(hdc, rc4.left, rc4.top, rc4.right, rc4.bottom);
Rectangle(hdc, rc5.left, rc5.top, rc5.right, rc5.bottom);
char space[256];
sprintf_s(space, "점수 : %d", score);
TextOut(hdc, 200, 20, space, strlen(space));
if (temp == 1)
{
rc1.top = rc1.top - 50;
}
else
{
rc1.top = 100;
}
if (temp == 2)
{
rc2.top = rc2.top - 50;
}
else
{
rc2.top = 100;
}
if (temp == 3)
{
rc3.top = rc3.top - 50;
}
else
{
rc3.top = 100;
}
if (temp == 4)
{
rc4.top = rc4.top - 50;
}
else
{
rc4.top = 200;
}
if (temp == 5)
{
rc5.top = rc5.top - 50;
}
else
{
rc5.top = 200;
}
}
두더지잡기 게임 비슷하게 만들었는데요
랜덤값이 너무빨리바뀌다보니까
말그대로 두더지도 너무빨리 올라왔다 내려갑니다
시간딜레이를 주려고
sleep 를 걸어봤는데 이역시
두더지가 뜬시점과 동시에 클릭을해줘야 점수가올라서 문제가발생합니다
sleep를 사각형 rc.top -50 부분에 걸어주면
점수 : 부분이 글씨가 가려집니다
이역시 invaildate 함수로 써볼려고했지만 hwnd 정의가 안되있다고 오류가뜹니다
마찬가지로 settimer killtimer 써보려고해도 hwnd 정의가안되있다고 못씁니다 ㅠㅠㅠ
어떻게해야 settimer 를 쓸수있을까요??
아니면 다른방법으로 두더지가 올라왔을때 한 1초쉬고 내려가게하는방법이있을까요????
wait 찾아보니까 없음 ㅠㅠ
안읽어봤지만 게임루프를 만들고 프레임마다 해 보아요
나의 관점은 두더지라는 객체를 만들고 해당 객체를 관리 하는 형태로 코딩하셔야 될꺼 같아요
지금 저린식으면 코드가 정말루 복잡해 질꺼 같네요 .. 냄새가 나요 ㅎㅎ