Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with the w,a,s,d commands
#1
Hey guys, i was looking at the tutorials for games.

Now there is this one thing where we can use the program to move a pixel. I got the program running only the pixel is not moving when i type the w or a or s or d commands. Any ideas why?

SCREEN 13
x = 50
y = 50
DO
press$ = INKEY$
PSET (x, y), x
IF press$ = "w" THEN y = y - 1
IF press$ = "s" THEN y = y + 1
IF press$ = "d" THEN x = x + 1
IF press$ = "a" THEN x = x - 1
LOOP UNTIL press$ = "q"

Hey and also when i was trying out the graphics programs after i press f-5 and i get the colors and shapes etc, when i exit and i come back to the program screen, for some reason i cant do anything on it. Not even backspacing what i got. All that works is when i move the mouse to the x to exit qbasic. Then i gotta open it back again?? Is this supposed to happen
ill Gates time is almost up.... i am taking over
Reply
#2
Nice to see your learning more, snakeZ.
Well, you ARE moving the pixel, it works fine for me (make sure you are not typing caps [caps-lock])

Also you are not erasing the pixel after you move it so it draws a line. Just erase and redraw.

Code:
SCREEN 13
x = 50
y = 50
DO                    'DO
press$ = INKEY$       'Get Input
PSET (x, y), x        'Draw
ox = x: oy = y        'Store
IF press$ = CHR$(0) + "H" THEN y = y - 1 'Change + Check
IF press$ = CHR$(0) + "P" THEN y = y + 1
IF press$ = CHR$(0) + "M" THEN x = x + 1
IF press$ = CHR$(0) + "K" THEN x = x - 1
WAIT &H3DA, 8       'Reduces flicker
PSET (ox, oy), 0    'Erase
LOOP UNTIL press$ = "q"  'Loop until q is pressed

See what that does. BTW....Use the arrow keys.... :wink:
i]"But...it was so beautifully done"[/i]
Reply
#3
Quote:Hey and also when i was trying out the graphics programs after i press f-5 and i get the colors and shapes etc, when i exit and i come back to the program screen, for some reason i cant do anything on it. Not even backspacing what i got. All that works is when i move the mouse to the x to exit qbasic. Then i gotta open it back again?? Is this supposed to happen
Ah I see you are running qbasic in windowed mode. Press alt-enter to make it go full screen. It's a DOS program let it run like it should be run =P
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
mhm :wink:
i]"But...it was so beautifully done"[/i]
Reply
#5
Smile Yeah, I can't even get it to work period in widow mode, IDE and the test screen thing... :wink:

But, when you need letter commands, (Moving stuff use arrows, mitth posted that above) but for optional controls that need letters.. use this to prevent it messing up in case cap lock is on, off, or what ever:

(Case insensitive codeSmile
Code:
IF UCASE$(press$) = "W" THEN...
IF UCASE$(press$) = "A" THEN..

Notice that tho, UCASE$(press$) makes the press$ sting all caps whether or not cap lock is on or off, then just check for capital letters...
Example

Player presses key(INKEY$ = "a")
Promt press$(press$ = INKEY$)
Cap press$ (UCASE$(press$))
press$ now = "A"
Check for "A"

Input can also be "A" it will just stay cap, so case insesitive!!!! Big Grin

Can also use LCASE$() which makes selected inputs (in this case press$) lower case.. (e.i. press "A" it chages it to "a" and if press is "a" it stays "a") :wink:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#6
Quote:UCASE$(press$) makes the press$ sting all caps
lol :lol:

I don't see the benifit of using w,a,s,d when you can use arrow keys...unless you doing 2 playes or Unreal Tournament lol
i]"But...it was so beautifully done"[/i]
Reply
#7
Thanks guys i will give it a try later. Inform you how it turn out.

PS: Can any game be created?? Like a third person shooter??
ill Gates time is almost up.... i am taking over
Reply
#8
Quote:Thanks guys i will give it a try later. Inform you how it turn out.

PS: Can any game be created?? Like a third person shooter??
Yeah.

This is made with QB 4.5
http://rel.betterwebber.com/junk.php?id=24
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#9
Ya, I read that tut.

The only limit to your games is:
1. You imagination
2. DOS

:wink:
i]"But...it was so beautifully done"[/i]
Reply
#10
Quote:
Rattra Wrote:UCASE$(press$) makes the press$ sting all caps
lol :lol:

I don't see the benifit of using w,a,s,d when you can use arrow keys...unless you doing 2 playes or Unreal Tournament lol

Yeah, duh, heh, I was on multible funcs other than arrow keys, like Player2, or Item/world functions.. ect.. So to keep it getting mixed up, its nice to know how to make a game case insensitive.. its also good to check for "8" "4" "6" "2" for those that use NUM pad and forget to turn off NUM LOCK,.. heh heh.. :wink:

Good luck!! To SnakeZ..
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)