Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mouse input/movement by numpad PROBLEMS
#31
Quote:well i got it my way and its faster, not like ill have more then 1 plane or anything, thnx anyway
What is this "your way"?


And Aga: No wonder you always write unformatted code... you're drunk!
Reply
#32
who writes unformatted code and is drunk, AGA or me???
Reply
#33
Apparently both of us, sir.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#34
Who said that?

I clearly wrote that sentence to Aga.
Reply
#35
well i learnt pretty much from AGA, he helped me with another project, that is on hold because of my current one, which he also helped me with, quick question AGA, in the code u wrote for me u use the following

Code:
DO
GOSUB getInput
IF nothingHappened% = 0 THEN GOSUB drawChar
IF exitloop1% = 1 THEN EXIT DO
LOOP

SLEEP
SYSTEM

getInput:
I$ = UCASE$(INKEY$) 'your characters are all uppercase.
IF I$ = "" THEN nothingHappened% = 16: RETURN   ' No button being pressed? DO NOTHING!
PUT (charx%, chary%), char%     ' cover the old char
IF I$ = CHR$(0) + "H" THEN chary% = chary% - 16
IF I$ = CHR$(0) + "P" THEN chary% = chary% + 16
IF I$ = CHR$(0) + "M" THEN charx% = charx% + 16
IF I$ = CHR$(0) + "K" THEN charx% = charx% - 16
IF I$ = " " THEN charx% = 160:    chary% = 100

IF charx% < 0 THEN LET charx% = 0
IF chary% < 4 THEN LET chary% = 4
IF charx% > 304 THEN LET charx% = 304
IF chary% > 180 THEN LET chary% = 180

nothingHappened% = 0
IF I$ = CHR$(27) THEN exitloop1% = 1: SYSTEM 'Allow quitting
RETURN
now i wanted to change how it ends, but im not sur how it ends or even how the loop keeps looping, its wierd, it works, but i dont know how. and the UCASE$ thing, i changed my input to just the arrow keys, so can i delete that, it works fine, but y was it used for the numpad???
Reply
#36
now i wanted to change how it ends, but im not sur how it ends or even how the loop keeps looping, its wierd, it works, but i dont know how.

Quote:and the UCASE$ thing, i changed my input to just the arrow keys, so can i delete that, it works fine, but y was it used for the numpad???

You had letters initially.

The logic is as follows.

Loop:

DO...LOOP.. it loops what is inside the loop until exitloop1% = 1, and then it immediately exits out. (EXIT DO) Then what happens afterwards is after the "LOOP" statement. In this case it's SLEEP, then SYSTEM.

getInput and drawChar are (GO)subs that the loop calls to. The code runs until the RETURN, which sends it back to the initial location of the sub call.

Nothinghappened%:
Assuming you can change only one object at a time, nothingHappened% changes to 0 if nothing happened to the screen. This will change if you have other effects besides the user moving the character, so you can either:

*Redraw a frame for each cycle anyway.
*Change nothinghappened to "somethinghappened" and set it intially to 0. Set it to 1 if the user sends input that changes the visual screen, and modify "IF nothingHappened% = 0 THEN GOSUB drawChar " to IF "nothingHappened% = 1 THEN GOSUB drawChar "
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#37
i think the code is incomplete, ehre it is again the rite way i hope

Code:
' A simple character moving program

DEFINT A-Z

SCREEN 13
CLS

