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] To return the
distance
between two sprites.(calculate R with Pythagorean
theorem)
[Format] SP_DIST(spriteNo1,spriteNo2)
[Explanation]
Distance is the center-to-center distance of each
sprite.
Circular collision detection can be
realized
by using this function together with 'SP_HIT'
function.
By combining it with the following [SP_BMX/BMY]
function,
you can calculate the vector (direction
and speed) of a sprite moving from No2 to No1.
SP_BMX SP_BMY |
[Features] When combined with [SP_DIST], it
calculates
the movement [X,Y] towards the target
object.
[Format] SP_BMX([speed])
SP_BMY([speed])
[Explanation]
In the previous [SP_DIST](No.1 target sprite, No.2 base point
sprite),
the straight-line distance R and the
distances of [X,Y] are both stored in memory.
This forms a
right-angled triangle with the coordinates of the two
sprites.
By dividing vertically and horizontally by
[X/R,Y/R],
you can calculate the movement distances
[X,Y] of the sprite moving towards the target object.
Since it's divided by distance R, the magnitude of the vector formed by the
[X,Y] movement distances
becomes the size of one
pixel.
However, you can change the movement speed using a
multiple of [speed] (supports decimals).
(where values
less than 1 will result in slower movement)
If omitted, it
will default to the previously specified [speed] (initially set to
1).
In the preceding [SP_DIST], please provide the
descriptions for the target object sprite
and the
base sprite (the one chasing) in that order.
e.g.
[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
'Definition of
square-shaped sprite
150 sp_def 0,(0,0),16,16
160 sp_on 0,1:sp_on 1,1:sp_on 2,1
'Speed set to 4 times (once is
sufficient)
170 sd=sp_bmx(4)
180 sp_put
0,(128,128),0: 'Base sprite
190 x1=128:y1=128
200 for i=0 to 16000
'Random Y appearance position
210
if i mod 256=0 then y2=irnd(256)
220 sp_put 1,(i mod
256,y2),0
:'Target object sprite
'Sprite moving towards
the target object
230 sp_put 2,(x1,y1),0
'Movement by
addition (accumulation)
240 x1+=mx:y1+=my
250 if
i mod 40=16 then
'By dist, calculate R,X,Y to the target and
memory
260 d=sp_dist(1,0)
'Appearance position is a
copy of the base sprite's X coordinate
270
x1=sp_stat(0,0)
'Determine X-axis movement amount (direction) per
frame
280 mx=sp_bmx()
'Appearance position is a copy of
the base sprite's Y coordinate
290
y1=sp_stat(0,1)
'Determine Y-axis movement amount (direction) per
frame
300 my=sp_bmy()
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