<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>


SPRVEC Search:

In Graphics Words in TurboForth Kernal

Word Name: SPRVEC
Type: Standard word
Data Stack Signature: sprite y x --
Return Stack Signature: --
Availability: V1.2
Description:

Defines a movement vector for sprite sprite.

Example:
hex
: square ( --) \ define sprite pattern 0 as a solid square
  data 4 $FFFF $FFFF $FFFF $FFFF 100 DCHAR ;
decimal
 
\ define colours:
 8 constant red
15 constant white
 5 constant blue
11 constant yellow
 1 constant black
 
: init ( -- )
    1 gmode       \ 32 column mode 
    black screen  \ black screen
    0 magnify     \ single 8x8 sprites
    square        \ define the sprite pattern
   
    \ set up the 4 sprites:
    ( sprite 0) 0 100 100 0 red sprite
    ( sprite 1) 1 110 100 0 white sprite
    ( sprite 2) 2 120 100 0 blue sprite
    ( sprite 3) 3 130 100 0 yellow sprite
   
    \ now define the movement vectors:
    ( sprite 0) 0 0 1 sprvec
    ( sprite 1) 1 0 2 sprvec
    ( sprite 2) 2 0 3 sprvec
    ( sprite 3) 3 0 4 sprvec ;
   
: delay ( n -- ) \ delay loop
    0 do loop ;
   
: moveSprites ( -- ) \ move the sprites 256 times
    init         \ initialise the sprites
    256 0 do 
      0 4 sprmov 
      500 delay  \ we need a delay otherwise its just a blur!
    loop ;
Comment:

When SPRMOV is called, sprite sprite will move y pixels up/down and x pixels left/right. If y is negative sprite will move upwards. If x is negative sprite will move leftwards.

Note: In TurboForth versions 1.0 and 1.1 this word is called SMLIST. It has been renamed in version 1.2 to SPRVEC to better describe its intention/function.

See Also: SPRMOV  SMLIST 

<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>