Comments (2)
๐ก ์์ํ๋ ๋๋ก ์ค๋ณต์ด ๋ฌธ์ ์๋ค.
๋๋ฒ๊น
์ ์ ๋์ถฉ "์ค๋ณต"๋ฌธ์ ๋ผ๊ณ ์์ํด์, ์ผ๋ถ๋ก ํจ์ ๋ฐ๋ก ๊ตฌํํด์ ํ๋๊ฑด๋ฐ,,;;
์ค๊ฐ์ ๋ ์ ๋์น๋ฅผ ๋ชป์ฑ์ง.. ํจ์ ๋ก์ง ๋ค์ ์ดํด๋ด์ผ๊ฒ ๋ค.
void Screen::Set_Filed(const int _size, const int _spot, Field* _fields)//๋งค๊ฐ๋ณ์: ๋๋ค ์ง๋ขฐ๊ฐ์.
{
int placed_count= _spot;
int* seeds = new int[_size]; //๋๋ค๊ฐ ์ค๋ณต ๋ฐฉ์ง๋ฅผ ์ํด ๊ฐ ์ ์ฅ.
memset(seeds, -1, sizeof(seeds));
while (placed_count > 0)
{
int i = (rand() % (_size-1) + 1);// 1 ~ size ๊น์ง
if ((i >= 11 && i % 11 == 0) || Check_OverLap_Seed(seeds, i)) continue;
seeds[_spot - placed_count] = i;
_fields[i - 1].Changestate(STATE_SPOT);
placed_count--;
}
delete[] seeds;
}
//randseed ์ค๋ณต ์ฒดํฌ ํจ์: ๊ฒ์ฌํ ๊ฐ์ ๋ฃ๊ณ ์ค๋ณต์ด ์์ผ๋ฉด false๋ฅผ ๋ฐํํ๋ค.
bool Screen::Check_OverLap_Seed(int* _seeds,const int _seed)
{
for (int i = 0; i < sizeof(_seeds); i++)
{
if (_seeds[i] == _seed) return true;
}
return false;
}
from opp-mine-sweeper-game.
โ
๋๋ฒ๊ฑฐ๋ก ๊ฐ ๋ฃ์ผ๋ฉด์ ๋๋ฆฐ ๊ฒฐ๊ณผ, seeds์ ๋ฐฐ์ด์ด ์ ๋๋ก ์ด๊ธฐํ ์๋๋ ์ ์ ๋ฐ๊ฒฌํ๋ค.
๊ทธ๋์ sizeof์ ๊ฐ์ ์ฐ์ด๋ณด๋...ํฌ๊ธฐ๊ฐ 4๊ฐ ๋์ค๋ ๊ฒ์ด๋ค.
sizeof ํจ์์ ์ฐ์์ ์ ๋๋ก ์์ง ๋ชปํ๊ณ ์ฌ์ฉํ ๋ด ์ค์์๋ค.ใ
ใ
ใ
sizeof๊ฐ ์๋ ๋ฐฐ์ด ์ฌ์ด์ฆ๋ฅผ ๋ฃ์ด์ฃผ๋, ์ ๋๋ก ์ด๊ธฐํ๊ฐ -1๋ก ๋์๊ณ , ์ค๋ณต ๊ฒ์ฌ ํจ์๋ ๋ถํ์ํ ํ์์ ์ค์ด๊ธฐ ์ํด์
while๋ฌธ์ ์ฌ์ฉํ์ฌ ๋ฐ๊พธ์๋ค.
//randseed ์ค๋ณต ์ฒดํฌ ํจ์: ๊ฒ์ฌํ ๊ฐ์ ๋ฃ๊ณ ์ค๋ณต์ด ์์ผ๋ฉด false๋ฅผ ๋ฐํํ๋ค.
bool Screen::Check_OverLap_Seed(const int* _seeds,const int _seed)
{
int i = 0;
while (_seeds[i] != -1)
{
if (_seeds[i] == _seed) return true;
i++;
}
return false;
}
from opp-mine-sweeper-game.
Related Issues (7)
- ๐.run() while๋ฌธ ํ์ถ์ ํ ์ถฉ๋ ์ค๋ฅ
- ๐README.md update HOT 1
- โ UI ์กฐ์ ํ๊ธฐ HOT 2
- ๐ ์ฃผ๋ณ ์ง๋ขฐ ์นด์ดํธ ํจ์ ์๊ณ ๋ฆฌ์ฆ ์ค๋ฅ
- ๐[ERROR] E0245 : a nonstatic member reference must be relative to a specific object HOT 6
- ๐[ERROR] member function declared with 'override' does not override a base class member
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opp-mine-sweeper-game.