Help with Sprites and Transparency

Discussion in 'Questions (Windows Mobile)' started by Drewpeu, Sep 23, 2008.

  1. Drewpeu

    Drewpeu Member Licensed User

    Hi Erel,

    I have just purchased basic4ppc, up to this point I have been a GLBasic
    person as it can compile for multiple Operating Systems.

    I have been trying to get my head around Sprites and Transparency in
    basic4ppc as they are used in a different way!

    LOADSPRITE "ship.bmp",0
    LOADSPRITE "shot.bmp",1
    LOADSPRITE "buga.bmp",2
    LOADSPRITE "boom.bmp",3

    The sprite's are referred to numerically or given names.

    // Player
    INC playerx, MOUSEAXIS(0)
    playerx = MAX(MIN(playerx,600),32)
    SPRITE 0, playerx, 456 //sets the ship.bmp position

    The ship.bmp has a background colour of RGB(255,0,128) which is transparent
    the sprites in basci4ppc also have transparency bur an image does no seem to
    have thia capabillity, the image button is no use for this either as its
    transparency is the same as the Form or Panel background colour?

    // Invaders
    speed = 3
    amour = 4

    LOCAL bugs[] AS FOE

    FOREACH bug IN bugs[] / draw the invaders on the screen and animate
    INC bug.x, bug.speed
    IF bug.x<0 OR bug.x>640
    bug.speed = - bug.speed
    INC bug.y, 32

    How would I handle all this in basic4ppc, I will end up with six rows of
    invaders, each row will have a score value, top will have the highest score
    so I need to know which sprite has been destroyed.

    Can I put the sprites in a structure or an Array?

    I am not asking you to do the programming for me but I would like more info
    on how to controll the sprites within the game.

  2. Erel

    Erel Administrator Staff Member Licensed User

    First I recommend you to go over some Sprites examples:
    You can find one under c:\Program Files\Anywhere Software\Basic4ppc Desktop\Samples
    And here:

    You can use the Control keyword to work with a group of sprites or any other objects.
    For example:
    For i = 1 to 10
    Control("Sprite" & i, Sprite).X = ...
    See this tutorial for more information:

    BTW, you can also consider using the ImageLib library and handle all the drawing without the Sprite library. This will give you more control.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice