Delphi
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Iron Speed
Go Back   Tutorialized ForumsDesktop ProgrammingDelphi

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 14th, 2005, 12:57 AM
Pixelmixer Pixelmixer is offline
Member
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 36 Pixelmixer New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Pixelmixer
Closed

Ok, this may seem a wierd question, because ive searched google for like a week to find an anwer.

I have 4 submit buttons in a form... each named "Submit" with the values "North", "South", "East", and "West". When a button is submitted it sends its value to a php script that determines which direction was clicked... this in turn moves a character around a map. Everything works flawlessly when a button is clicked.....

However....

In the game clicking a direction gets repetative. I want to assign each button a key on the keyboard... so when that key is pressed it submits a value.... for example...

"W" key is hit on the keyboard... the value "North" is submitted... or up/down/left/right.... say.. the "UP" key is hit, the value "North" is sent...

My php code is pretty much irrelavent... but basically what im asking is, how to submit a specific button when a certain key is pressed.... is this even possible???

Reply With Quote
  #2  
Old August 16th, 2005, 11:54 PM
jetblacknewyear jetblacknewyear is offline
Member
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 36 jetblacknewyear New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
all of that is probably easier to do in Flash if you can recreate your game in it.

either way, here it is

Code:
<script language="JavaScript">

function arrowPress() 
{
  if (event.keyCode == 37) 
  {
    alert("You pressed the left arrrow.");
    return false;
  } 
  else if (event.keyCode == 38) 
  {
    alert("You pressed the up arrrow.");
    return false;
  } 
  else if (event.keyCode == 39) 
  {
    alert("You pressed the right arrrow.");
    return false;
  } 
  else if (event.keyCode == 40) 
  {
    alert("You pressed the down arrrow.");
    return false;
  } 
  else 
  {
    alert("You pressed some other key.");
    return false;
  }
}

document.onkeydown = arrowPress;
</script>


it doesn't send any variables to php though. if you need any more help, or if i missed something, just post again

Reply With Quote
  #3  
Old August 17th, 2005, 12:46 PM
Pixelmixer Pixelmixer is offline
Member
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 36 Pixelmixer New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Pixelmixer
I already got the script i needed, thanks for the help tho.. and yes it would be easier in flash to do, but I hve other reasons for using php.

Thanks for the help anyways and ill close the topic.. forgot i had it up still.

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingDelphi > Closed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway