Jump to content

QBASIC help


ninja_lord666

Recommended Posts

At school, I'm taking a course called Computer Concepts 1 where we learn the basics of all programming: QBasic. I need help on my Pong Clone that I'm making. I asked my teacher, but he doesn't know :P I know you all here are geeks in some way or another (you joined a forum called Gaming Source); so, I'm asking if someone here can help me.

 

How do you use simultaneous INKEY$ ? ex: player one pushes "p" to make his paddle move up and at the same time player two pushes "s" to make his paddle go down. However, player one hit "p" right before so only his paddle moves. I want them both to move.

 

I've bolded the part with the paddle movement

 

Here is my code so far (I cut out the player one version as it is irrelevent to my problem):

 

DEFINT A-Z

SCREEN 7

CLS

 

DATA 00,00,00,15,15,15,00,00,00

DATA 00,15,15,15,15,15,15,15,00

DATA 15,15,15,15,15,15,15,15,15

DATA 15,15,15,15,15,15,15,15,15

DATA 15,15,15,15,15,15,15,15,15

DATA 00,15,15,15,15,15,15,15,00

DATA 00,00,00,15,15,15,00,00,00

 

FOR Y = 1 TO 7

FOR X = 1 TO 9

READ Z

PSET (X, Y), Z

NEXT X

NEXT Y

DIM Ball(9 * 7)

GET (0, 0)-(9, 7), Ball

 

CLS

 

LINE (0, 0)-(0, 10), 15

DIM Paddle1(100)

GET (0, 0)-(0, 10), Paddle1(1)

 

CLS

 

LINE (0, 0)-(0, 10), 15

DIM Paddle2(100)

GET (0, 0)-(0, 10), Paddle2(1)

 

CLS

 

CONST XMax = 320

CONST YMax = 200

 

INPUT "Do you want (1) Player or (2) Player"; Q

ON Q GOTO 7, 2

 

 

 

2 SCREEN 7, , 1, 0

 

5 S1 = 0: S2 = 0

6 CLS

LOCATE 1, 1: PRINT "Player 1: "; S1, "Player 2: "; S2

 

IF S1 = 21 THEN

CLS

PRINT "Player 1: "; S1, "Player 2: "; S2

PRINT "Player 1 wins!"

INPUT "Play again? (Y/N)"; Q$

IF Q$ = "Y" OR Q$ = "y" THEN

GOTO 5

END IF

END

END IF

 

IF S2 = 21 THEN

CLS

PRINT "Player 1: "; S1, "Player 2: "; S2

PRINT "Player 2 wins!"

INPUT "Play again? (Y/N)"; Q$

IF Q$ = "Y" OR Q$ = "y" THEN

GOTO 5

END IF

END

END IF

 

A = 100

B = 100

X = 160

Y = 100

 

DX = 2

DY = 2

 

DO

P$ = INKEY$

IF P$ = CHR$(27) THEN END

 

PUT (XMax - 5, A), Paddle1(1)

PUT (5, B), Paddle2(1)

PUT (X, Y), Ball

 

WAIT &H3DA, 8

PCOPY 1, 0

 

BA = A

BB = B

BX = X

BY = Y

 

IF LCASE$(P$) = "p" AND A > 7 THEN

A = A - 6

END IF

 

IF P$ = ";" AND A < YMax - 18 THEN

A = A + 6

END IF

 

IF LCASE$(P$) = "w" AND B > 7 THEN

B = B - 6

END IF

 

IF LCASE$(P$) = "s" AND B < YMax - 18 THEN

B = B + 6

END IF

 

X = X + DX

Y = Y + DY

 

IF X > XMax - 12 THEN

S2 = S2 + 1

GOTO 6

END IF

 

IF X < 2 THEN

S1 = S1 + 1

GOTO 6

END IF

 

IF Y > YMax - 13 THEN

DY = -2

END IF

 

IF Y < 4 THEN

DY = 2

END IF

 

IF X > XMax - 17 AND Y < A + 8 AND Y > A - 8 THEN

DX = -2

END IF

 

