Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pygameを用いてGUIを #2

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions GUI/build/exe.win32-2.7/IPAexfont/IPA_Font_License_Agreement_v1.0.txt

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions GUI/build/exe.win32-2.7/IPAexfont/Readme_IPAexfont00201.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
IPAex�t�H���g
�\ �͂��߂ɂ��ǂ݂������� �\

IPAex�t�H���g�́AJIS X 0213:2004�ɏ�������TrueType�A�E�g���C���x�[�X��OpenType�t�H���g�ł��B

IPAex�t�H���g�̎g�p�܂��͗��p�ɓ������ẮA�Y�t�́uIPA�t�H���g���C�Z���Xv1.0�v�ɒ�߂�����ɏ]���Ă��������B
IPAex�t�H���g���g�p���A�������A�܂��͔Еz����s�ׁA���̑��A�uIPA�t�H���g���C�Z���Xv1.0�v�ɒ�߂錠���̗��p���s�����ꍇ�A��̎҂́uIPA�t�H���g���C�Z���Xv1.0�v�ɓ��ӂ������̂ƌ��Ȃ��܂��B


IPAex�t�H���g2���̃p�b�N�iIPAex�S�V�b�N�AIPAex�����j IPAexfont00201.zip
|--�͂��߂ɂ��ǂ݂������� Readme_IPAexfont00201.txt
|--IPA�t�H���g���C�Z���Xv1.0 IPA_Font_License_Agreement_v1.0.txt
|--IPAex�S�V�b�N(Ver.002.01) ipaexg.ttf
|--IPAex����(Ver.002.01) ipaexm.ttf


�uIPA�t�H���g�v�́AIPA�̓o�^���W�ł��B

=========================
IPAex Font
-- Readme --

IPAex Fonts are JIS X 0213:2004 compliant OpenType fonts based on TrueType outlines.

In using IPAex fonts, please comply with the terms and conditions set out in "IPA Font License Agreement v1.0" included in this package.
Any use, reproduction or distribution of the IPA Font or any exercise of rights under "IPA Font License Agreement v1.0" by a Recipient constitutes the Recipient's acceptance of the License Agreement.


IPAex Fonts 2 fonts package �iIPAex Gothic�AIPAex Mincho�j IPAexfont00201.zip
|--Readme Readme_IPAexfont00201.txt
|--IPA Font License Agreement v1.0 IPA_Font_License_Agreement_v1.0.txt
|--IPAexGothic(Ver.002.01) ipaexg.ttf
|--IPAexMincho(Ver.002.01) ipaexm.ttf


"IPA Font" is a registered trademark of IPA in Japan.
Binary file added GUI/build/exe.win32-2.7/IPAexfont/ipaexg.ttf
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/IPAexfont/ipaexm.ttf
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/SDL.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/SDL_image.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/SDL_mixer.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/SDL_ttf.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/_ctypes.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/_hashlib.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/_multiprocessing.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/_socket.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/_ssl.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/bz2.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/build/exe.win32-2.7/image/bgimg_story1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/build/exe.win32-2.7/image/bgimg_title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/build/exe.win32-2.7/image/game_start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/build/exe.win32-2.7/image/game_start1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/build/exe.win32-2.7/jpeg.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/libfreetype-6.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/libogg-0.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/libpng12-0.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/library.zip
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/libtiff.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/libvorbis-0.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/libvorbisfile-3.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/print.exe
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pyexpat.pyd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.base.pyd
Binary file not shown.
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.cdrom.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.color.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.constants.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.display.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.draw.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.event.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.fastevent.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.font.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.image.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.imageext.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.joystick.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.key.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.mask.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.mixer.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.mixer_music.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.mouse.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.movie.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.overlay.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.pixelarray.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.rect.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.rwobject.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.scrap.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.surface.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.surflock.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.time.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/pygame.transform.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/python27.dll
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/select.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/smpeg.dll
Binary file not shown.
1 change: 1 addition & 0 deletions GUI/build/exe.win32-2.7/sound/mp3/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mp3は TAM Music Factory "http://www.tam-music.com/"さんよりお借りしました。
Binary file added GUI/build/exe.win32-2.7/sound/mp3/bgm1.mp3
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/sound/mp3/bgm_title.mp3
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/sound/mp3/tam-y09.mp3
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/sound/mp3/tam-y10.mp3
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/sound/mp3/tam-y18.mp3
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/sound/mp3/tam-y23.mp3
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/sound/mp3/tamhe08rm.mp3
Binary file not shown.
80 changes: 80 additions & 0 deletions GUI/build/exe.win32-2.7/story.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
 ==================================
