head 1.1; branch 1.1.1; access ; symbols start:1.1.1.1 PAlibDoc:1.1.1; locks ; strict; comment @# @; 1.1 date 2005.11.02.08.30.25; author jandujar; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2005.11.02.08.30.25; author jandujar; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @ PA_lib: Key input system

Key input system


Defines

#define PA_MoveSprite(sprite)   PA_MoveSpriteEx(PA_Screen, sprite, PA_GetSpriteLx(0, sprite), PA_GetSpriteLy(0, sprite))
 Move a sprite according to the stylus's position. The sprite will be 'hooked' if the stylus passes over it, and then they'll be linked together. Returns 1 if the sprite is moved. You can also get information from PA_MovedSprite.Moving (1 if you are moving a sprite), .Sprite (sprite moved), .X (X position of the center of the sprite), .Y (Y position of the center of the sprite), .Vx (horizontal speed ! useful if you want to make the sprite continue to move when you release the stylus...), and .Vy
#define PA_SpriteTouched(sprite)   PA_SpriteTouchedEx(sprite, PA_GetSpriteLx(PA_Screen, sprite), PA_GetSpriteLy(PA_Screen, sprite))
 Check if a given sprite is touched. Returns 1 if touched...
#define PA_StylusInZone(x1, y1, x2, y2)   ((Stylus.X>=x1)&&(Stylus.Y>=y1)&&(Stylus.X<x2)&&(Stylus.Y<y2))
 Check if the stylus is in a given zone... Returns 1 if yes, 0 if not

Functions

void PA_UpdatePad (void)
 Update the Keypad, use it once per frame (in the VBL for example). You can then retrieve the held down keys with Pad.Held.A (or Up, Down...), Newly pressed keys with Pad.Newpress.R, and the just released keys with Pad.Released.Up...
void PA_UpdateStylus (void)
 Update the Stylus position. You can then check if the stylus is current in use (Stylus.Held), newly pressed (Stylus.Newpress), or released (Stylus.Released), and get it's position (Stylus.X, Stylus.Y).
bool PA_MoveSpriteEx (bool screen, u8 sprite, u8 lx, u8 ly)
 Move a sprite according to the stylus's position. See PA_MoveSprite for more details... The difference is that here you chose the sprite dimension (lx and ly), which is useful if the sprite is smaller than the DS standard sizes... (for example 20x20...). This will also limit the 'hooking' distance
bool PA_MoveSpriteDistance (u8 sprite, u8 distance)
 Move a sprite according to the stylus's position. See PA_MoveSprite for more details... The difference is that here you chose the hooking distance in pixels
void PA_UpdateMoveSprite (void)
 Update the moving sprite info. If you don't put this in the VBL (it already is in PA_InitVBL), then if you stop moving around a sprite, it might not be able to pick up other sprites...
bool PA_SpriteTouchedEx (u8 sprite, u8 lx, u8 ly)
 Check if a given sprite is touched. Returns 1 if touched... You can chose the width and height around the sprite

Detailed Description

Check which keys are pressed...

Define Documentation

#define PA_MoveSprite sprite   )     PA_MoveSpriteEx(PA_Screen, sprite, PA_GetSpriteLx(0, sprite), PA_GetSpriteLy(0, sprite))
 

Move a sprite according to the stylus's position. The sprite will be 'hooked' if the stylus passes over it, and then they'll be linked together. Returns 1 if the sprite is moved. You can also get information from PA_MovedSprite.Moving (1 if you are moving a sprite), .Sprite (sprite moved), .X (X position of the center of the sprite), .Y (Y position of the center of the sprite), .Vx (horizontal speed ! useful if you want to make the sprite continue to move when you release the stylus...), and .Vy

Parameters:
sprite Object number in the sprite system

#define PA_SpriteTouched sprite   )     PA_SpriteTouchedEx(sprite, PA_GetSpriteLx(PA_Screen, sprite), PA_GetSpriteLy(PA_Screen, sprite))
 

Check if a given sprite is touched. Returns 1 if touched...

Parameters:
sprite Sprite number in the sprite system

#define PA_StylusInZone x1,
y1,
x2,
y2   )     ((Stylus.X>=x1)&&(Stylus.Y>=y1)&&(Stylus.X<x2)&&(Stylus.Y<y2))
 

Check if the stylus is in a given zone... Returns 1 if yes, 0 if not

Parameters:
x1 X value of the upper left corner
y1 Y value of the upper left corner
x2 X value of the lower right corner
y2 Y value of the lower right corner


Function Documentation

bool PA_MoveSpriteDistance u8  sprite,
u8  distance
 

Move a sprite according to the stylus's position. See PA_MoveSprite for more details... The difference is that here you chose the hooking distance in pixels

Parameters:
sprite Object number in the sprite system
distance Hooking distance

bool PA_MoveSpriteEx bool  screen,
u8  sprite,
u8  lx,
u8  ly
 

Move a sprite according to the stylus's position. See PA_MoveSprite for more details... The difference is that here you chose the sprite dimension (lx and ly), which is useful if the sprite is smaller than the DS standard sizes... (for example 20x20...). This will also limit the 'hooking' distance

Parameters:
screen On what screen to do it
sprite Object number in the sprite system
lx Sprite length
ly Sprite height

inline bool PA_SpriteTouchedEx u8  sprite,
u8  lx,
u8  ly
[inline]
 

Check if a given sprite is touched. Returns 1 if touched... You can chose the width and height around the sprite

Parameters:
sprite Sprite number in the sprite system
lx Wideness
ly Height


Generated on Fri Oct 28 23:16:51 2005 for PA_lib by  doxygen 1.3.9.1
@ 1.1.1.1 log @Initial import of PalibDoc, begin on PAlib0.64b @ text @@