Giter Site home page Giter Site logo

Comments (6)

Yeram522 avatar Yeram522 commented on July 22, 2024 1

โŒ Field ์œ„์น˜ ์ •๋ณด ์ดˆ๊ธฐํ™” ์•ˆ๋จ
โŒ Clicked์‹œ ๋ชจ๋“  ๋ฐฐ์—ด์ด ์—ด๋ ค๋ฒ„๋ฆฌ๋Š” ์˜ค๋ฅ˜

from opp-mine-sweeper-game.

Yeram522 avatar Yeram522 commented on July 22, 2024

๐Ÿ’ก Staticํ•จ์ˆ˜ ์•ˆ์—์„œ static์ด ์•„๋‹Œ ํ•จ์ˆ˜๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ ๊ทธ๋ ‡๋‹ค!
์–ด๋–ป๊ฒŒ ํ•ด๊ฒฐํ•˜๋ฉด ์ข‹์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด์ž!

from opp-mine-sweeper-game.

Yeram522 avatar Yeram522 commented on July 22, 2024

image
void Game2D::MouseEventProc(MOUSE_EVENT_RECORD mer)ํ•จ์ˆ˜๋ฅผ unstatic์œผ๋กœ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ, ๊ทธ๋ž˜๋„ main.cpp์˜ ํ•จ์ˆ˜๋ฅผ ๋‹ค๋ฅธ .cpp์—์„œ ์‚ฌ์šฉํ•˜๋ ค๋ฉด main.h๊ฐ€ ํ•„์š”ํ•˜๊ฒŒ ๋œ๋‹ค. ๊ทธ๋ž˜์„œ main.h๋ฅผ ๋”ฐ๋กœ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ? ์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋‚œ๋‹ค. ์™œ๊ทธ๋Ÿฐ์ง€ ์ด์œ ๋Š” ๋ชป์ฐพ์Œ.

๊ทธ๋ž˜์„œ Field๋ฅผ static ๋ณ€์ˆ˜๋กœ ๋งŒ๋“ค๊ธฐ๋กœ ํ–ˆ๋‹ค.

from opp-mine-sweeper-game.

Yeram522 avatar Yeram522 commented on July 22, 2024

image
ํด๋ž˜์Šค์˜ static ๋ณ€์ˆ˜๋Š” ํ•ด๋‹น ํด๋ž˜์Šค์˜ ๋ฉค๋ฒ„๋ณ€์ˆ˜๋กœ ์†ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์—, ์ƒ์„ฑ์ž์—์„œ ์ดˆ๊ธฐํ™” ํ•ด์ค„ ์ˆ˜ ์—†์–ด์„œ, ์ƒ์„ฑ์ž ํ•จ์ˆ˜์— ์ดˆ๊ธฐํ™” ํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ๋„ฃ์—ˆ์ง€๋งŒ, ์œ„์™€ ๊ฐ™์ด ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค.

์˜ค๋ฅ˜๊ฐ€ ๋‚œ ์ด์œ ๋Š”, ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.
์ถœ์ฒ˜

ํด๋ž˜์Šค์—์„œ์˜ static๋ณ€์ˆ˜๋Š” ๋ชจ๋‘ ํด๋ž˜์Šค ์™ธ๋ถ€์—์„œ ์„ ์–ธํ•ด ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
๊ทธ ์„ฑ์งˆ์ƒ static๋ณ€์ˆ˜๋Š” ์ „์—ญ๋ณ€์ˆ˜์™€ ๊ฐ™์ง€๋งŒ, ์Šค์ฝ”ํ”„๋งŒ ํด๋ž˜์Šค ์Šค์ฝ”ํ”„์— ์†Œ์†๋œ ์ „์—ญ๋ณ€์ˆ˜๋ผ๊ณ  ๋ณด๋Š” ๊ฒƒ์ด ํƒ€๋‹นํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ „์—ญ๋ณ€์ˆ˜์™€ ๊ฐ™์€ ์œ„์น˜์—์„œ ์„ ์–ธ๋˜๋Š” ๊ฒƒ์ด์ง€์š”.

๊ทธ๋ž˜์„œ ์™ธ๋ถ€์— static์„ ํ•œ๋ฒˆ ์„ ์–ธํ•ด์ฃผ์—ˆ๋”๋‹ˆ ํ•ด๊ฒฐ ๋˜์—ˆ๋‹ค.
image

