0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Pyxel】[小技]空の.pyxresファイルを作成する

0
Posted at

前日までに作成した記事
短いプログラムで遊ぶ③
短いプログラムで遊ぶ④
短いプログラムで遊ぶ⑤
において、
前準備として、あらかじめ「Pyxel Editorを起動して空のmy_resource.pyxresを作成してください」と書きましたが、以下の方法で空の.pyxresファイルを作成することができます。

やってることは単に空の.pyxresファイルをバイナリダンプしたデータをファイル化してるだけですが、これを使えば前準備がいらなくなります。
なんとなく邪道な方法なのかなとか思うので別記事にしました。

本来ならば.pyxpalのロードコマンドがあるのが理想です。

#-----------------------------------------------------------------
#空の.pyxresファイルを作成する
#-----------------------------------------------------------------
resdata = [	0x50,0x4B,0x03,0x04,0x14,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x21,0x00,0x4C,
			0x7D,0xBE,0xCE,0xA1,0x00,0x00,0x00,0x11,0x15,0x00,0x00,0x13,0x00,0x00,0x00,
			0x70,0x79,0x78,0x65,0x6C,0x5F,0x72,0x65,0x73,0x6F,0x75,0x72,0x63,0x65,0x2E,
			0x74,0x6F,0x6D,0x6C,0xED,0xCC,0x4B,0x0E,0x83,0x30,0x0C,0x04,0xD0,0x7D,0x4E,
			0xC1,0x11,0x50,0x7F,0xBB,0x9E,0x24,0x42,0x55,0x44,0x0C,0x58,0x22,0x09,0xC5,
			0x86,0x5E,0xBF,0x41,0x0A,0xDB,0xEE,0x5A,0x55,0x68,0x76,0x1E,0xDB,0xF3,0xBA,
			0x34,0x07,0xA7,0x8F,0x95,0x66,0xE1,0x14,0xAB,0x7B,0x75,0x31,0xC6,0x5A,0x0E,
			0xAE,0x27,0x69,0x1A,0xF3,0x62,0xAF,0x43,0xDE,0x9E,0xAE,0x37,0x33,0x10,0xF7,
			0x83,0x96,0xE0,0x9D,0xBA,0x3C,0x5A,0x5B,0xE7,0xAF,0x1F,0x35,0x94,0x47,0x0A,
			0x6E,0xFA,0xD8,0xE1,0xD0,0xCB,0xDC,0xE6,0x50,0xA3,0x7E,0x94,0xBA,0xA4,0x25,
			0xFA,0xAD,0x1C,0x93,0x92,0x6C,0x97,0xC6,0x68,0x8A,0xFB,0xB8,0xA6,0x71,0x09,
			0x7B,0xA0,0xAE,0xA3,0x56,0x4B,0x90,0x89,0xC8,0xE7,0xF1,0x5C,0x83,0x01,0x03,
			0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x01,0x03,0x06,0x0C,0x18,0x30,0x60,0xC0,
			0x80,0xF9,0x22,0x13,0x16,0xE1,0x76,0x63,0x84,0x9E,0xE5,0xE1,0x7F,0xB7,0x6F,
			0x50,0x4B,0x01,0x02,0x14,0x03,0x14,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x21,
			0x00,0x4C,0x7D,0xBE,0xCE,0xA1,0x00,0x00,0x00,0x11,0x15,0x00,0x00,0x13,0x00,
			0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xA4,0x81,0x00,0x00,0x00,
			0x00,0x70,0x79,0x78,0x65,0x6C,0x5F,0x72,0x65,0x73,0x6F,0x75,0x72,0x63,0x65,
			0x2E,0x74,0x6F,0x6D,0x6C,0x50,0x4B,0x05,0x06,0x00,0x00,0x00,0x00,0x01,0x00,
			0x01,0x00,0x41,0x00,0x00,0x00,0xD2,0x00,0x00,0x00,0x00,0x00,0xFFFF]
with open('./my_resource.pyxres', mode='wb') as f:
	_cnt = 0
	while( resdata[_cnt] != 0xFFFF ):
		#16進数の数値をバイナリ書き込みする
		f.write( resdata[_cnt].to_bytes(1,'big') )
		_cnt+=1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?