' This is the srite's design
PSET (4, 1), 8: PSET (7, 1), 8: PSET (8, 1), 8: PSET (12, 1), 8: PSET (13, 1), 8: PSET (3, 2), 8: PSET (4, 2), 14: PSET (5, 2), 8: PSET (6, 2), 8: PSET (7, 2), 14: PSET (8, 2), 14: PSET (9, 2), 8: PSET (11, 2), 8: PSET (12, 2), 14: PSET (13, 2), 8: _
    PSET (3, 3), 8: PSET (4, 3), 14: PSET (5, 3), 14: PSET (6, 3), 14: PSET (7, 3), 14: PSET (8, 3), 14: PSET (9, 3), 14: PSET (10, 3), 8: PSET (11, 3), 14: PSET (12, 3), 14: PSET (13, 3), 14: PSET (14, 3), 8: PSET (15, 3), 8: PSET (2, 4), 8: PSET ( _
3, 4), 14: PSET (4, 4), 14: PSET (5, 4), 14: PSET (6, 4), 14: PSET (7, 4), 14: PSET (8, 4), 14: PSET (9, 4), 8: PSET (10, 4), 14: PSET (11, 4), 14: PSET (12, 4), 14: PSET (13, 4), 14: PSET (14, 4), 14: PSET (15, 4), 14: PSET (16, 4), 8: PSET (3, 5) _
, 8: PSET (4, 5), 14: PSET (5, 5), 8: PSET (6, 5), 14: PSET (7, 5), 66: PSET (8, 5), 66: PSET (9, 5), 14: PSET (10, 5), 14: PSET (11, 5), 14: PSET (12, 5), 8: PSET (13, 5), 14: PSET (14, 5), 14: PSET (15, 5), 8: PSET (4, 6), 8: PSET (5, 6), 8: PSET  _
(6, 6), 66: PSET (7, 6), 66: PSET (8, 6), 66: PSET (9, 6), 66: PSET (10, 6), 14: PSET (11, 6), 14: PSET (12, 6), 8: PSET (13, 6), 14: PSET (14, 6), 8: PSET (5, 7), 8: PSET (6, 7), 66: PSET (7, 7), 16: PSET (8, 7), 66: PSET (9, 7), 66: PSET (10, 7),  _
16: PSET (11, 7), 66: PSET (12, 7), 8: PSET (13, 7), 8: PSET (5, 8), 8: PSET (6, 8), 66: PSET (7, 8), 16: PSET (8, 8), 66: PSET (9, 8), 66: PSET (10, 8), 16: PSET (11, 8), 66: PSET (12, 8), 8: PSET (3, 9), 8: PSET (4, 9), 8: PSET (5, 9), 66: PSET (6 _
, 9), 8: PSET (7, 9), 66: PSET (8, 9), 66: PSET (9, 9), 66: PSET (10, 9), 66: PSET (11, 9), 8: PSET (12, 9), 66: PSET (13, 9), 8: PSET (14, 9), 8: PSET (2, 10), 8: PSET (3, 10), 66: PSET (4, 10), 66: PSET (5, 10), 64: PSET (6, 10), 15: PSET (7, 10) _
, 8: PSET (8, 10), 8: PSET (9, 10), 8: PSET (10, 10), 8: PSET (11, 10), 15: PSET (12, 10), 64: PSET (13, 10), 66: PSET (14, 10), 66: PSET (15, 10), 8: PSET (1, 11), 8: PSET (2, 11), 66: PSET (3, 11), 64: PSET (4, 11), 64: PSET (5, 11), 64: PSET (6,  _
11), 15: PSET (7, 11), 15: PSET (8, 11), 15: PSET (9, 11), 15: PSET (10, 11), 15: PSET (11, 11), 15: PSET (12, 11), 64: PSET (13, 11), 64: PSET (14, 11), 64: PSET (15, 11), 66: PSET (16, 11), 8: PSET (1, 12), 8: PSET (2, 12), 64: PSET (3, 12), 64:  _
PSET (4, 12), 8: PSET (5, 12), 8: PSET (6, 12), 8: PSET (7, 12), 15: PSET (8, 12), 15: PSET (9, 12), 15: PSET (10, 12), 15: PSET (11, 12), 8: PSET (12, 12), 8: PSET (13, 12), 8: PSET (14, 12), 64: PSET (15, 12), 64: PSET (16, 12), 8: PSET (1, 13), 8 _
: PSET (2, 13), 8: PSET (3, 13), 8: PSET (5, 13), 8: PSET (6, 13), 9: PSET (7, 13), 8: PSET (8, 13), 8: PSET (9, 13), 8: PSET (10, 13), 8: PSET (11, 13), 9: PSET (12, 13), 8: PSET (14, 13), 8: PSET (15, 13), 8: PSET (16, 13), 8: PSET (5, 14), 8:  _
PSET (6, 14), 9: PSET (7, 14), 9: PSET (8, 14), 9: PSET (9, 14), 9: PSET (10, 14), 9: PSET (11, 14), 9: PSET (12, 14), 8: PSET (5, 15), 8: PSET (6, 15), 115: PSET (7, 15), 115: PSET (8, 15), 114: PSET (9, 15), 115: PSET (10, 15), 115: PSET (11, 15) _
, 114: PSET (12, 15), 8: PSET (5, 16), 8: PSET (6, 16), 115: PSET (7, 16), 115: PSET (8, 16), 114: PSET (9, 16), 115: PSET (10, 16), 115: PSET (11, 16), 114: PSET (12, 16), 8:

