Ariane Soft PPL2 Pocket Programming DataMite
  #1  
Old 09-03-2009, 04:16 PM
Mike Halliday Mike Halliday is offline
Senior Member
 
Join Date: Sep 2007
Location: Crewe, Cheshire, UK
Posts: 821
Send a message via Skype™ to Mike Halliday
Default Multiple key detection

How do I detect multiple key presses?

An example:

I Press UP, then I press LEFT - Sprite moves diagonally. Unfortunately when I do this using the standard keypress detection my sprite starts moving up when I press the UP key, then moves left when I press the LEFT key.

It appears that only single key presses are registered.

Am I missing something? - Is there a simple way to do this?
Reply With Quote
  #2  
Old 09-03-2009, 05:53 PM
Leginus Leginus is offline
Senior Member
 
Join Date: Mar 2008
Location: Chesterfield, Derbyshire, UK
Posts: 143
Default

As i understand it mike this is a shortcoming of windows mobile and not ppl. The only other way that I have seen it done in games is to have an onscreen joystick with 8 positions, as you couldnt use a 4 position one because you can only register 1 screen press at the same time as well. Lol gr8 planning from microsoft :0
Reply With Quote
  #3  
Old 09-03-2009, 08:39 PM
Nicknack Nicknack is offline
Senior Member
 
Join Date: Nov 2006
Location: Germany
Posts: 527
Default

do you have this on mind?
Code:
#include "GameAPI.ppl"

func mainproc(hWnd$, Msg$, wParam$, lParam$)
  ok$ = true;

  case (Msg$)

    WM_CLOSE:
      ShutGameAPI(hWnd$);

    WM_KEYDOWN:
      g_KeyEvent(wParam$, True);

    WM_KEYUP:
      g_KeyEvent(wParam$, False);

  end;
  return (ok$);
end;

func GameProc(hWnd$, Msg$, wParam$, lParam$)
  case (Msg$)
    WM_PAINT:t
      g_clear(0);
      RenderSprites;
      
    WM_TIMER:
    	if (g_key.vkDown$ and g_key.vkRight$)
        OffsetSprite(sp$,1,1);
      end;
      if (g_key.vkA$)
        PostMessage(hWnd$, WM_CLOSE, 0, 0);
      end;

  end;
  return (true);
end;

func WinMain
  h$ = newform({GAPI}, {GAPIClass}, &mainproc);
  ShowWindow(h$, SW_SHOW);

  ShowFPS(true, G_RGB(255, 255, 255));
  InitGameAPIEx(h$, &GameProc, 240, 320, false, 5, 60);

	global(sp$);	
	sp$=newsprite(null);
	sEtspritewidth(sp$,10);
	sEtspriteheight(sp$,10);

  return (true);
end;
surely it doesn't work the same way directly in WM_KEYDOWN, but with the help of an extra variable for each keystate it should keep your fingers gliding, too

Last edited by Nicknack; 09-03-2009 at 08:41 PM.
Reply With Quote
  #4  
Old 09-18-2009, 10:49 PM
mmtbb mmtbb is offline
Senior Member
 
Join Date: Jun 2006
Posts: 117
Default

Mike,

You have to manually do this. You have to use an if() statement to chack if both buttons are down, then issue the command to move the sprite diagonal.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright (c) ArianeSoft Inc.
Copyright © 2009 www.ppl-lang.com - All rights reserved
Web Design by BR Web Consulting Ltd