ã¿ã¼ããã«ç»é¢ã§ç¹ãæããç·ãå¼ãã
ã¯ããã«
ããã¾ã§åãã¡ã¯ãCCã®ã¿ã¼ããã«ç»é¢ï¼ã³ã³ãã¥ã¼ã¿ãã¿ã¼ãã«ãå³ã¯ãªãã¯ãã¦è¡¨ç¤ºãããç»é¢ï¼ãå¤ä»ãã®ã¢ãã¿ã使ã£ã¦ãæåã表示ãã¦ãã¾ããã
ä»åã¯ãããã®ä¸ã§ç¹ãæããç·ãå¼ãæ¹æ³ã«ã¤ãã¦å¦ã³ã¾ãããã
è²ã使ãã¾ãã®ã§ãAdvanced ComputerãAdvanced Monitorãå¿
è¦ã§ãã
è²ã使ããªãéè²ã¨è¦ãã¦ããã¾ãããã
ã¿ã¼ããã«ç»é¢ã§ç¹ãæã
ã¾ãã¯éè²ã®Advanced Computerãç¨æãã¾ãããã
å³ã¯ãªãã¯ã§è¡¨ç¤ºãããã¿ã¼ããã«ç»é¢ä¸ã§èµ¤ãç¹ãæç»ãã¾ãã
ãeditãã³ãã³ãã使ããªããã¦æ¬¡ã®ããã°ã©ã ãå ¥åããå®è¡ãã¦ã¿ã¾ãããã
term.setBackgroundColor(colors.red)
term.write(" ")
ããã¯ãèæ¯è²ã赤ã«ããç»é¢ä¸ã«åè§ã¹ãã¼ã¹ã表示ãã¦ãã¾ãã
ã¤ã¾ã空ç½ã表示ãããã¨ã§èæ¯è²ã®èµ¤ãåé¢ã«è¦ãã¦ããããã§ããã
ãªãããã§ã¯èµ¤è²ã使ãã¾ããããComputerCraftã§ã¯è¨16è²ã®è²ã使ãã¾ãã詳ããã¯ä»¥ä¸ãåç
§ã®ãã¨ã
ç»é¢ä¸ã§ã¯ä»¥ä¸ã®ããã«å·¦ä¸ã®ä½ç½®ã«èµ¤ãç¹ï¼ã¨ããããå°ãã ãé·æ¹å½¢ï¼ã表示ããã¦ãã¾ãã
ã¾ããç¹ã®ããå¾ãã®ä½ç½®ã«ã«ã¼ã½ã«ã移åãç¹æ»
ãã¦ãã¾ãããããã¯term.write()ã§æåã表示ããã®ã§ãããæ£å¸¸ãªåãã§ãã
ãã¤ã¯ããããComputerCraftã«ãããç¹ã®æç»ã§ãã
ãã以ä¸ãå°ããªç¹ã¯æã¦ã¾ããã
ããçµµãæããªãã°ããã®ç¹ãæå°ã®åä½ã¨ãã¦ãçµã¿ç«ã¦ã¦ãããªãã¦ã¯ãªãã¾ããã
ãã¦ããã®ã¾ã¾ã ã¨ç»é¢ã«èµ¤ãç¹ãæ®ã£ãã¾ã¾ã§ãããç¹æ»
ã«ã¼ã½ã«ã®ä½ç½®ãä¸éå端ã§ããã
å
ã«æ»ãã«ã¯ããã¤ãã®æ¹æ³ãããã¾ããããã£ã¨ãåç´ãªã®ã¯CCã³ã³ãã¥ã¼ã¿ããªã»ãããããã¨ã§ãã
ãªã»ããããã«ã¯ãCTRL+Rããã¼ããã°ããæ¼ãã£ã±ãªãã§ãããã
ã¿ã¼ããã«ç»é¢ã®ç»ç´ æ°ã調ã¹ã
次ã«ã以ä¸ã®ããã°ã©ã ãæ¸ãã¦å®è¡ãã¾ãããã
w, h = term.getSize() print(w,' ',h)
å®è¡çµæã¯ãã51 19ãã¨è¡¨ç¤ºããã¾ãã
ãterm.getSize()ãé¢æ°ã¯ãã¿ã¼ããã«ç»é¢ã®ãµã¤ãºãè¿ãã¾ããè¿å¤ã¯2åãããããããå¹ ã¨é«ããè¿ãã¾ããLuaã®ææ³ã«ãããå¤éä»£å ¥ãã¤ã¾ãå¤æ°wã«å¹ ãå¤æ°hã«é«ããä»£å ¥ãã¦ãã¾ãã
ãã®ãã¨ãããã¿ã¼ããã«ç»é¢ã¯å¹
51ãé«ã19ãã使ããªããã¨ããããã¾ãã
è¨ãæããã¨ããã®ã¿ã¼ããã«ç»é¢ã®è§£å度ã¯51x19ã§ããããã®ã¿ã¼ããã«ç»é¢ã§çµµãæããã¨æã£ããã51x19=969åã®ç¹ï¼ããã¦16è²ã®è²åãï¼ãã使ããªããã¨ã«ãªãã¾ãã
ä»»æã®ä½ç½®ã«ç¹ãæã
ã§ã¯ãä»»æã®ä½ç½®ã«ç¹ãæã£ã¦ã¿ã¾ãããã
term.setCursorPos(10,10) term.setBackgroundColor(colors.red) term.write(" ")
- ã«ã¼ã½ã«ã®ä½ç½®ã座æ¨ï¼10,10ï¼ã«ç§»å
- èæ¯è²ã赤ã«ãã
- 空ç½ã表示ãããã¨ã§èæ¯è²ã®èµ¤ãæã
ããã»ã©èª¿ã¹ãããã«ãã¿ã¼ããã«ç»é¢ã®å¹
ã¨é«ãã¯51x19ã§ãã座æ¨(1,1)ãã(51,19)ã¾ã§ã®ç¯å²ã§èªç±ã«ç¹ãæã¤ãã¨ãã§ãã¾ãã
ããã§æ³¨æãããã®ã¯ãç¹ãæã£ããã¨ãã«ã¼ã½ã«ä½ç½®ããã®ããå¾ãï¼ä»åã¯ã(11,10)ï¼ã«ç§»åãã¦ãããã¨ã§ãããããå©ç¨ããã¨æ¨ªç·ãæãã®ãã¨ã¦ãç°¡åã«ãªãã¾ãã
横ç·ãå¼ã
座æ¨ï¼2,2)ãã(11,2)ã¾ã§é·ã10ã®æ¨ªç·ãå¼ãã¦ã¿ã¾ãããã
ããã°ã©ã ã¯ä»¥ä¸ã®ã¨ããã§ãã
term.setCursorPos(2,2) term.setBackgroundColor(colors.red) for x=2,11 do term.write(" ") end
空ç½ã¹ãã¼ã¹ã表示ãããã³ã«ã«ã¼ã½ã«ä½ç½®ãã©ãã©ã横ã«ç§»åãã¦ããã®ã§ã
åç´ã«åº§æ¨(2,2)ãã10åã®ç©ºç½ã¹ãã¼ã¹ã表示ããã°ããã§ãããã
縦ç·ãå¼ã
縦ç·ã®ã¨ãã¯ã横ç·ã®ããã«ç°¡åã«ã¯ããã¾ããã
æ¯åãã«ã¼ã½ã«ä½ç½®ã移åããªãã¦ã¯ãªãã¾ãããã
以ä¸ã¯ã座æ¨(2,2)ãã(2,11)ã¾ã§é·ã10ã®ç¸¦ç·ãå¼ãã¾ãã
term.setBackgroundColor(colors.red) for y=2,11 do term.setCursorPos(2,y) term.write(" ") end
æ£æ¹å½¢ï¼ï¼ï¼ãæã
縦ç·ã横ç·ãæããã¨ãã§ãããªããããããå©ç¨ãã¦åè§å½¢ãæããã¨ãã§ãã¾ãã
å·¦ä¸ã®å§ç¹ï¼2,2ï¼ãå³ä¸ã®çµç¹ï¼11,11ï¼ã¨ããä¸è¾ºã10ã®æ£æ¹å½¢ãæãã¦ã¿ã¾ãããã
ã¨ãããã2ã¤ã®ããã°ã©ã ãç´¹ä»ãã¦ã¿ã¾ãã
term.setBackgroundColor(colors.red) for y=2,11 do term.setCursorPos(2,y) for x=2,11 do term.write(" ") end end
ã¾ãã¯ãã®ããã°ã©ã ã
ãã¡ãã¯ãå
ã«ç´¹ä»ãã横ç·ããã°ã©ã ï¼1ã¤æ¸ãè¾¼ãã ãã«ã¼ã½ã«ãå³ã«1ã¤ããããï¼ãå©ç¨ããããã°ã©ã ã§ããã«ã¼ã½ã«ä½ç½®ãå¤ããã®ã¯ãy座æ¨ãå¤ããã¨ãã ãã
ã¤ã¾ããä¸çªå·¦å´ã®åº§æ¨ã«ã«ã¼ã½ã«ç§»åï¼setCursorPos()ï¼ãããã¦10åã®ç©ºç½ã表示ã¨ããæµããç¹°ãè¿ãã¾ãã
次ã«ãã¡ãã®ããã°ã©ã ã
term.setBackgroundColor(colors.red) for y=2,11 do for x=2,11 do term.setCursorPos(x,y) term.write(" ") end end
ãã¡ãã®è¶£æ¨ãç°¡åã«è¨ãã¨ã
ãã«ã¼ã½ã«ã横ã«1ã¤ãããã¨ãæ°ã«ããªããã¨ã«ããæç»ããã座æ¨ã«æ¯åã«ã¼ã½ã«ã移åãããã
ã¨ããããã°ã©ã ã§ããå¹çã§è¨ãã¨å
ã®ããã°ã©ã ããã¯è½ã¡ãããããã¾ãããã大ãããã¹ã§ã¯ããã¾ãããã
ã©ã¡ãã使ããã¯å¥½ã¿ã®åé¡ã§ãããå人çã«ã¯ãé£ãããã¨èããã«æ¸ãå¾è ã®ãæ°ã«ããæ¯åã«ã¼ã½ã«ç§»åãããã°ã©ã ã§è¯ãã¨æãã¾ãã
ãã®ããã°ã©ã ã§æç»ããã10x10ã®æ£æ¹å½¢ã¯ãã¡ãã§ãã
â¦â¦ããããããªãã§ãããããæ£æ¹å½¢ãããªãã§ãããã
ã§ãããã¯ä»æ¹ãªãã®ã§ããã
ã ã£ã¦ã1ã¤ã®ç¹ãæããæç¹ã§ç¸¦é·ã®é·æ¹å½¢ã ã£ããããªãã§ããããããçµã¿ç«ã¦ã¦ä½ã£ãåè§å½¢ããã¯ãé·æ¹å½¢ã«ãªã£ã¦ãã¾ãã®ã§ãã
ãã¦ãããç¡çããæ£æ¹å½¢ã«ãã¦ãã¾ãã¾ãããã
1ã¤ã®ç¹ãèããã¨ãããã®ç¸¦é·ã®é·æ¹å½¢ã¯ã横ï¼ç¸¦ ï¼ ï¼ï¼ï¼ = ï¼ï¼1.5 ãã®æ¯çã«ãªã£ã¦ãã¾ãã
ã¤ã¾ã縦ã®æ¹ãé·ãã横ã®1.5åã«ãªã£ã¦ãã¾ãã
ãã®ããã使ãç¹ã®æ°ããã®æ¯çã«åããã¦è¨ç®ãã¦ãã¾ãã°ããã®ã§ãã
ãã¨ãã°æ¨ªæ¹åã®è¾ºã®é·ã15ï¼åã®ç¹ï¼ã絶対ã¨èãã¦æ£æ¹å½¢ãæããªãã°ã
縦æ¹åã¯ãã®3åã®2ã«ãã¦ãã¾ãã°ããã®ã§ããã¤ã¾ã縦æ¹åã¯15*2/3=10ï¼åã®ç¹ï¼ã§ãã
term.setBackgroundColor(colors.red) for y=2,11 do --2ãã11ã¾ã§ã®10åç¹°ãè¿ã for x=2,16 do -- 2ãã16ã¾ã§ã®15åç¹°ãè¿ã term.setCursorPos(x,y) term.write(" ") end end
ãï¼æ£æ¹å½¢ã§ããï¼
ç¹ã®ç¸¦æ¨ªæ¯ã«ã¤ãã¦ã®è£è¶³
ã横ï¼ç¸¦ï¼ï¼ï¼ï¼ãã¨ããã¾ããããå³å¯ã«è¨ãã¨ãç¹ãæãå ´æã«ãã£ã¦ç¸¦æ¨ªæ¯ãç°ãªãã¾ãã
ä¸å³ã®9ç®æã®ç¹ãè¦ãã¨ãããããã«ãç¹ãæãå ´æã«ãã£ã¦ç¸¦æ¨ªæ¯ãç°ãªã£ã¦ããããã«è¦ãã¾ãã
ããã§ãã¹ã¯ãªã¼ã³ã·ã§ãããæ¡å¤§ãã¦åç¹ãããã¤ã®ãããããæ§æããã¦ãããæ°ãã¦ã¿ã¾ããã
- æå·¦ä¸(1,1) â 16x22 = (12+4)x(18+4)
- æå·¦ä¸(1,10)â 16x18 = (12+4)x18
- æå·¦ä¸(1,19)â 16x22 = (12+4)x(18+4)
- ä¸å¤®ä¸(5,1)â 12x22 = 12x(18+4)
- ä¸å¤®ä¸(5,10)â 12x18ï¼åºæºï¼
- ä¸å¤®ä¸(5,19)â 12x22 = 12x(18+4)
- æå³ä¸(51,1)â 16x22 = (12+4)x(18+4)
- æå³ä¸(51,10)â16x18 = (12+4)x18
- æå³ä¸(51,19)â16x22 = (12+4)x(18+4)
åºæºã¨ãªãã®ã¯5çªç®ã®ç¹ï¼5,10ï¼ã§ãããã®ç¹ã®ããã«ç»é¢ç«¯ã«é£æ¥ãã¦ããªãç¹ã¯å¿
ã12ãããx18ãããã¨ãªã£ã¦ãã¾ãï¼ã¤ã¾ãã横ï¼ç¸¦ï¼ï¼ï¼ï¼ã§ãï¼ã
ããã«å¯¾ãã¦ãç»é¢ç«¯ã«é£æ¥ãã¦ããç¹ã¯ãã®é£æ¥ãã¦ããå´ã®ãµã¤ãºã4ãããå追å ããã¦ãã¾ãã
ï¼ä¾ï¼ï¼1çªç®ã®æå·¦ä¸ã®åº§æ¨(1,1)ã®ç¹ã¯å·¦å´ã¨ä¸å´ã®2ç®æãç»é¢ç«¯ã«é£æ¥ãã¦ããããã縦æ¹åã¨æ¨ªæ¹åã®ä¸¡æ¹ã+4ããã追å ããã¦(12+4)x(18+4)=16x22ãããã®é·æ¹å½¢ã«ãªã£ã¦ããï¼
ï¼ä¾ï¼ï¼2çªç®ã®æå·¦ä¸ã®åº§æ¨(1,10)ã®ç¹ã¯å·¦å´ã®ã¿ç»é¢ç«¯ã«é£æ¥ãã¦ããããã横æ¹åã®ã¿+4ããã追å ããã¦12+4=16ãããã¨ãªã£ã¦ããï¼
ã¤ã¾ãè¨ãæããã¨ãç»é¢ç«¯ã«ããç¹ã¯ã4ãããåã®å¹
ãé«ãã追å ããã¾ãã
å³ã§ç¤ºãã¨ã以ä¸ã®ããã«æ°´è²ã®ã©ã¤ã³ã«é£æ¥ããç¹ã«4ãããåã®è¿½å ãããã¾ãã
ä¾ãã°ä¸ã®å³ã§ãæ°´è²ã®ã©ã¤ã³ãåãé¤ãã赤ãåè§å½¢ã¯å
¨ã¦åã大ããã®12x18é·æ¹å½¢ã«ãªã£ã¦ããããã«è¦ãã¾ãããï¼
ãã£ã¦ãæ¬å½ã«æ£ç¢ºã«å³å¯ãªæ£æ¹å½¢ãæããããªãã°ãç»é¢ã«é£æ¥ããæ£æ¹å½¢ã¯é¿ããã»ããè¯ãã§ãããã
ãã®åã ãä½åãªè¨ç®ãå¿
è¦ã¨ãªãã¾ãã®ã§ã
æç»å 容ãå®å ¨æ¶å»ããããã°ã©ã
ãã¦ãæå¾ã«ã
æ¯åCCã³ã³ãã¥ã¼ã¿ããªã»ããããã®ãé¢åã§ãããæç»å
容ãå®å
¨æ¶å»ããããã°ã©ã ãç´¹ä»ãã¾ãããã
term.setBackgroundColor(colors.black) term.clear() term.setCursorPos(1,1)
- èæ¯è²ãé»ã«ãã
- ç»é¢ãæ¶å»ï¼æ£ç¢ºã«ã¯èæ¯è²ã§å ¨é¢ãå¡ãã¤ã¶ãï¼
- ã«ã¼ã½ã«ã®ä½ç½®ãå·¦ä¸ï¼1,1ï¼ã«ç§»å
ãã¤ã³ãã¯ãæåã«èæ¯è²ãé»(colors.black)ã«ãã¦ããããterm.clear()ãé¢æ°ãå®è¡ãããã¨ã§ããããããªãã¨ã寸åã§term.setBackgroundColor()ããè²ã§å¡ãæ¿ãããã¦ãã¾ãã¾ãï¼ãã¨ãã°ç´åã«èæ¯ã赤ã«æå®ãã¦ãããå
¨é¢ã赤ã«ãªãï¼ã
ããã§åã®è¯ãæ¹ã¯æ°ã¥ããã®ã§ã¯ãªãã§ãããããã¾ããã¨æã£ãããªããããããæ£è§£ã§ãã
term.claer()ã¯ãç»é¢å
¨ä½ããã¹ã¦ã®åº§æ¨ã空ç½ã¹ãã¼ã¹ã§ä¸æ¸ãããé¢æ°ã ã¨æããã¾ãï½ï½ï½
æ®å¿µãªããJavaå´ã®å¦çã ã¨æãããã®ã§ã½ã¼ã¹ãè¦ããã¨ã¯ã§ãã¾ããããããããééããªãã§ããããåæã§ããï¼P
ã§ããããæåã«èæ¯è²ãé»ã«æ»ãã¦ãããªãã¨ããã¾ããããç»é¢å
¨é¨ã«ç©ºç½ã¹ãã¼ã¹ãæãã®ã§ããããå¦çã«ãæéããããããã§ãã
term.claer()ãforæãªã©ã§é«éã«ç¹°ãè¿ãå®è¡ããã¨ç»é¢ãã¡ãã¤ãã®ã¯ãããåå ãªãã§ããã
ã¾ã¨ã
ã¿ã¼ããã«ç»é¢ã§çµµãæãããã®åºæ¬ç¥è
- è²ã使ããªãéè²ã³ã³ãã¥ã¼ã¿
- 赤ãç¹ãæããâãèæ¯è²ã赤ã«ãã¦ç©ºç½ã¹ãã¼ã¹ã表示
- ç»ç´ æ°ï¼term.size()
- ä»»æã®ä½ç½®ã«æããâãã«ã¼ã½ã«ã移åãããterm.setCursorPos(x,y)ã
- æå°åä½ã®ç¹ã®ç¸¦æ¨ªæ¯ãã3:2ãªã®ã§ãçµµãæãã¨ãã«ã¯ç¸¦æ¨ªã®æ¯çããããããè¨ç®ãããã¨
- ãã¨ãã°ã縦ã®é·ãã3åã®2ã«ãããªã©
- ç»é¢æ¶å»ã¯ãèæ¯è²ãé»ã«æ»ãã¦ãããterm.clear()ããè² è·é«ãã®ã§ä½¿ãæã¯æ°ãä»ãã¦ã