img = Image.load("man.png", VRAM)
x =10
y =10while not Keys.newPress.Start do
Controls.read()if Stylus.held then
x = Stylus.X
y = Stylus.Y
endif Keys.held.Up then y = y +2endif Keys.held.Down then y = y -2endif Keys.held.Right then x = x +2endif Keys.held.Left then x = x -2end
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 =1while not Keys.newPress.Start do
Controls.read()
startDrawing()
spr:playAnimation(SCREEN_DOWN, x, y, direction)if Keys.held.Up then direction =1 y = y -1endif Keys.held.Right then direction =2 x = x +1endif Keys.held.Down then direction =3 y = y +1endif Keys.held.Left then direction =4 x = x -1end
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