注意:スプライト機能は重いので、iPad1ではちょっとしんどいです。
// スプライトテスト1
// V2.00以降専用
// グラフィックモードに設定
width(0)
int wgx,wgy
getWidth(wgx,wgy):// グラフィックモードで画面幅を取得
locate(0,2):print "Graphic Width:";wgx;"*";wgy
// sprite pattern (X68 type)
dim char ptnA(255) = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0
,0,0,2,0,2,0,2,0,0,2,0,2,0,2,0,0
,0,0,0,3,0,3,0,3,3,0,3,0,3,0,0,0
,0,1,2,0,4,0,0,4,4,0,0,4,0,2,1,0
,0,0,0,3,0,5,0,5,5,0,5,0,3,0,0,0
,0,0,2,0,0,0,6,0,0,6,0,0,0,2,0,0
,0,1,0,3,4,5,0,7,7,0,5,4,3,0,1,0
,0,1,0,3,4,5,0,7,7,0,5,4,3,0,1,0
,0,0,2,0,0,0,6,0,0,6,0,0,0,2,0,0
,0,0,0,3,0,5,0,5,5,0,5,0,3,0,0,0
,0,1,2,0,4,0,0,4,4,0,0,4,0,2,1,0
,0,0,0,3,0,3,0,3,3,0,3,0,3,0,0,0
,0,0,2,0,2,0,2,0,0,2,0,2,0,2,0,0
,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
}
int spA=16:// パターン番号
int pbA=1://3 :// パレットブロック番号
int planeA=0:// プレーン番号
//
dim char ptnB(255)={ // あ(複数色)
0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,1,0 ,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,1,0 ,0,0,0,0,0,0,0,0
,0,0,0,1,2,3,4,5 ,6,7,8,9,1,0,0,0
,0,0,0,0,0,0,1,0 ,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,1,0 ,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,1,2 ,3,4,5,0,0,0,0,0
,0,0,0,0,1,2,3,0 ,0,0,4,5,6,0,0,0
,0,0,0,1,0,0,2,0 ,0,3,0,0,0,4,0,0
,0,0,1,0,0,0,2,0 ,0,3,0,0,0,4,0,0
,0,0,1,0,0,0,2,0 ,3,0,0,0,0,4,0,0
,0,0,1,0,0,0,2,1 ,0,0,0,0,0,3,0,0
,0,0,0,1,0,0,2,0 ,0,0,0,3,4,0,0,0
,0,0,0,0,1,2,0,0 ,0,3,4,0,0,0,0,0
,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0
}
int spB=spA+1:// パターン番号
int pbB=pbA+1:// パレットブロック番号
int planeB=planeA+1:// プレーン番号
//
int i,x,y
sp_init():// ここでスプライト画面は非表示になる
sp_clr()
sp_def(spA,ptnA)
sp_def(spB,ptnB)
for i = 0 to 7
sp_color(i,rgb(0,i*256/8,0),pbA)
next
//
sp_color(0,0,pbB)
sp_color(1,&hff00ffff,pbB)
sp_color(2,&hffff00ff,pbB)
sp_color(3,&h800000ff,pbB)
sp_color(4,&h8080ffff,pbB)
sp_color(5,&hff8080ff,pbB)
sp_color(6,&hff0000ff,pbB)
sp_color(7,&h00ff00ff,pbB)
sp_color(8,&h0080ffff,pbB)
sp_color(9,&hffffffff,pbB)
//
int pbA2=pbB+1 :// パレットブロック番号
for i = 0 to 7
sp_color(i,rgb(i*256/8,0,0),pbA2)
next
//
width(32)
vpage(B_SPAGE+B_TPAGE,YES):// display sprite screen
//vpriority(TPAGE,SPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpriority(SPAGE,TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
cls()
tborder(1,CTHRED)
//
// タッチした位置にスプライトパターンを表示する
//
str exit$,mes$
if isLocalizeJapan() then {
exit$="中断"
mes$="画面にタッチ&ドラッグしてください"
} else {
exit$="exit"
mes$="Please touch & drag"
}
setFunctionKey(0,exit$,'!')
setFunctionKeyBackgroundImage("funcBack.png")
displayFunctionKeyAll(YES,YES):// v2.0
//
setTouchArea(0,0,0,0,0,YES):// これがないと任意のタッチ座標を得られない
//
dim float tpoint(2)
int touchCnt
str cs
int dt=0,t
int ts=time():/* 開始時間
locate(0,1):print mes$
//
sp_disp(YES)
//
if NO then {
sp_halt(YES):// 以下一括変更するので終了まで表示停止
sp_setting(planeA+0,0,0,spA,pbA2,SPRITE_FLIP_NONE,SPRITE_PRW_SPBG0BG1)
sp_setting(planeA+1,16,16,spA,pbA2,SPRITE_FLIP_NONE,SPRITE_PRW_SPBG0BG1)
sp_setting(planeA+2,32,32,spA,pbA2,SPRITE_FLIP_NONE,SPRITE_PRW_SPBG0BG1)
sp_halt(NO):// 表示再開
end
}
//
int x0=-1,y0=-1
repeat
// キー入力待ちしながら時計を回す
while (not kbhit())
t=time()
if t-ts>dt then { :/* 秒が変った
dt=dt+1
// locate(20,0):print dt;
// beep2(0)
// locate(20,1)
}
touchCnt=getTouchPoint(tpoint)
if (touchCnt>0) then {
x=tpoint(0):// float → int
y=tpoint(1)
if x<>x0 or y<>y0 then {
locate(0,0):print x;",";y
sp_halt(YES):// 以下一括変更するので終了まで表示停止
// 普通 / normal
if pbA<>1 then {
sp_setting(planeA , x, y,spA,pbA ,SPRITE_FLIP_NONE,SPRITE_PRW_SPBG0BG1)
} else {
// sp_move()はパレットブロック1専用
sp_move( planeA , x, y,spA)
}
// 反転
sp_setting(planeB , x+16, y+16,spB,pbB ,SPRITE_FLIP_NONE ,SPRITE_PRW_SPBG0BG1)
sp_setting(planeB+1, x-16, y+16,spB,pbB ,SPRITE_FLIP_HORIZONTAL ,SPRITE_PRW_SPBG0BG1)
sp_setting(planeB+2, x+16, y-16,spB,pbB ,SPRITE_FLIP_VERTICAL ,SPRITE_PRW_SPBG0BG1)
sp_setting(planeB+3, x-16, y-16,spB,pbB ,SPRITE_FLIP_HORIZONTAL_VERTICAL,SPRITE_PRW_SPBG0BG1)
// 同一パターンを別パレットブロックで
sp_setting(planeB+4,wgx-x,wgy-y,spA,pbA2,SPRITE_FLIP_NONE,SPRITE_PRW_SPBG0BG1)
sp_halt(NO):// 表示再開
//
x0=x:y0=y
}
// Do not re-displayed when the coordinate is same. Sprite would flicker Failure to do so.
}
endwhile
// キー操作判定
cs=inkey$()
until cs="!"
float ver=osVersion()
print "iOS=";ver
//
end
Zipファイル : XBsprite.zip
0 件のコメント:
コメントを投稿