??====================================Author:YoungwookKim(Korean)========================================================================Contact:rumia0601@gmail.com========================================================================0??? ????? 0?? ??%? ======================================================================== tǤ??? 0???? GUI0??<??X? ??8? ====================================^? ? й???,?tnj???@? GUI|? 0??<?? ??.?Uֈה?,?tnj???@? 2D?? ??%?,??%? h??|? ????X??? 2DGUI|? 0??<?? ??.?? ???,CUIXֽ??? ?̹ 9??ה? ?t?l?X? printh?˜? inputh??@Ɣ? t?ļD? t?|? ??.????t?,?tnj???X? ?Ť? h??? print/inputh??|? ???XՔ????? ?,?????? ? ?Ŵ?X? 0??? ????? ??%?D? 0??Ɣ? ??? ? ?x?

HelloWorld!??

ȸ?? ?̳D??|? ??.(t? ?? ȸҔ? ?@? ? ??Ѭ??? .ttfU֥ǐ?|? ??ɔ? ?Ӹ? ?|?D? DՔ?? ??.)..image::Basic-ouput-sourcecode.png:class:inlined-right..code-block::python:linenos:importsys,pygamepygame.init()size=width,height=220,140speed=[2,2]black=0,0,0screen=pygame.display.set_mode(size)ball=pygame.image.load("Basic-ouput-sourcecode.png")ballrect=ball.get_rect()while1:foreventinpygame.event.get():ifevent.type==pygame.QUIT:sys.exit()ballrect=ballrect.move(speed)ifballrect.left<0orballrect.right>width:speed[0]=-speed[0]ifballrect.top<0orballrect.bottom>height:speed[1]=-speed[1]screen.fill(black)screen.blit(ball,ballrect)pygame.display.flip()..image::Bagic-ouput-result-screen.png:class:inlined-right..code-block::python:linenos:importsys,pygamepygame.init()size=width,height=220,140speed=[2,2]black=0,0,0screen=pygame.display.set_mode(size)ball=pygame.image.load("Bagic-ouput-result-screen.png")ballrect=ball.get_rect()while1:foreventinpygame.event.get():ifevent.type==pygame.QUIT:sys.exit()ballrect=ballrect.move(speed)ifballrect.left<0orballrect.right>width:speed[0]=-speed[0]ifballrect.top<0orballrect.bottom>height:speed[1]=-speed[1]screen.fill(black)screen.blit(ball,ballrect)pygame.display.flip()(HelloWorld?? ȸ?X? ???? T?ܴ@? ?‰? ????)1??ɬ? print(

HelloWorld!)?? D?X?t? ???? T?ܴ? d? ????X??.tǃ?@? GUIXֽ???

? MѤ¸Ҕ? ͌? 5?X? l?1? 1???(MѤ¸? ????,?Ӹ?,l?0?,????,???)|? ???0? L?8?t??.GUIXֽ??? ? MѤ¸Ҕ? 1?X? l?1? 1???(MѤ¸? ????)̹D? ??????,4?X? l?1? 1???t? ??? ? H?t??.?x??<??,#7X? pygame.display.set_caption(

HelloWorldProject)h?”? print(HelloWorldProject)h??@? ٳ|?? 0???D? ??.X???̹,t? h?? ?? 8?????@? ??????X? ?ij?? ??X??? ??

