■ このスレッドは過去ログ倉庫に格納されています
【pygame】pythonでゲーム製作【ぱいがめ】
- 1 :名前は開発中のものです。:2005/09/13(火) 18:51:45 ID:dnfPM2vI.net
- オブジェクト指向スクリプト言語のpythonでゲーム作ろうぜ!!
- 321 :名前は開発中のものです。:2008/05/27(火) 00:36:29 ID:7kQ6fLoZ.net
- ネタ投下
ttp://icculus.org/pyddr/
- 322 :名前は開発中のものです。:2008/05/27(火) 01:53:25 ID:GoGc/+DU.net
- ありがとう
- 323 :名前は開発中のものです。:2008/06/02(月) 17:42:52 ID:cqNlW2zB.net
- pygame.font.fontでフォント作成しようとしているのだけど、StringIOやtarfile.extractfileとかを引数に割り当ててもエラーになってしまうんだけどなにかできる方法とかありますか?
fp = open(hogehoge,'rb')とかでfpを引数にする分には問題ないのだけど
- 324 :名前は開発中のものです。:2008/06/02(月) 19:21:36 ID:8Qz1LMxH.net
- StringIOをfpとして扱う方法があったような
- 325 :名前は開発中のものです。:2008/06/02(月) 19:27:06 ID:8Qz1LMxH.net
- 文字コードが合ってないんじゃないか?
- 326 :名前は開発中のものです。:2008/06/03(火) 01:19:32 ID:bgHBWqPe.net
- 単純に純正ファイルオブジェクトしか扱わないということでは
- 327 :名前は開発中のものです。:2008/06/03(火) 02:06:21 ID:uK0BObxI.net
- 質問者はソースを出すべきだと思う
- 328 :名前は開発中のものです。:2008/06/03(火) 02:10:44 ID:uK0BObxI.net
- pygame.font.SysFont
create a Font object from the system fonts
pygame.font.SysFont(name, size, bold=False, italic=False): return Font
Return a new Font object that is loaded from the system fonts.
The font will match the requested bold and italic flags.
If a suitable system font is not found this will fallback
on loading the default pygame font.
The font name can be a comma separated list of font names to look for.
pygame.font.Font
create a new Font object from a file
pygame.font.Font(filename, size): return Font
pygame.font.Font(object, size): return Font
Load a new font from a given filename or a python file object.
The size is the height of the font in pixels.
If the filename is None the Pygame default font will be loaded.
If a font cannot be loaded from the arguments given an exception will be raised.
Once the font is created the size cannot be changed.
Font objects are mainly used to render text into new Surface objects.
The render can emulate bold or italic features,
but it is better to load from a font with actual italic or bold glyphs.
The rendered text can be regular strings or unicode.
- 329 :323:2008/06/03(火) 11:39:19 ID:mLDxfbhh.net
- とりあえずこんな感じです
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import StringIO
import pygame
from pygame.locals import *
def main():
pygame.init() # pygameの初期化
screen = pygame.display.set_mode( (180, 180) ) # 画面を作る
pygame.display.set_caption('Hello pygame') # タイトル
fp = open(u'みかP.ttf', 'rb')
font = pygame.font.Font(fp, 24) # フォントを読み込む
text = font.render(u"日本語表示テスト", True, (255,255,255))
fp.close()
#ここの部分がエラー 下記はエラーメッセージ
#This application has requested the Runtime to terminate it in an unusual way.
#Please contact the application's support team for more information.
#
fp2 = open(u'みかP.ttf', 'rb')
buf = StringIO.StringIO(fp2.read())
buf.seek(0,0)
font2 = pygame.font.Font(buf, 24) # フォントを読み込む
text2 = font2.render(u"日本語StringIO", True, (255,255,255))
buf.close()
fp2.close()
- 330 :323:2008/06/03(火) 11:50:20 ID:mLDxfbhh.net
- while True:
screen.blit(text, (0,0)) # 文字を画面に貼り付ける
screen.blit(text2, (0,60))
pygame.display.flip() # 画面を反映
for event in pygame.event.get(): # イベントチェック
if event.type == QUIT: # 終了が押された?
return
if (event.type == KEYDOWN and
event.key == K_ESCAPE): # ESCが押された?
return
if __name__ == '__main__': main()
# end of file
textは出力されるけど、text2はエラーで出力されない状態
→font2 = pygame.font.Font(buf, 24)
この部分でエラーが起きてるので、おそらく型エラーかなんかおこしてるっぽいのだけど
実際にはアーカイブ化されたフォントを使うのが目的なので、フォント名指定でなくこういう回りくどいことしてます
総レス数 1002
229 KB
新着レスの表示
掲示板に戻る
全部
前100
次100
最新50
read.cgi ver 2014.07.20.01.SC 2014/07/20 D ★