SPRITEMOVEXY

From Liberty BASIC Family
Revision as of 03:04, 11 October 2023 by StPendl (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

This BASIC sprite command will cause a sprite to move automatically on each DRAWSPRITES execution.
Two variables define the amount of pixels to move on each coordinate. Setting those to 0 (zero) will cause the sprite to stop moving.
The Background and Sprites will not show up until a DRAWSPRITES command is issued.

Syntax

Graphic Box Control

  1. Print #Handle.Extension, "spritemovexy spritename x y"
  2. #Handle.Extension, "spritemovexy spritename x y"
  3. #Handle.Extension "spritemovexy spritename x y"
  4. Print #Handle.Extension, "spritemovexy spritename "; varx;" "; vary
  5. #Handle.Extension, "spritemovexy spritename "; varx;" "; vary
  6. #Handle.Extension "spritemovexy spritename "; varx;" "; vary

Graphics Type Window

  1. Print #Handle, "spritemovexy spritename x y"
  2. #Handle, "spritemovexy spritename x y"
  3. #Handle "spritemovexy spritename x y"
  4. Print #Handle, "spritemovexy spritename "; varx;" "; vary
  5. #Handle, "spritemovexy spritename "; varx;" "; vary
  6. #Handle "spritemovexy spritename "; varx;" "; vary

Hints

The sprites could be several images of a character walking.
Only one graphicbox or graphics window in a program may use sprites.

Example

This example uses the image from above. Save it to a folder of your choice and run this code from the same folder.
NOMAINWIN
LOADBMP "BMP","sprite_jb_guy_1.bmp"
Open "Just BASIC - Sprite Demo - SpriteMoveXY" For Graphics_nsb_nf as #main
    #main "Trapclose [quit]"
    #main "AddSprite player BMP"

    [startMoving]
    #main "SpriteMoveXY player 3 3"

    Timer 100, [repeat]
    Wait
    [repeat]
    #main "Drawsprites"
    wait

[quit]
Timer 0
Close #main
UNLOADBMP "BMP"
End

Useful Procedures

' Place a useful function or sub using this keyword here