? 8?????t??.?? ?,4????|? ??%?X?0? ?t? ? ????T?ܴ? ?Ż??? ??1????|? XՔ??? ?? ???D? ????????.????T?ܴ?? 4?X? ????<?? ?? ??? ? ???.Header(#1-#2),Initial8?(#3-#12),Always8?(#13-#20),Event8?(#16-#19)? ????t??.Header?? ?,??ȴ?D? importXՔ? ????t? ?‰? ??.??0??? importpygame,sys?? m??? DՔ?X??.t? ?? ȸ?? ?tnj??? ?? ȸ?t?p?,???Ɛ?? ??????D? ??̸X?? ??D? L? ??̸???|? X?0? L?8???(?? ?? #19?? ? sys.exit()? ?‰? ??)????x? $???t? DՔ? ?Ŕ? ????? 8?l?t??.frompygame.localsimport*?? #17?? ?X? QUIT?@? ǩ?? ????D? ??? ??t? ????X?0? ?t? p?X? ?D???<?? DՔ?X??.Initial8?(4?? ???8? t??X? 8????)?? ?,??? ???? Ո?̹ ?0?T??p??? ???? h??? Ո?̹ 8֜? ??.??? ?????? ?@? ??? ????t? ?ų1?D? ??t?0? ?t? ?0?T? ??.?tnj???@? ?????? ????D? ????XՔ? T?$?? GUI??D? L?9??? ? H? ??.(????t????)X՘?X? ????@? R?,G?,B? 3?X? l?1? ?ƌ?|? ????.???? ? ???? ??”? red=(255,0,0)@? ?t? ??????|? ??.pygame.init()?? ?@? h?”? ????? ????`? h??|? ?t? ? ??? ^? ? ? 8֜????|? ??.(t? x?X? h???@? ????? ?? ?Xՠ??.)Always8?(4?? ???8?)?? ?,??? ???? Ĭ?? ??p?tǸ??p??? ???? h??? Ĭ?? 8֜? ??.(<?`?,p?t?8?t? ?ǔ? ???? p?t?t? ޹D? L?̹)pygame.display.update()|??? h?”? |???<?? ?x? ???/h??X? ?̬?? ]??? t????? 8֜????p?,t? h?”? ?̬?X? ????<??D? ??lа?(=??Ȳ0?)?? ??%?XՔ? h??t?0? L?8?t??.t? h??? Always8? ȹ??ɹ?? ?‰???? J?<?t?,??%???? T?t??? ???? ???? p?t?0?? ?? |?X?X??? JŔ? 8? ?? ??8? ? ???.(t? x?X? h???@? ????? ?? ?Xՠ??.)Event8?(??? tǤ???|? ??l?XՔ? ???8?)?? ?,??? tǤ???? ???X?t? t??? ?? ?̬?? t?踴????.pygame.event.get()h?”? Always8??? ? ???? tǤ????X? 0???D? ?X???.????? t? tǤ????@? ??ٳ?<?? ??? ??? ?<?? ?,? ??.??????,for-in8?D? ??t?,Always8??? ? ???? ??? tǤ????D? ?(??<?? ?̬?`? ? ??? (tǤ??? 0??).?|? 䴴? ?,#17-#19?? QUIT|??? tǤ???|? ?̬?X?? ???.t? tǤ???? ?Ҭ?p??t?,?tnj???t? ??̸ ? t??? ?¤??t? ??̸??? ??.(t? x?X? h???@? ????? ?? ?Xՠ??.)0??? ???t? ????? ???? ??X?t?,t? ????? |ǀ? h???D? ?Ȉ? ????X?t?

HelloWorld!? ??%???? `? ? ???.?????,MѤ¸?X? ?Ӹ?@? l?0?? ?t?8?|? ??.pygame.font.Font(HoonWhiteCatR,ttf,32)|??? #9X? h?”? ?ȴ??? tDŽ?X? ttf?|?? ?Ӹ?|? ?X?? l?0? (t? ???? 32)ij ???.t? h??X? ?X? ?@? myTextFont|???

????? ȥ?t? P????.????? myTextFont???X? render(

HelloWorld!,True,red,green)|??? #10X? h??X? ?X? ?D? myText|???

????? ȥ?t? P????.renderh?”? MѤ¸? ?????? ????D? ?`? ? ???.t? ????,MѤ¸?X? ????@? h?? ??,MѤ¸?? D?̲ l???X? ????@? ?]? ??t? ??.myText???X? get_rect()|??? #11X? h??X? ?X? ?D? myTextArea|??? ????? ȥ?t? P???p?,myTextArea?? MѤ¸?|? ??%?X?0? ?t? `??? ? l???D? X?????.get_rect()|??? h?”? MѤ¸?X? ?Ӹ? l?0?@? MѤ¸?X? 8?t?|? ?$?X??? ??? ?ɬ??? ???D? ?X???.̹}? myTextArea|??? ???X? center|??? d??? ???|? MѤ¸?? T?t? ??Y??? $ƌ?T? ????t?,(#12)MѤ¸?X? ?X?|? T?t? ??Y?<?? $ƌ? L? ? ???.X???̹ T?t? ??Y?D? ?Ż??? L?Dż? ? ??D?L???? ?,T?t?X? ȴ? l?0?|? ?t?|? ??.#8X? pygame.display.set_mode((640,480))h?”? ?΄??? (l?0?,????,?X? ???|? ??ɔ? ????t? display.updateh??? 8֜??t? ??$??ɔ? ???)|? ??1?X?? ?? l?0?|? 640x480<?? ???¨??.????t?,T?t?X? ??Y?@? (320,240)t??.T?t?X? ȴ? l?0?? U?? ??t?,}??X? Ĭ??̹ X?t? ??? ??X?X? ?X?|? ???`? ? ?nj? ??.(2DGUIt???? ??%???? ??? ??@? x,y1???D? ????)($?x???t? x???? l??,DŘ???t? y???? |?D? ?????t? H? ??.^? ? ? й? h???@? ??P? Initial8??? ?‰????|? XՔ? ???t??,Ƙ?X?t? t? ????@? ?????? ij? ??p?tǸ?? DՔ? ??0? L?8?t??.<?`?,fillh?˜? blith?”? h??X? ??1? L?8??? Always8??? ?‰? ??.#14X? fill(white)h?”? ?΄???|? ???(XՀ???)<?? D̰Ɣ? 0???D? ‰???.#15X? blit(myText,myTextArea)?? ??? ???(myText)|? ??? ?X?(myTextArea)?? ?????? 0???D? ‰???.blitt? fillt????? ‰????|? ??.??? ??t? ?΄????? ??$???? ??t?,?΄???X? ????<?@? display.updateh??? ?‰??t? ??%???? ??.tǃ?t? 20??ɬ? ????T?ܴ|? ?? $???t????.20??ɬ? ????T?ܴ X?? ??ٳ ?Ƭ?|? t?t?XՔ? p? ???t? $Ƙ? x????? ?? ??.X???̹,t? ????T?ܴ?? 4????|? ???X?p??? ??XՔ? ??@? ????? ??5??? J?D? ??t??.t? ????T?ܴX? 0??? ????? ??%?D? ?? 0??? ?Ĭ|? t?tՈ??t? йt??.??0??? ?̬? ???D? ???XՔ? ??@? ?Ũ?L???L? ?? ȸ??? ? ?ɉ? ? ??t??.<8?? T?ܴ>::importpygame,sys#1frompygame.localsimport*#2white=(255,255,255)#3red=(255,0,0)#4green=(0,255,0)#5pygame.init()#6pygame.display.set_caption("HelloWorldProject")#7myScreen=pygame.display.set_mode((640,480))#8myTextFont=pygame.font.Font("HoonWhitecatR.ttf",32)#9myText=myTextFont.render("HelloWorld!",True,red,green)#10myTextArea=myText.get_rect()#11myTextArea.center=(320,240)#12whileTrue:#13myScreen.fill(white)#14myScreen.blit(myText,myTextArea)#15foreventinpygame.event.get():#16ifevent.type==QUIT:#17pygame.quit()#18sys.exit()#19pygame.display.update()#20




Edit on GitHub