IF X < 6 AND Y < B + 8 AND Y > B - 8 THEN

DX = 2

END IF

 

FOR I = 1 TO 30000

FOR J = 1 TO 5

NEXT

NEXT

 

PUT (XMax - 5, BA), Paddle1(1)

PUT (5, BB), Paddle2(1)

PUT (BX, BY), Ball

LOOP

Link to comment
Share on other sites

Write a C compiler and do it in C.

The idea is to do it in QBASIC. We aren't learning C/C++ in Computer Concepts 1. Throught this semester, we will be learning only QBASIC. Next year in Computer Concepts 2, we will learn Java, and in AP Computer Science (senior year), I'm not entirely sure yet...possibly C/C++...

Any-hoo, right now, I'm supposed to work with QBASIC.

Link to comment
Share on other sites

Even when I toyed around with it, I wasn't much good with QBASIC, and have been turned off to most programming languages because of it. Suprised the teacher of the course doesn't even know, they should damnit, if they can't be bothered to learn themselves, why should they try teaching it? Anyway, the best suggestion I could offer is to see if you can find it being used in another Qbasic program, and figure out the syntax. I think nibbles has what you're looking for, (can't remember if it had 2 player simultanious mode or not). Honestly, don't think there's anyone who uses that language any more, or any sources where you can download (or otherwise obtain) non-copywrited examples of the coding. You may get lucky with a few google searches though. I'm pretty sure that just seeing the code to see how something is done is fair game, just don't steal their work.

 

If you don't have much luck there, you might want to check out some of your local college libraries, they might have some books from the 1970's (and yes, there are a few) that could explain how to get 2 functions to work at the same time, or how to make it alternate between the two quickly. I'm assuming the grade is based on just having a functional item, not making a kickass game.

Link to comment
Share on other sites

Write the C compiler in QBASIC.

Uhh...the point is to make the program in QBASIC...You don't get it do you?

 

That looks like the most boring programming language ever written! I'm glad I didn't take it.

 

Sorry I can't be of help Ninja

That's ok Dark0ne. I know it's quite boring. I'll be glad when I can move onto Java next year.

 

...Anyway, the best suggestion I could offer is to see if you can find it being used in another Qbasic program, and figure out the syntax. I think nibbles has what you're looking for, (can't remember if it had 2 player simultanious mode or not). Honestly, don't think there's anyone who uses that language any more, or any sources where you can download (or otherwise obtain) non-copywrited examples of the coding. You may get lucky with a few google searches though. I'm pretty sure that just seeing the code to see how something is done is fair game, just don't steal their work.

That's what I've been trying to do, but no luck so far. I'll try some more programs though.

 

 

...I'm assuming the grade is based on just having a functional item, not making a kickass game.

Actually, in the course, we don't have much...direction. Occasinally we get a lecture or an assignment (which he never collects :huh: ), but overall, we just do whatever. What I'm trying to say is, I'm making this just because I want to :D .

Link to comment
Share on other sites

I'll be glad when I can move onto Java next year.

 

You're be glad now, but you won't be glad when you hit Java. It sucks the big one.

 

What I'm trying to say is, I'm making this just because I want to

 

Oh, you're one of those :P

Link to comment
Share on other sites

You're be glad now, but you won't be glad when you hit Java. It sucks the big one.

That's what you think...I seem to believe you...lol

 

Oh, you're one of those :P

Just what are you implying? :D lol

Link to comment
Share on other sites

If you really want to learn about computers, then my suggestion is that you repress all knowledge of QBASIC immediately, with the exception of the bare minimum you need to pass that class. QBASIC is a completely brain-damaged language, and it ends up putting fundamentally misguided concepts about computers into the minds of whoever learns it --- hence why your instructor himself is avoiding QBASIC like the plague.

 

After that, wipe your hard-drive clean and install only a very bare-bones UNIX system with a C compiler. Add in screen and learn how to use it; avoid X11 at all costs (for now). If you want to do anything that you can't do with sed and vi, write a program for it in C, partially-compile it, and then edit the assembly language code by hand. You'll be a world-class programmer in no time.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...