 1980년대 초반 오락기로 등장해 많은 인기를 끌었었던 스페이스 인베이더 게임을 앱 인벤터로 코딩해 보자. 스페이스 인베이더 게임의 개요는 스마트 폰 하단에 위치한 로케트를 터치하여 좌우로 드래그하면 총알이 발사되면 스마트폰 상단에 위치한 우주선을 맞춰 격추 시키는 게임이다.  로케트와 우주선 및 총알은 Drawing and Animation에서 ImageSprite 2개와 Ball 1개를 각각 사용하기로 한다. Score 3은 2개의 라벨로 구성된다. Score는 내용 변동이 없는 단순히 붙박이 라벨이며 뒤따르는 점수는 블록 코딩 편집에서 변수로 처리되어 그 결과가 수시로 입력된다. 한편 RESET은 버튼이며 누르면 Score 가 0으로 설정된다. 아울러 클럭이 1개 사용되는데 이는 우주선이 한 번씩 위치를 바꾸기 위한 허용 시간이며 지금의 코딩에서는 총알의 속도를 감안하여 많은 스코어를 낼 수 있도록 3초로 설정하였다. 허용 시간을 줄이면 빨리 움직이므로 총알의 속도(Speed) 값을 올려 줄 필요가 있다.  로케트(rocket)와 우주선(saucer)은 인터넷에서 png 이미지 파일을 검색하여 마음에 드는 그래픽 파일을 다운하여 사용하도록 한다. 즉 png 그림 파일이 준비되면 속성 창에서 업로딩 기능을 사용하여 불러 온다. 총알은 이미지 파일이 아니면 Drawing and Animation의 Ball을 사용하여 속성 즉 반경(radius) 과 속도(Speed) 및 색상 설정을 해 주면 된다. 블록 코딩에서 퍼즐을 맞춰 보기로 한다. 스크린을 초기화함에 있어 총알은 발사 시에 볼 수 있어야 하나 스크린 초기화 시에는 거짓(false) 으로 설정하여 볼 수 없도록 한다.  로케트스프라이트는 드래그할 때에 X 좌표 값을 얻어낸다. 아래의 코딩에서는 로케트 스프라이트를 터치했을 때 총알 발사지점의 좌표, 가시성, 속도 및 방향을 설정한다.  이어서 총알 발사 후 총알이 우주선(SaucerSprite)과 부딪힐 때의 조건으로서 총알의 가시성을 즉각 OFF 함과 동시에 로케트의 X 좌표에 로케트 너비의 반만큼을 더하고 Y 좌표는 20 만큼 감한 위치를 잡아 발사 위치로 잡는다. 그리고 Score를 1점 가산한다. 아울러 Clock1에서는 우주선의 폭의 반만큼 좌우 양측경계에서 우주선까지의 거리를 감안하면 캔바스 폭에서 우주선의 폭만큼 감하면 되며 이 범위를 대상으로 우주선의 위치를 게임자가 감을 잡을 수 없도록 난수를 사용하여 설정한다.  마지막으로 RESET 버튼을 누르면 SCORE가 0으로 재설정된다. 블록 편집을 빠져나와 저장 후 QR 코드를 스캔하여 게임을 즐겨 보자.