Episode 1: 勇者の旅立ち
==================================
---- 世界では・・・・・・ ---------------------------------------------
2年前に復活した魔王によって、世界は滅びようとしていた。
各国は魔王討伐のために軍隊を向かわせたが、魔王軍の前ではどうにもならず、
ひとつひとつと国が滅ぼされ、このまま世界は滅ぼされると思われた。
最後の望みとして、パラパッパラ国の国王は古に伝わる”伝説の勇者”を探し出し、
その者に魔王討伐を託すことにした。
--------------------------------------------------------------------------

- - - - - - パラパッパパ村の %s の家 - - - - - -
%s は目が覚めた。窓から入ってくる太陽の光がまぶしい。
ベットから降りて、ひとつ伸びをする。
今日は何か楽しいことが起きる、そんな予感がしていた。
と、そのとき、誰かが %s を呼ぶ声が聞こえた......

誰が呼んでいるか[選択]

1: 母
2: 愛猫のミケ
3: ゴット竹中
4: となりの山田さん

呼んでいるのは母のようだ。
母「朝ごはんできてるから、早く食べてよ」
テーブルの上にはおいしそうなパンとスープ、サラダがある。
いただきます、とさっそくスープを口に運ぶ。
一口食べた瞬間、激痛が体中を走る。
!!!!! 毒だ!!!!!

ゴット竹中「あなたは神を信じますか?
信じているならあなたは救われる。
信じていないなら地獄に落ちろ!!!」
/*
\n呼んでいるのは父のようだ。
父「まき割りを手伝ってくれないか」
まきを割るために家の裏に向かった。
いつものように斧を使ってまきを割る。
しかし、まきを割ろうとした瞬間、まきがはじけ飛んだ!!
!!!!! 痛い !!!!!
*/
呼んでいるのは愛猫のミケのようだ。
ミケ「・・・・・・にゃー」
・・・・・・なごむ。

呼んでいるのはとなりの山田さんのようだ。
%s 「こんにちは!!山田さん、どうしたんですか。
山田さん・・・? 黙ったままで、何かあったんですか?」
山田さん「・・・・・・フフフ・・・フハハハハハハハハハハハッ!!!」
%s 「なんですか!? どうしたんですか!?!?」
山田さん「!!!!!私が魔王だ!!!!!」
%s 「な、なんだって!?!?」
山田さん「!!!!!世界はもらっていくぞ!!!!!」
%s 「!!!!!そうはさせないっ!!!!!」
!!!山田さんとの戦闘に突入!!!

タケオ「おーい!! 起きてるかーーっ!!!」
親友のタケオの呼ぶ声がする。こんなに朝早くに来るなんて珍しい。
タケオ「知ってるか!!!魔王を倒せるのは”伝説の勇者”だけなんだってよ!!!
"伝説の勇者"って、%s のことだよな!?」

あなたの返事は? [選択]

1,もちろん、そうだよ。
2,そんなわけない。
3,”伝説の勇者”、それはタケオ、お前のことだ!!!

タケオ「やっぱりそうか。いや、ずっと前から分かっていたんだ。
お前が勇者だってことはよ。
だって俺も勇者だからな!!!」
%s 「なんだって!?!?」
タケオ「勇者は一人だけでいい・・・・・・
つまり俺かお前か、どちらかが勇者として魔王を討ちに行く。
だからどちらが本当の勇者か、決めなきゃなんねぇ。
勝負だ!! %s!!」

