images

フォルダ「simple blit, stylus and keys」
ソース
img = Image.load("man.png", VRAM)
 
x = 10
y = 10
 
while not Keys.newPress.Start do
 
	Controls.read()
 
	if Stylus.held then
		x = Stylus.X
		y = Stylus.Y
	end
 
	if Keys.held.Up then y = y + 2 end
	if Keys.held.Down then y = y - 2 end
	if Keys.held.Right then x = x + 2 end
	if Keys.held.Left then x = x - 2 end
 
	startDrawing()
	screen.blit(SCREEN_DOWN, x, y, img)
	screen.print(SCREEN_UP, 0, 0, "Use the stylus or + to move the man")
	screen.print(SCREEN_UP, 0, 8, "Press START to quit")
	screen.print(SCREEN_UP, 0, 184, "FPS: "..NB_FPS)
	stopDrawing()
 
end
 
Image.destroy(img)
img = nil
x = nil
y = nil
 

使用している画像
man.png

実行結果

フォルダ「sprite and keys」
ソース
spr = Sprite.new("sprite.png", 24, 32, VRAM)
 
spr:addAnimation({0,1,2,1}, 300) -- Walk up
spr:addAnimation({3,4,5,4}, 300) -- Walk right
spr:addAnimation({6,7,8,7}, 300) -- Walk down
spr:addAnimation({9,10,11,10}, 300) -- Walk left
 
x = 150
y = 80
direction = 1
 
 
while not Keys.newPress.Start do
 
	Controls.read()
 
	startDrawing()
 
	spr:playAnimation(SCREEN_DOWN, x, y, direction)
 
	if Keys.held.Up then direction = 1 y = y - 1 end
	if Keys.held.Right then direction = 2 x = x + 1 end
	if Keys.held.Down then direction = 3 y = y + 1 end
	if Keys.held.Left then direction = 4 x = x - 1 end
 
	screen.print(SCREEN_UP, 0, 184, "FPS: "..NB_FPS)
	screen.print(SCREEN_UP, 0, 0, "Press START to quit")
 
	stopDrawing()
 
end
 
spr:destroy()
spr = nil
x = nil
y = nil
direction = nil
 

使用している画像
sprite.png

実行結果


タグ:

+ タグ編集
  • タグ:
最終更新:2010年10月09日 19:43
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。