author | codingart |
---|---|
permlink | 151-1 |
category | kr |
json_metadata | {"tags":["kr","kr-newbie","manamine","jjangjjangman","kr-dev"],"image":["https://cdn.steemitimages.com/DQmeCWm2BnqRQeNniWycpZTsqwfxXzwdnBhCzG8MAHn8MUJ/noname01.png","https://cdn.steemitimages.com/DQmRkBJfafj6oXmFhjxko5R49a2JdzdyPYrVp5hgBJkfWqZ/noname02.png","https://cdn.steemitimages.com/DQmak6UwJhEoa3x9XfdVeCLvzqsGGxcmnisVimFK1QgKTvs/noname03.png","https://cdn.steemitimages.com/DQmTMHvXGj7uGL9kqQkkLPwNqanUNM44pepBnQRtn1g4bjF/noname04.png","https://cdn.steemitimages.com/DQmaqFcHUyMLSjDQ6rW82P77F2KD1P4KTkWwNmtwwQW7rQZ/noname05.png","https://cdn.steemitimages.com/DQmTvq9v5svt4Zwsi37x1V7tsQ5LFtQRLFmz9cXWUXiG6cL/noname06.png"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-09-21 06:07:00 |
last_update | 2018-09-21 06:07:00 |
depth | 0 |
children | 2 |
last_payout | 2018-09-28 06:07:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 11.535 HBD |
curator_payout_value | 3.760 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,951 |
author_reputation | 41,833,111,979,966 |
root_title | "아두이노 코딩-151: 게임 스페이스 1 인베이더 앱인벤터 코딩" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 71,829,598 |
net_rshares | 11,413,034,574,691 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
wony | 0 | 232,134,538,538 | 30% | ||
snow-airline | 0 | 39,573,105,736 | 100% | ||
virus707 | 0 | 7,136,830,996,185 | 50% | ||
pje0807 | 0 | 2,202,419,340 | 98.56% | ||
bramd | 0 | 2,682,369,279,214 | 30% | ||
mishana | 0 | 11,390,393,014 | 60% | ||
ahn | 0 | 116,143,933,187 | 100% | ||
papasmf1 | 0 | 924,947,350 | 100% | ||
wisdomandjustice | 0 | 204,262,951,883 | 21% | ||
beetlevc | 0 | 629,432,351 | 1% | ||
andrey915 | 0 | 463,538,201 | 100% | ||
ldv977 | 0 | 462,911,176 | 100% | ||
vladser58 | 0 | 463,966,127 | 100% | ||
devnboost | 0 | 764,632,647 | 100% | ||
pairplay | 0 | 922,544,335,441 | 44% | ||
karapetyang | 0 | 464,317,716 | 100% | ||
shtotomoda | 0 | 463,401,696 | 100% | ||
danielyana | 0 | 462,394,201 | 100% | ||
vorovskoy44 | 0 | 462,085,066 | 100% | ||
greeglofchik | 0 | 463,241,520 | 100% | ||
judiciouscable | 0 | 462,897,982 | 100% | ||
codingart | 0 | 7,764,855,548 | 100% | ||
bouquetclick | 0 | 463,028,474 | 100% | ||
upperhostler | 0 | 463,402,545 | 100% | ||
dusterdeciles | 0 | 461,625,328 | 100% | ||
payslipsitaly | 0 | 463,622,223 | 100% | ||
habitroof | 0 | 463,191,298 | 100% | ||
buddingcaviar | 0 | 462,381,729 | 100% | ||
kiraluchkova | 0 | 462,633,255 | 100% | ||
lenalidchyk63 | 0 | 462,142,995 | 100% | ||
lippedpython | 0 | 463,432,316 | 100% | ||
pumpdyke | 0 | 464,218,768 | 100% | ||
bolttrite | 0 | 463,361,639 | 100% | ||
kitgoody | 0 | 463,647,897 | 100% | ||
pointsbee | 0 | 462,933,415 | 100% | ||
googoltailored | 0 | 462,712,895 | 100% | ||
blandstatics | 0 | 462,614,417 | 100% | ||
marcatounique | 0 | 463,253,642 | 100% | ||
ikudelin | 0 | 463,418,082 | 100% | ||
shukinsanechek | 0 | 463,232,385 | 100% | ||
thrufore | 0 | 463,343,123 | 100% | ||
buglife | 0 | 40,214,548,498 | 100% | ||
ecotypedatabase | 0 | 463,508,812 | 100% | ||
englishbracket | 0 | 463,236,874 | 100% | ||
arkoseduration | 0 | 462,989,351 | 100% | ||
terminatorcamel | 0 | 464,766,805 | 100% | ||
meaninglathered | 0 | 462,753,806 | 100% |
This is great! Do you share your posts on twitter? I think that is one of the best ways to get more exposure. @steemengineteam has a great tool for autoposting steemit articles to twitter.
author | bemotivated |
---|---|
permlink | re-151-1-20180921t060802 |
category | kr |
json_metadata | "" |
created | 2018-09-21 06:08:03 |
last_update | 2018-09-21 06:08:03 |
depth | 1 |
children | 0 |
last_payout | 2018-09-28 06:08:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 190 |
author_reputation | -3,951,644,073,249 |
root_title | "아두이노 코딩-151: 게임 스페이스 1 인베이더 앱인벤터 코딩" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 71,829,655 |
net_rshares | -10,002,956,536 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
mack-botjr | 0 | -10,002,956,536 | -0.5% |
pairplay 가 kr-dev 컨텐츠를 응원합니다! :)
author | pairplay |
---|---|
permlink | re-codingart-151-1-20180922t003518266z |
category | kr |
json_metadata | "" |
created | 2018-09-22 00:35:21 |
last_update | 2018-09-22 00:35:21 |
depth | 1 |
children | 0 |
last_payout | 2018-09-29 00:35:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 32 |
author_reputation | 49,450,702,071,116 |
root_title | "아두이노 코딩-151: 게임 스페이스 1 인베이더 앱인벤터 코딩" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 71,900,661 |
net_rshares | 0 |