タケオ「・・・・・・そうか。

タケオ「!?!? やっぱり気づいてたのか!!\n");
Binary file added GUI/build/exe.win32-2.7/unicodedata.pyd
Binary file not shown.
Binary file added GUI/build/exe.win32-2.7/zlib1.dll
Binary file not shown.
Binary file added GUI/game2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/image/bgimg_story1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/image/bgimg_title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/image/game_start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/image/game_start1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GUI/image/game_start2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
172 changes: 149 additions & 23 deletions GUI/print.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,180 @@
from pygame.locals import * # constant value of pygame
import sys
import codecs
import os

if os.name == 'nt':
# In Windows
import ctypes
elif os.name == 'posix':
# In Linux, Macos
pass

class Game(object):
def __init__(self):
title = 'Game!!'
title = '勇者の旅立ち'
pygame.display.set_caption(title)
# setup font
self.font_size = 18 # default font size
self.f_serif = pygame.font.Font("IPAexfont/ipaexm.ttf", self.font_size)
self.f_sans_serif = pygame.font.Font("IPAexfont/ipaexg.ttf", self.font_size)
self.pos_y = 0

def main(self, screen):
self.screen = screen
self.pos_msg_y = 0

def main(self, screen_size):
f_screen_full = False
self.screen_x = 640
self.screen_y = 480
clock = pygame.time.Clock()
self.screen = pygame.display.set_mode((self.screen_x, self.screen_y))
self.screen.fill((255, 255, 255))
self.print_font("Welcome to Gaming world!")
self.file_story = codecs.open("story.txt", "r", "utf-8")

self.load_img_title()
self.load_img_gamestart()
self.play_bgm_title()

story = 0 # 0 is title screen
f = 0
interval = 0

while True:
time = clock.tick(60) # 60 fps
time_s = time / 1000.0
pygame.display.update()
for event in pygame.event.get():
if event.type == QUIT:
#sys.exit()
return
sys.exit()
#return
elif event.type == pygame.KEYDOWN and \
event.key == pygame.K_ESCAPE:
#sys.exit()
return
sys.exit()
#return
elif event.type == pygame.KEYDOWN and \
event.key == pygame.K_F2:
# フルスクリーンとウィンドウを F2キーで切り替え
f_screen_full = not f_screen_full
if f_screen_full == True:
self.screen = pygame.display.set_mode(screen_size, FULLSCREEN)
self.screen_x = screen_size[0]
self.screen_y = screen_size[1]
else:
self.screen = pygame.display.set_mode((640, 480))
self.screen_x = 640
self.screen_y = 480
#self.screen.fill((255, 255, 255))
elif event.type == pygame.KEYDOWN and \
event.key == pygame.K_RETURN:
self.puts_message()
if story == 0:
story += 1
self.play_bgm_game()
self.load_img_story1()
self.make_msgarea()
elif story == 1:
self.puts_message()

if story == 0:
interval += time_s
if interval >= 0.7 and f == 0:
interval = 0
self.load_img_title()
f = 1
elif interval >= 0.2 and f == 1:
interval = 0
self.load_img_gamestart()
f = 0

self.file_story.close()

def print_font(self, string, color = (0, 0, 0)):

# screen
def make_msgarea(self):
screen_size = self.screen.get_size()
self.msgarea_size = (screen_size[0] / 5 * 4, 18 * 5) #screen_size[1] / 4)
self.msgarea = pygame.Surface(self.msgarea_size)
self.msgarea.fill((0, 100, 0))
pos = (screen_size[0] - (int(screen_size[0] * 0.9)), screen_size[1] - (int(screen_size[1] * 0.2)))
self.screen.blit(self.msgarea, pos)
#self.msgarea = msg

# print
def print_font_free(self, string, color = (0, 0, 0), size = 18, bgcolor = (255, 255, 255)):
pos = (0, self.pos_y)
text = self.f_sans_serif.render(string, True, color)
f_sans_serif = pygame.font.Font("IPAexfont/ipaexg.ttf", size)
if bgcolor == (255, 255, 255):
text = f_sans_serif.render(string, True, color)
else:
text = f_sans_serif.render(string, True, color, bgcolor)
self.screen.blit(text, pos)
pygame.display.update()
self.pos_y += self.font_size
self.pos_y += size
y = self.screen.get_size()
if self.pos_y > y[1]:
self.pos_y = 0