DIM char%(129)                  'Set aside enough space to hold the sprite
GET (1, 1)-(16, 16), char%      'Get the sprite into the ball% array

CLS

PAINT (0, 0), 2                 ' Make background
FOR x = 160 TO 175
FOR y = 100 TO 115
PSET (x, y), 0
NEXT y
NEXT x
DIM back%(32001)                'Set aside enough space to hold the sprite
GET (0, 0)-(319, 199), back%    'Get the sprite into the back% array

CLS

charx% = 160: chary% = 100      ' Set default ballx% and bally% coordinates
PUT (0, 0), back%
PUT (charx%, chary%), char%     ' Set the ball to it's default location
PRINT charx%; chary%            ' print the char's location

DO
GOSUB getInput
IF nothingHappened% = 0 THEN GOSUB drawChar
IF exitloop1% = 1 THEN EXIT DO
LOOP

SLEEP
SYSTEM

getInput:
I$ = INKEY$
IF I$ = "" THEN nothingHappened% = 1: RETURN   ' No button being pressed? DO NOTHING!
PUT (charx%, chary%), char%     ' cover the old char
IF I$ = CHR$(0) + "H" THEN chary% = chary% - 16
IF I$ = CHR$(0) + "P" THEN chary% = chary% + 16
IF I$ = CHR$(0) + "M" THEN charx% = charx% + 16
IF I$ = CHR$(0) + "K" THEN charx% = charx% - 16
IF I$ = " " THEN charx% = 160:    chary% = 100

IF charx% < 0 THEN LET charx% = 0
IF chary% < 4 THEN LET chary% = 4
IF charx% > 304 THEN LET charx% = 304
IF chary% > 180 THEN LET chary% = 180

nothingHappened% = 0
IF I$ = CHR$(27) THEN exitloop1% = 1: SYSTEM 'Allow quitting
'IF I$ = CHR$(27) THEN GOSUB TheEnd
RETURN


drawChar:

PUT (charx%, chary%), char%     ' replace the char
LOCATE 1, 1
PRINT charx%; chary%            ' print the char's location

RETURN

i got rid of the UCASE$, its uneeded with arrows now so thats solved, but i still dont get the

Code:
SLEEP
SYSTEM

now i also want to change the ending to a wierd fill and i figured something like this
Code:
' The ending
PSET (1, 1), 16
DIM blank%(8)
GET (0, 0)-(1, 1), blank%
FOR x = 1 TO 320
FOR y = 1 TO 200
PUT (x, y), blank%
NEXT y
NEXT x
PRINT "Thanks For Playing, Press ESC"
IF I$ = CHR$(27) THEN END
now i put that at the bottom of the code, but it doesnt do anything, this is too wierd