๐Ÿ’ก๊ทผ๋ฐ cpp๋Š” ๊ฐ์ฒด์ง€ํ–ฅ์ธ๋ฐ, ํด๋ž˜์Šค ์œ„์— ํด๋ž˜์Šค์˜ static ์ „์—ญ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๋Š”์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค..

โš’Field๋ฅผ static์œผ๋กœ ํ•ด์ฃผ๋Š” ๊ฒฝ์šฐ์— ๊ด€๋ จ๋œ ํ•จ์ˆ˜๋„ static์œผ๋กœ ๋ฐ”๊ฟ”์•ผ ํ•˜๊ณ , ์—ฌ๋Ÿฌ๋ชจ๋กœ ๋ชจ๋“  ๊ฒƒ์„ ์ „์—ญ๋ณ€์ˆ˜๋กœ ๋ฐ”๊ฟ”์•ผ ๋˜๋Š” ์ƒํ™ฉ์ด ์™€์„œ ์œ„์˜ ์•„์ด๋””์–ด๋Š” ๋ชจ๋‘ ์ฒ ํšŒํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.

from opp-mine-sweeper-game.

Yeram522 avatar Yeram522 commented on July 22, 2024
void update() override
	{
		Game2D::Update_UI(this->flag_count);

		if (Game2D::IsMouseClicked)
		{
			for (int i = 0; i < 10*11; i++)
			{
				WindowPos fieldpos = fields[i].GetWinpos();//์ง€์—ญ๋ณ€์ˆ˜
				Borland::gotoxy(0, 20);
				printf("Clicked %d %d\n%d %d", fieldpos.x, fieldpos.y, ClickedPos.x, ClickedPos.y);
				Borland::gotoxy(0, 1);
				if (fieldpos.x == ClickedPos.x && fieldpos.y == ClickedPos.y)
					fields[i].Clicked();
			}
		}

		draw(pos, fields);

		render();
	}

main.cpp ์—์„œ ์ž…๋ ฅ ์ด๋ฒคํŠธ๊ฐ€ ์ผ์–ด๋‚  ์ˆ˜ ์žˆ๊ฒŒ ๋ฐ”๊พธ์—ˆ๋‹ค.
๊ทธ๋Ÿฐ๋ฐ, ๊ฐ๊ฐ ํ•„๋“œ์˜ ์œ„์น˜์ •๋ณด์˜ ์ดˆ๊ธฐํ™”๊ฐ€ ์ œ๋Œ€๋กœ ์•ˆ๋œ ๊ฒƒ ๊ฐ™๋‹ค..ใ… ใ… 

from opp-mine-sweeper-game.

Yeram522 avatar Yeram522 commented on July 22, 2024

๐ŸŒžํ•ด๊ฒฐ

void Init_Winpos(int _index)
	{
		Winpos.x = 3 + (_index - (_index / 11) * 11 - 1) * 4;
		Winpos.y = _index / 11 + 2;
	}

๋””๋ฒ„๊ฑฐ ๋Œ๋ ค๋ณธ ๊ฒฐ๊ณผ ์ˆ˜์‹ ์˜ค๋ฅ˜ ์žˆ์—ˆ์Œ.

void Clicked()
	{
		Isclicked = true;
		Changestate(state);
	}

Clickedํ•จ์ˆ˜์—์„œ isclicked๋งŒ true๋กœ ๋ฐ”๊ฟ”์ฃผ๊ณ , field์˜ shape ์€ ์•ˆ๋ฐ”๊ฟ”์ค˜์„œ ๋ชจ์–‘ ์•ˆ๋ฐ”๋€๊ฑฐ์˜€์Œ.
๋ชจ๋“  ๋ฐฐ์—ด์ด ์—ด๋ ค๋ฒ„๋ฆฌ๋Š” ์˜ค๋ฅ˜๊ฐ€ ์žˆ์–ด์„œ,,์ด์œ ๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ใ… ใ… ๊ทธ๋ƒฅ ํ•จ์ˆ˜์ž์ฒด๋ฅผ ์™ธ๋ถ€์— ์„ ์–ธํ•˜์ง€ ์•Š๊ณ  ํด๋ž˜์Šค ๋‚ด๋ถ€์— ์„ ์–ธํ–ˆ์Œ. ์ด๊ฑด ๋‚˜์ค‘์— ๋ธŒ๋žœ์น˜ ๋”ฐ๋กœ ํŒŒ์„œ ์ง์ ‘ ํ™•์ธํ•ด๋ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค. #9

from opp-mine-sweeper-game.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.