게임을 만들고 있는데 어려움이 생겼습니다.

na94ojt의 이미지

(문제점을 찍은 사진을 첨부했습니다)
저는 크레이지아케이드를 mfc로 만들어 보고 있는 학생입니다.
진짜처럼 보이기 위해 게임할 때 인터페이스 창(주변에 유저이름 보이고 나가기 버튼도 있는)도 캡쳐해서 구해놨고
프로그램이 실행되면 전체화면으로 전환되며 전체화면으로 전환된 다이얼로그 크기를 RECT구조체에 받아서
늘어난 비율에 따라 게임화면이 어디부터 어디까지인지 정해서 출력하는 것입니다.
예를 들어서 원래 인터페이스 사진의 크기는 가로 800이고 사진에서 게임화면의 시작 위치(left)는 20입니다.
그렇다면 이때의 비율은 800:20이고,전체화면의 크기 정보는 rect라는 RECT구조체에 담았다고 했을 때 전체화면의 가로 길이는 rect.right이고 이 때 게임화면의 시작 위치는 모르니까 x라고 치면 비율은 rect.right:x입니다.
800:20과 rect.right:x는 비율이 같을테니까
800:20 = rect.right:x일 테고
그렇다면 20*rect.right = 800x이고
결론적으로 x = rect.right*20/800 이라고 생각을 했습니다. 그래서 완성한 코드가 아래와 같습니다.

	RECT rect;
	int startx, starty, endx, endy, width, height;
	GetClientRect(hWnd, &rect);
 
	startx = rect.right * 20 / 800;
	starty = rect.bottom * 40 / 600;
	endx = rect.right * 620 / 800;
	endy = rect.bottom * 560 / 600;
 
	width = (endx - startx) / 15;
	height = (endy - starty) / 13;
 
	HDC memDC = CreateCompatibleDC(hdc);
 
	HBITMAP pOld = (HBITMAP)SelectObject(memDC, this->m_hBackgroundBit);
	TransparentBlt(hdc, rect.left, rect.top, rect.right, rect.bottom, memDC, 0, 0, 800, 600, RGB(255, 0, 255));
 
	pOld = (HBITMAP)SelectObject(memDC, this->m_hBackgroundFieldBit);
	TransparentBlt(hdc, startx, starty, endx, endy, memDC, 0, 0, 600, 520, RGB(255, 0, 255));
 
	pOld = (HBITMAP)SelectObject(memDC, this->m_hHardBlockBit);
	TransparentBlt(hdc, startx, starty, startx + width, starty + height, memDC, 0, 0, 40, 40, RGB(255, 0, 255));
 
	SelectObject(memDC, pOld);
	DeleteDC(memDC);

위 코드가 실행되면 사진과 같이 나옵니다. 시작 좌표는 맞는것같지만 끝 좌표도 맞지 않고 블록의 크기도 맞지않습니다.
크기를 잘 조절하는 방법이 없을까요?
File attachments: 
첨부파일 크기
Image icon game3.jpg280.91 KB

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.