11-23-2005, 07:21 AM
well in qb4.5, well the version that i hav anyway the codes for the numpad are as follows:
1 - 4F
2 - 50
3 - 51
4 - 4B
5 - 4C
6 - 4D
7 - 47
8 - 48
9 - 49
so ya, if i input them like that, they dont work, if i input them as qb4.0 codes which are like 70-82 around there, in qb4.5, they become some of the letters
heres the code anywayso ya, thats the code, and it dont seem to work, gives an error msg "Expected: )", and won't run, plus i need a way of creating borders, because if the ball's coordinates are off the screen, it sais illegal call function and highklights the PUT command in the subroutine drawCircle, so some sort of borders would be nice
1 - 4F
2 - 50
3 - 51
4 - 4B
5 - 4C
6 - 4D
7 - 47
8 - 48
9 - 49
so ya, if i input them like that, they dont work, if i input them as qb4.0 codes which are like 70-82 around there, in qb4.5, they become some of the letters
heres the code anyway
Code:
' A simple ball moving qbasic program
' ©2005 Jimmy Jones
DEFINT A-Z
SCREEN 13
CLS
'Draw a filled circle for our sprite
CIRCLE (4, 3), 4, 4
PAINT (4, 3), 12, 4
'Set aside enough space to hold the sprite
DIM ball%(37)
'Get the sprite into the ball% array .. before clearing the screen, doofus!
GET (0, 0)-(8, 7), ball%
' Clear the screen
CLS
' Set default ballx% and bally% coordinates 'coordinates ....
ballx% = 160
bally% = 100
' Set the ball to it's default location
PUT (ballx%, bally%), ball%
PRINT ballx%; bally%
DO
GOSUB getInput
IF nothingHappened% = 0 THEN GOSUB drawCircle
IF exitloop1% = 1 THEN EXIT DO
LOOP
SLEEP
SYSTEM
getInput:
I$ = UCASE$(INKEY$) 'your characters are all uppercase.
IF I$ = "" THEN nothingHappened% = 1: RETURN ' No button being pressed? DO NOTHING!
IF I$ = CHR$(47) THEN ballx% = ballx% - 1: bally% = bally% + 1
IF I$ = CHR$(48) THEN bally% = bally% + 1
IF I$ = CHR$(49) THEN ballx% = ballx% + 1: bally% = bally% + 1
IF I$ = CHR$(4B) THEN ballx% = ballx% - 1
IF I$ = CHR$(4C) THEN ballx% = 160: bally% = 100
IF I$ = CHR$(4D) THEN ballx% = ballx% + 1
IF I$ = CHR$(4F) THEN ballx% = ballx% - 1: bally% = bally% - 1
IF I$ = CHR$(50) THEN bally% = bally% - 1
IF I$ = CHR$(51) THEN ballx% = ballx% + 1: bally% = bally% - 1
nothingHappened% = 0
'Allow quitting
IF I$ = CHR$(27) THEN exitloop1% = 1: SYSTEM
RETURN
drawCircle:
CLS
PUT (ballx%, bally%), ball%
PRINT ballx%; bally%
'What you want to do here clear the screen and redraw the ball at new location,
'Also printing the ball's x and y coordinates for unknown reason...
RETURN