so anyway, so far tats wat i want to get working, plus if u run it like the first segment of code is, ull notice that the 16x16 black part on the background is the only part where the char looks how it should, other than that, when he goes on the green, its colors gets messed up and become all purply and stuff. thats my problems for tonite anyway[/code]
Reply
#38
Code:
PSET (4, 1), 8: PSET (7, 1), 8: PSET (8, 1), 8: PSET (12, 1), 8: PSET (13, 1), 8: PSET (3, 2), 8: PSET (4, 2), 14: PSET (5, 2), 8: PSET (6, 2), 8: PSET (7, 2), 14: PSET (8, 2), 14: PSET (9, 2), 8: PSET (11, 2), 8: PSET (12, 2), 14: PSET (13, 2), 8: _
    PSET (3, 3), 8: PSET (4, 3), 14: PSET (5, 3), 14: PSET (6, 3), 14: PSET (7, 3), 14: PSET (8, 3), 14: PSET (9, 3), 14: PSET (10, 3), 8: PSET (11, 3), 14: PSET (12, 3), 14: PSET (13, 3), 14: PSET (14, 3), 8: PSET (15, 3), 8: PSET (2, 4), 8: PSET ( _
3, 4), 14: PSET (4, 4), 14: PSET (5, 4), 14: PSET (6, 4), 14: PSET (7, 4), 14: PSET (8, 4), 14: PSET (9, 4), 8: PSET (10, 4), 14: PSET (11, 4), 14: PSET (12, 4), 14: PSET (13, 4), 14: PSET (14, 4), 14: PSET (15, 4), 14: PSET (16, 4), 8: PSET (3, 5) _
, 8: PSET (4, 5), 14: PSET (5, 5), 8: PSET (6, 5), 14: PSET (7, 5), 66: PSET (8, 5), 66: PSET (9, 5), 14: PSET (10, 5), 14: PSET (11, 5), 14: PSET (12, 5), 8: PSET (13, 5), 14: PSET (14, 5), 14: PSET (15, 5), 8: PSET (4, 6), 8: PSET (5, 6), 8: PSET  _
(6, 6), 66: PSET (7, 6), 66: PSET (8, 6), 66: PSET (9, 6), 66: PSET (10, 6), 14: PSET (11, 6), 14: PSET (12, 6), 8: PSET (13, 6), 14: PSET (14, 6), 8: PSET (5, 7), 8: PSET (6, 7), 66: PSET (7, 7), 16: PSET (8, 7), 66: PSET (9, 7), 66: PSET (10, 7),  _
16: PSET (11, 7), 66: PSET (12, 7), 8: PSET (13, 7), 8: PSET (5, 8), 8: PSET (6, 8), 66: PSET (7, 8), 16: PSET (8, 8), 66: PSET (9, 8), 66: PSET (10, 8), 16: PSET (11, 8), 66: PSET (12, 8), 8: PSET (3, 9), 8: PSET (4, 9), 8: PSET (5, 9), 66: PSET (6 _
, 9), 8: PSET (7, 9), 66: PSET (8, 9), 66: PSET (9, 9), 66: PSET (10, 9), 66: PSET (11, 9), 8: PSET (12, 9), 66: PSET (13, 9), 8: PSET (14, 9), 8: PSET (2, 10), 8: PSET (3, 10), 66: PSET (4, 10), 66: PSET (5, 10), 64: PSET (6, 10), 15: PSET (7, 10) _
, 8: PSET (8, 10), 8: PSET (9, 10), 8: PSET (10, 10), 8: PSET (11, 10), 15: PSET (12, 10), 64: PSET (13, 10), 66: PSET (14, 10), 66: PSET (15, 10), 8: PSET (1, 11), 8: PSET (2, 11), 66: PSET (3, 11), 64: PSET (4, 11), 64: PSET (5, 11), 64: PSET (6,  _
11), 15: PSET (7, 11), 15: PSET (8, 11), 15: PSET (9, 11), 15: PSET (10, 11), 15: PSET (11, 11), 15: PSET (12, 11), 64: PSET (13, 11), 64: PSET (14, 11), 64: PSET (15, 11), 66: PSET (16, 11), 8: PSET (1, 12), 8: PSET (2, 12), 64: PSET (3, 12), 64:  _
PSET (4, 12), 8: PSET (5, 12), 8: PSET (6, 12), 8: PSET (7, 12), 15: PSET (8, 12), 15: PSET (9, 12), 15: PSET (10, 12), 15: PSET (11, 12), 8: PSET (12, 12), 8: PSET (13, 12), 8: PSET (14, 12), 64: PSET (15, 12), 64: PSET (16, 12), 8: PSET (1, 13), 8 _
: PSET (2, 13), 8: PSET (3, 13), 8: PSET (5, 13), 8: PSET (6, 13), 9: PSET (7, 13), 8: PSET (8, 13), 8: PSET (9, 13), 8: PSET (10, 13), 8: PSET (11, 13), 9: PSET (12, 13), 8: PSET (14, 13), 8: PSET (15, 13), 8: PSET (16, 13), 8: PSET (5, 14), 8:  _
PSET (6, 14), 9: PSET (7, 14), 9: PSET (8, 14), 9: PSET (9, 14), 9: PSET (10, 14), 9: PSET (11, 14), 9: PSET (12, 14), 8: PSET (5, 15), 8: PSET (6, 15), 115: PSET (7, 15), 115: PSET (8, 15), 114: PSET (9, 15), 115: PSET (10, 15), 115: PSET (11, 15) _
, 114: PSET (12, 15), 8: PSET (5, 16), 8: PSET (6, 16), 115: PSET (7, 16), 115: PSET (8, 16), 114: PSET (9, 16), 115: PSET (10, 16), 115: PSET (11, 16), 114: PSET (12, 16), 8:
Tell me how you're going to do this with a larger sprite... say 320x200 :o

