SP_PUT |
[Features] The specified sprite
is displayed on a screen.
[Format] SP_PUT n,(x,y), [,pt] [,Reverse-switch]
[Explanation]
n: Sprite number. It can be used to 256
pieces.
x,y: Coordinates to display.
The value including a decimal is OK.
pt: The pattern number defined by 'SP_DEF'.
Reverse switch: 0.(or omitted)no
reverse 1.X-reverse 2.Y-reverse 3.XY-reverse
So that Sprite number is bigger, the
priority of the indication becomes higher.
[e.g.] The example of sprite use.
[smp_sp.bas]
100 circle(7,7),7,col(9)
110 circle(7+16,7),7,col(10)
120 circle(7+32,7),7,col(12)
130 get@(0,0),48,16,(0,0)
140 sp_def 0,(0,0),16,16
150 sp_def 1,(16,0),16,16
160 sp_def 2,(32,0),16,16
170 sp_on 0,1:sp_on 1,1:sp_on 2,1
180 dim x(3)
190 for i=1 to 100
200 sp_put 0,(x(0),16),0 : x(0)=x(0)+1
210 sp_put 1,(x(1),48),1 : x(1)=x(1)+2
220 sp_put 2,(x(2),80),2 : x(2)=x(2)+3
230 vsync
240 next
[Application]
*Speed up by the abbreviation.
If specifying only sprite number as
'sp_put 10' and omit the following,
it will reference directly to the
address of variable specified before.
By describing by variable
specification at first, and omitting at the time of loop,
it's possible to speed up in mass
sprite.
e.g.
sp_put
i,(cx(i),cy(i)),cp(i)
'...loop
for i=0 to ec
cx(i)+=1
sp_put i
next
'In this example, referring to
the value directly from address of 'cx(i),cy(i),cp(i)'
'There is use cases in the
sample'acsamp.bas'.
SP_DEF |
[Features] Definition of pattern
position in the Graphic buffer.
[Format] SP_DEF n,(x1,y1),x2,y2
[Explanation]
Start
point (x1,y1)
x2,y2 = sprite width.
n: The pattern number to define. It can
be defined to 256 pieces.
SP_ON |
[Features] Sprite
display/nondisplay is switching.
[Format] SP_ON n,sw
[Explanation]
n:
Sprite number.
sw=0 Hide
sw=1 Normal Sprite display
sw=2 Zooming Sprite display
When specifying '2'->Zooming
Sprite,
it can be displayed at
any magnification specified by 'sp_zoom'.
SP_MOVE |
[Features] To make sprite move
automatically by specified moving pattern.
[Format] SP_MOVE n,[pt],[d1],[d2],[d3],[d4]
[Explanation]
The set-up Sprite continue moving every
frame.
n: Sprite number
pt: moving pattern
pt=1 Now, moving pattern is only
[No.1]straight-moving.
To move
X-direction by 'd1'.
To move
Y-direction by 'd2'.
The moving amount
can be specified by a decimal unit.
In [d3][d4], the animation pattern of
sprite is specified.
Let be base-point
displayed sprite-pattern which defined by 'sp_def',
in Graphic buffer to rightward, by
sprite's width unit,
to be specified
by [d3] to how many pieces it shifts.
(Beforehand, it draw animation pattern to Graphic buffer as arranged in
horizontal)
Animation pattern will
loop in the specified number.
For
example, if [d3]=4 is specified, it starts from the base point No.1,
and if it come to the 4th pattern, the
next it return to No.1 pattern.
How
many frames required to move to the next anime pattern, it is specified by [d4],
If specify
pt=0, moving and animation will stop.
Information of current sprite's coordinates can be acquirable by 'sp_stat'
function.
Since auto moving is performed
in this command at every frame,
in
(,i)mode, timing can not keep up and it may become different behavior from
(,c)mode.
e.g. Sprite auto move
& animation, swap sample
[smp_mv_anm.bas]
100 screen
1,1,1,0:cls 3
110 for i=0 to 15
120 if i>7 then j=7-(i-8) else j=i
130 circle(i*32+16,16),7+j
140 next
150 get@(0,0),32*16,32,(0,0):cls 2
160 sp_def 1,(0,0),32,32
170 sp_def 2,(0,0),32,32
180 sp_on 1,1
190 sp_on 2,1
200 sp_move 1,1,1,0,16,8
210 sp_put 1,(32,100),1
220 sp_put 2,(32,200),2
230 while -1
240 vsync 256
250 sp_swap 1,2
260 k=-(k-1)
270 print "Swap move sprite ";k+1
280 sp_put k+1,(32,sp_stat(k+1,1)),1
290 wend
SP_ZOOM |
[Features] To specify expansion
rate of zooming Sprite each.
[Format] SP_ZOOM n, [EX-rate(XorAll)], [EX-rateY],
[Rotation angle]
[Explanation]
In
Sprite, to specify Expansion rate & Rotation angle.
n: Sprite No. (0~Sprite max number-1)
Expansion rate: 1=No expansion. 'Less
than 1' is reduction.
When specified
2nd parameter [EX-rate(XorAll)] only,
it is discriminated to be expansion
rate of both x and y.
When specified
3rd parameter [EX-rateY],
x and
y are discriminated as independent expansion rate.
By specifying [Rotation angle],
it's possible to make rotate Sprite
by 360 degree unit.(right turn)
For
Zooming-Rotation Sprite, it is necessary to specify 'sp_on SpriteNo,2'. (c.f.
sp_on)
The axis of rotation is always
the Sprite center.
Zooming Sprite
display base point is specified by 'SP_ORDER'.(edge or center)
'Zooming-Rotation Sprite' can not do
these.
XY-Reversed display,
'sp_move' automatic movement, 'sp_hit' collision judgment.
At the moment 'Zooming-Rotation Sprite'
does not be supported to 'OpenGL mode'.
[e.g.]
sp_on
12,2
for i=0 to 360
sp_put 12,x,y,pt
sp_zoom 12,1+i/100,,i
next
Sample etc. "smp_spzoom.bas"
SP_ORDER |
[Features] To specify the
starting number of sprite display priority order.
[Format] SP_ORDER n
[Explanation]
[SP-DisplayPriority]
To specify the
starting number of sprite display priority order.
Usually sprite is displayed,
Number 0 is the most backward,
Number 255 is the most forward. (Default n=0)
For example, if specifying 'sp_order
64',
display priority will be this.
[Backward] 64~255 0~63 [Forward]
[BasePosX] [BasePosY]
It set the coordinate specification of
zooming Sprite where to do.
Coordinate
specification is possible in the upper left, the center of Sprite, etc.
About designation method and its unit,
Unit 1 = half size of enlarged Sprite.
Example sp_order ,0,0
This is
coordinate specify with [upper left].
Example sp_order ,1,1
This is
coordinate specify with [central part of enlarged Sprite].
The base point is shifted to lower right
only by [half size] x [Specified number].
(The Sprite display shift to the upper
left)
It's possible to set different
values for x and y.
The normal Sprite
are always specified coordinate at the upper left.
SP_SWAP |
[Features] All the state is
exchanged between two sprite.
[Format] SP_SWAP sp1,sp2
[Explanation]
The
sprite number for exchange is specified by 'sp1','sp2'.
The Data exchanged
XY coordinates, size-XY, pattern,
display-ON/OFF state, margin size,
collision target & value of 'sp_hit()', 'sp_move'-moving pattern &
data.
SP_STAT |
[Features] To acquire various
information of sprite.
[Format] SP_STAT(n,d)
[Explanation]
n:
Sprite number.
d: Get the type.
0: x position.
1: y position.
2: The width of the pattern
size.
3: The height of the
pattern size.
4: Pattern
number.
5: Hide=0
Display=1
6: SP_MOVE: Moving pattern
number.
7: SP_MOVE: Data1 (X
moving amount)
8: SP_MOVE: Data2
(Y moving amount)
VSYNC |
[Features] Wait until the screen
drawing is updated regularly(1/60sec), and take the timing of
synchronization.
[Format] VSYNC
[n]
[Explanation]
FPS(Frames Per Second) is set as 60 with this
version.
This statement grasps the
last updating, and check whether new updating is made,
if updated, it will progress to the
next command.
When 'n' is specified,
it becomes n/60-second interval.(default n=1)
By describing it in loop, movement of
Sprite is kept by the constant speed.
[e.g.]
100
line(0,0)-(31,31),col(9),bf
110
get@(0,0),32,32,(0,0)
120 sp_def
0,(0,0),32,32
130 cls 3 : sp_on 0,1
140 for i=1 to 300
150 x=x+1: y=100
160 sp_put 0,(x,y),0
170 vsync 1
180 next
190 x=0 : goto 140
SP_OUT |
[Features] It is investigated
whether Sprite is inside of BG Graphics view range.
[Format] SP_OUT(Sprite
number)
[Explanation]
Inside return=0
Outside return=-1
In the area of screen inner side,
it can be expanded by the specified
amount of 'BG_GDSET' 3rd parameter.
Default = 1 pixcel widely for all directions.
(So as the Sprite that appeared in
'BG_GENE' not to disappear immediately)
[e.g.]
if sp_out(1)
then print"outside."
SP_CHECK |
[Features] It perform a
collision judgment between Sprite.
[Format] SP_CHECK
[Explanation]
The
candidate for a collision of each sprite is beforehand set up by 'SP_TARGET'.
The information on sprite overlapping
when 'SP_CHECK' is performed can be read by 'SP_HIT'.
When making collision size smaller than
the appearance of sprite,
the margin
have to be specified by 'SP_MARGIN'.
SP_HIT |
[Features] The sprite No. of the
overlaid sprite is returned. (Function)
[Format] SP_HIT(n,m)
[Explanation]
n: The Sprite No. to cause it.(Range0-255)
m: (m-th) The Count number in
order.
m=0: The number of the
sprite which has collided is returned.
m=1-: Subsequently, Sprite No. of a target which has collided is
returned.
Specification more than the
number of collisions will return -1.
Undisplayed sprites are out of judgment.
(When origin is undisplayed, a collision number is 0 piece.)
[e.g.]
When No.1 has collided with No.4 and
No.6.
sp_hit(1,0) -> 2
sp_hit(1,1) -> 4
sp_hit(1,2) -> 6
sp_hit(1,3) -> -1
SP_TARGET |
[Features] To specify the scope
of collision of each sprite.
[Format] SP_TARGET n, start, end
[Explanation]
n:
Sprite No. to cause it.(0-255)
start-end: The range. (0-255)
The
collision judging range of the specified sprite
is made even into 'end' position from
'start' position.
When no judgment,
'start' position is made into a bigger value than 'end' position.
SP_MARGIN |
[Features] The size of the
margin portion which doesn't have a collision judging at sprite is specified.
[Format] SP_MARGIN n,m
[Explanation]
n: Sprite No.(0-255)
m: The number of margin pixels.
If 0 is specified, it will become the
same judgment size as display size.
0000 e.g.
0880 This is
sprite size 4.
0880 '0' expresses the margin space.
0000 Margin
size=1 (Area which doesn't collide)
[e.g.] Sample of sprite
collision judging
[smp_hit_mgn.bas]
100 line(0,0)-(15,15),col(9),b
110 get@(0,0),16,16,(0,0) :cls 3
120 sp_def 0,(0,0),16,16
130x=0:y=100
140 sp_on 0,1:sp_on 1,1
150 sp_target 0,0,1
160 sp_margin 0,2
170 sp_put 1,(100,100),0
180 x=x+1
190 sp_put 0,(x,y),0
200 sp_check
210 for i=1 to sp_hit(0,0)
220 print"Hit no";sp_hit(0,i)
230 next
240 if sp_hit(0,0)>0 then stop
250 vsync
260 goto 180
SP_DIST |
[Features] Returns the distance
between two sprites, calculated using the Pythagorean theorem.
[Format] SP_DIST(Sprite No1, Sprite
No2)
[Explanation]
The distance is from the center of one
sprite to the center of the other.
This function, combined with the 'sp_hit' function, allows for circular
collision detection.
Also, by pairing
this with the following 'sp_bmx/sp_bmy' functions, you can calculate the vector
(direction and speed) of a sprite moving from No2 towards No1.
SP_BMX SP_BMY |
[Features] In combination with
'sp_dist', it calculates the X,Y movement towards a target.
[Format] SP_BMX([speed])
SP_BMY([speed])
[Explanation]
The immediately preceding 'sp_dist'(No1
target sprite, No2 base sprite) has stored the linear distance r and the X,Y
distances respectively.
This forms a
right triangle using the two sprites as coordinates.
By dividing the width and height by the
distance (X/r, Y/r), the movement amounts in X and Y directions towards the
target can be calculated.
Since it's
divided by the distance r, the magnitude of the X,Y movement vector is the size
of 1 pixel, but the movement speed can be adjusted by specifying a [speed]
multiplier (supports decimals).
Values
less than 1 will slow it down.
If
omitted, it will be the previously specified [speed] (default is 1).
In the prior 'sp_dist', please specify
the target sprite first, followed by the base sprite (the chasing side).
[Example]
[smp_dist.bas]
100 cls
3:pen ,,1
110 screen ,,1
120 line(1,1)-(14,14),col(15),b
130 pen ,,0
140 bg_view ,,,,size(0)\256
150 sp_def 0,(0,0),16,16: 'Define a
square sprite
160 sp_on 0,1:sp_on
1,1:sp_on 2,1
170 sd=sp_bmx(4):
'Specify speed as 4 times (once is enough)
180 sp_put 0,(128,128),0: 'Base
sprite
190 x1=128:y1=128
200 for i=0 to 16000
210 if i mod 256=0 then
y2=irnd(256): 'Random Y appearance position
220 sp_put 1,(i mod 256,y2),0:
'Target sprite
230 sp_put
2,(x1,y1),0: 'Sprite moving towards the target
240 x1+=mx:y1+=my: 'Add to move
250 if i mod 40=16 then
260 d=sp_dist(1,0): 'Calculate &
store r, X, Y to the target with dist
270 x1=sp_stat(0,0): 'Copy the
X-coordinate of the base appearance position
280 mx=sp_bmx(): 'Determine X
movement amount (direction) per frame
290 y1=sp_stat(0,1): 'Copy the
Y-coordinate of the base appearance position
300 my=sp_bmy(): 'Determine Y
movement amount (direction) per frame
310 endif
320 vsync
330 next
SP_PRINT |
[Features] To write text in
sprite buffer and display the text by sprite.
[Format] SP_PRINT pt,"string", x, y [,fontsize]
[Explanation]
pt: Pattern
number defined by 'SP_DEF'.
It's specified position of buffer to write the text in this
frame.
"string": Text string to be
written to the sprite buffer.
If let it to chr$(12), it becomes the same function as 'CLS'.
(Clear all
characters in the area)
x,y: Character
coordinates to be written.
pt-specified area: upper-left (0,0)
To specify coordinates
in character units.
fontsize:
size of the character.(omissible)
It can also
resize by 'font' command.
It have influence
to displayable word count.
The size is
rounded to multiple of 8 pixels.
The flow of display by 'SP_PRINT'.
To allocate a place to write text with
'SP_DEF',
and assign actual
display with 'SP_PUT','SP_ON',
and specify display position,
text is actually written in the buffer by 'SP_PRINT',
and it will be displayed on the
screen.
It's possible to use it like
text display window by one sheet sprite.
Further, it is necessary to specify
colors in advance.
To be used the same
command as the text screen setting.
Command usage: color text-color, graphic-color
'text-color' is [SP_PRINT's textfont
color],
'graphic-color' is [background
fill color]
At first please set
this:
color col(15),0
background
color->black:transparent.(default=white)
Because text can be overwritten
repeatedly,
the previous text will be
cleared each time by this background color.
[e.g.] "smp_spprint.bas"
10 color col(15),0
20 sp_def 1,(128,128),160,96
30 sp_put 1,(32,32),1
40 sp_on 1,1
50 sp_print 1,"SC-12800",1,1
60 sp_print 1,"LEFT OOO",1,2