def print_font(self, string, color = (0, 0, 0), size = 18, bgcolor = (255, 255, 255)):
""" print to message area """
if self.msgarea == None:
return
pos = (430, 200)
pos_msg = (0, self.pos_msg_y);
f_sans_serif = pygame.font.Font("IPAexfont/ipaexg.ttf", size)
if bgcolor == (255, 255, 255):
text = f_sans_serif.render(string, True, color)
else:
text = f_sans_serif.render(string, True, color, bgcolor)

self.msgarea.blit(text, pos_msg)
screen_size = self.screen.get_size()
pos = (screen_size[0] - (int(screen_size[0] * 0.9)), screen_size[1] - (int(screen_size[1] * 0.2)))
self.screen.blit(self.msgarea, pos)
self.pos_msg_y += size
if (self.pos_msg_y + size) >= self.msgarea_size[1]:
self.msgarea.scroll(0, -18)
self.pos_msg_y -= size

def puts_message(self):
str = self.file_story.readline()
str = str.replace("\n", "")
str = str.replace("\r", "")
str = str.replace("\t", " ")
self.print_font(str)
self.print_font(str, (0, 0, 0))

# sound
def play_bgm_game(self):
pygame.mixer.music.load("sound/mp3/bgm1.mp3")
pygame.mixer.music.play(-1)

def play_bgm_title(self):
pygame.mixer.music.load("sound/mp3/bgm_title.mp3")
pygame.mixer.music.play(-1)

# image
def load_img_title(self):
bgimg = pygame.image.load("image/bgimg_title.png").convert()
self.screen.blit(bgimg, (0, 0))
pygame.display.update()

def load_img_gamestart(self):
msgimg = pygame.image.load("image/game_start2.png").convert_alpha()
x = ( self.screen_x - msgimg.get_size()[0] ) / 2
y = ( self.screen_y - msgimg.get_size()[1] ) / 2
self.screen.blit(msgimg, (x, y))
pygame.display.update()

def load_img_story1(self):
img = pygame.image.load("image/bgimg_story1.png").convert()
self.screen.blit(img, (0, 0))
pygame.display.update()


def get_screen_size():
if os.name == 'nt': #Windows
user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
elif os.name == 'posix': #Linux
screensize = 640, 480
else:
screensize = 640, 480
return screensize

### ----------- main ----------- ###
if __name__ == '__main__':
screen_size = (640, 480)
pygame.init()
screen = pygame.display.set_mode(screen_size)
f_screen_size = get_screen_size()
game = Game()
game.main(screen)
game.main(f_screen_size)
14 changes: 14 additions & 0 deletions GUI/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import sys
from cx_Freeze import setup, Executable

includes = ["pygame", "sys",]

base = None
if sys.platform == "win32":
base = "Win32GUI"

setup( name = "Yusha",
version = "0.0.1",
options = {"build_exe" : {"includes" : includes }},
executables = [Executable("print.py", base=base)])
1 change: 1 addition & 0 deletions GUI/sound/mp3/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mp3は TAM Music Factory "http://www.tam-music.com/"さんよりお借りしました。
Binary file added GUI/sound/mp3/bgm1.mp3
Binary file not shown.
Binary file added GUI/sound/mp3/bgm_title.mp3
Binary file not shown.
Binary file added GUI/sound/mp3/tam-y09.mp3
Binary file not shown.
Binary file added GUI/sound/mp3/tam-y10.mp3
Binary file not shown.
Binary file added GUI/sound/mp3/tam-y18.mp3
Binary file not shown.
Binary file added GUI/sound/mp3/tam-y23.mp3
Binary file not shown.
Binary file added GUI/sound/mp3/tamhe08rm.mp3
Binary file not shown.
Loading