Having some problems with the WM_COLLIDE handler. It detects the collision, and stops the sprite, however it seems like it's still trying to move - ie I have to hold down the opposite direction to bring the speed back to 0 before he'll move left again.
and what I'm using for the movement:
Likely a stupid question, but I can't figure out what's causing it. If I set the sprite speed to 0, shouldn't it start subtracting from 0?
Also a small note - I noticed the second line doesn't get executed regardless of what I put there, is that normal or is that another stupid error?
[edit] Heh, while I'm at it, DrawSprite asks for the spriteid, is that what I set the variable to when loading the sprite, ie
worldtest$ = LoadSprite("c:\\ppl\\plat\\image.bmp", -1, 1, 0, NULL);
would worldtest$ be the spriteid? that doesn't seem to work here.
[edit2] Doh, now if I put a sprite under the player, and set the gravity, it falls OK, but I'm unable to move due to the fact it's constantly finding a collision. Is there anyway to detect collisions on the separate axis?
- Code:
func mainproc(hWnd$, Msg$, wParam$, lParam$)
ok$ = true;
case(Msg$)
WM_CLOSE:
ShutGameAPI(hWnd$);
WM_KEYDOWN:
KeysPressed$[wParam$] = 1;
WM_KEYUP:
KeysPressed$[wParam$] = 0;
WM_COLLIDE:
SetSpriteSpeedX(wParam$, 0);
PostMessage(hWnd$, WM_CLOSE, 0, 0);
end;
return(ok$);
end;
and what I'm using for the movement:
- Code:
if (KeysPressed$[keys.vkLeft$])
SetSpriteSpeedX(player$, SpriteSpeedX(player$) - .001);
end;
if (KeysPressed$[keys.vkRight$])
SetSpriteSpeedX(player$, SpriteSpeedX(player$) + .001);
end;
Likely a stupid question, but I can't figure out what's causing it. If I set the sprite speed to 0, shouldn't it start subtracting from 0?
Also a small note - I noticed the second line doesn't get executed regardless of what I put there, is that normal or is that another stupid error?
[edit] Heh, while I'm at it, DrawSprite asks for the spriteid, is that what I set the variable to when loading the sprite, ie
worldtest$ = LoadSprite("c:\\ppl\\plat\\image.bmp", -1, 1, 0, NULL);
would worldtest$ be the spriteid? that doesn't seem to work here.
[edit2] Doh, now if I put a sprite under the player, and set the gravity, it falls OK, but I'm unable to move due to the fact it's constantly finding a collision. Is there anyway to detect collisions on the separate axis?