Hi ya'll. I'm having some trouble with the keystate command. I know the number of the keys I'm checking to see whether are being pressed or not. Here's the problem. I've got a 2d bitmap, and a sprite that
moves along a X axis. When it crosses infront of a door, I've got
the name of the door assigned to a variable (PlayerLoc$). When the sprite is infront of the door, I want to be able to use the space bar, enter key or return key to open the door. Here's the code I've been using:
do
paste image 1,2,0
` Show the player
sprite 1,PlayerX,PlayerY,2
set sprite 1,0,1
show sprite 1
rem Moves the player sprite (the little spaceman) left and right on the starport bitmap, but assigns limits so
rem the player cannot go past the left edge or right edge of the map.
` Left Arrow
if keystate(203) and PlayerX >=0 rem checks to see if the left key is being pressed and the sprite X (PlayerX)
rem location is greater or equal to the zero (far left) spot on the map. If the sprite is at the far left edge
rem of the map, the player will not be allowed to move any further left.
dec PlayerX rem takes the PlayerX value and decreases it by one, thus moving the sprite left one space
wait 1 rem slows down the sprite movement left
endif rem ends the if / endif condition statement checking to see if the player can move left
` Right Arrow
if keystate(205) and PlayerX<=590 rem checks to see if the right key is being pressed and the sprite X
rem (PlayerX) is less then or equal to 590 (the far right edge of the map). If the sprite is at the far right
rem edge of the map, the player will not be allowed to move further right.
inc PlayerX rem changes PlayerX and increases it by one, thus moving the sprite right one space
wait 1 rem slows down the sprites movement right
endif rem ends the if/endif condition statement checking to see if the player can move right and is pressing
rem the right arrow key
rem Displays what each door on the starport 2 starport map is for by displaying the text at the bottom center
rem of the bitmap, and assigns a value to the PlayerLoc$ variable when the player moves the spaceman infront
rem of the door
if PlayerX > 25 and PlayerX < 60 then text 300,300,"Operations" : PlayerLoc$ = "Operations"
if PlayerX > 110 and PlayerX < 136 then text 300,300,"Personnell": PlayerLoc$ = "Personnell"
if PlayerX > 195 and PlayerX < 219 then text 300,300,"Crew Assignment" : PlayerLoc$ = "Crew Assignment"
if PlayerX > 280 and PlayerX < 308 then text 300,300,"Bank" : PlayerLoc$ = "Bank"
if PlayerX > 363 and PlayerX < 384 then text 300,300,"Ship Configuration" : PlayerLoc$ = "Ship Configuration"
if PlayerX > 449 and PlayerX < 475 then text 300,300,"Trading Post" : PlayerLoc$ = "Trading Post"
if PlayerX > 538 and PlayerX < 572 then text 300,300,"Docking Bay" : PlayerLoc$ = "Docking Bay"
if keystate(28) or keystate(57) or keystate(156) and PlayerLoc$ = "Operations" then gosub Operations : return
if keystate(28) or keystate(57) or keystate(156) and PlayerLoc$ = "Personnell" then gosub Operations_2 : return
if keystate(28) or keystate(57) or keystate(156) and PlayerLoc$ = "Crew Assignment" then gosub Operations_3 : return
if keystate(28) or keystate(57) or keystate(156) and PlayerLoc$ = "Bank" then gosub Operations_4 : return
if keystate(28) or keystate(57) or keystate(156) and PlayerLoc$ = "Ship Configuration" then gosub Operations_5 : return
if keystate(28) or keystate(57) or keystate(156) and PlayerLoc$ = "Trading Post" then gosub Operations_6 : return
if keystate(28) or keystate(57) or keystate(156) and PlayerLoc$ = "Docking Bay" then gosub Docking_Bay
rem or keystate(57) or keystate(156)
loop
when ran, the enter key (number pad) works as it should, but the space bar and the enter key near the letters only goes to "Operations". In every one of the subroutines I've got the gosub main statement at the end to bring the program back to where the sprite and bitmap are first displayed. I tried using the 'return' statement instead, but it didn't make any difference. I can remove the 2nd and 3rd keystate parts and make it work with only one keystroke, if I have to, but I was wondering if there's any alternatives to doing that?