:lol:
Reply
#39
Programming is all about THINKING.. T H I N K I N G ..... (hehe, just a reminder.. thinking...)

If it doesn't work try to isolate the code. Just try this:

Code:
' The ending
PSET (1, 1), 16
DIM blank%(8)
GET (0, 0)-(1, 1), blank%
FOR x = 1 TO 320
FOR y = 1 TO 200
PUT (x, y), blank%
NEXT y
NEXT x
PRINT "Thanks For Playing, Press ESC"
IF I$ = CHR$(27) THEN END

Now see if it works. Does it work? If it doesn't, separate it into even smaller sections, and/or try to reason out your code.

Example:
Code:
PRINT "Thanks For Playing, Press ESC"
IF I$ = CHR$(27) THEN END

This is an example of code that has not been thought through. It's ok, I do this sometimes too (but I try to avoid it). What you really want is:

Code:
PRINT "Thanks For Playing, Press ESC"
DO
IF INKEY$ = CHR$(27) THEN END
LOOP

You didn't have a loop to keep checking for the escape being pressed, and I$ = INKEY$ just assigns I$ to INKEY$. There is no special use for I$ by itself. In your original case I$ would remain as the last key pressed. THE LAST KEY PRESSED IS I$. FURTHERMORE I made a mistake by saying ": SYSTEM" after "exitloop1% = 1", causing the thing to terminate prematurely. You copied this mistake.

Last thing:
You commented out " 'IF I$ = CHR$(27) THEN GOSUB TheEnd ".. You're not supposed to do that as a matter of principle.. it should exit out of the sub and then all the way back to the main function. This principle becomes absolute reality when you want to do something after the exiting out. Now I'm sure you know what I'll say: If you exit out of TheEnd at some point you'll end up back in the getInput sub instead of at the main program.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#40
So so give us an update..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)