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


SPRMOV Search:

In Graphics Words in TurboForth Kernal

Word Name: SPRMOV
Type: Standard word
Data Stack Signature: start_sprite count --
Return Stack Signature: --
Availability: V1.0  V1.1  V1.2
Description:

Moves the sprites starting at start_sprite and continuing for count sprites according to their vectors (see SPRVEC).

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 ;

movesprites

Comment:

none

See Also: SPRVEC 

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