Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Several programs of mine
#1
I am new to qbasic programming and am just getting the hang of it. these are some programs that i have recently made tell me what you think of them.


This one I took from one of the turtorials on www.qbasicnews.com and then i improved it
Code:
DECLARE SUB pause (sec!)
SCREEN 13
ON ERROR GOTO errorrun
DIM errorcode AS INTEGER
RANDOMIZE TIMER
DIM splash(16383)



'splash
FOR pitch = 5000 TO 2000 STEP -50
SOUND pitch, 1
NEXT

FOR y = 1 TO 20
FOR x = 1 TO 40
READ clr
LINE (x * 5, y * 5)-(x * 5 + 5, y * 5 + 5), clr

NEXT
NEXT

DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3
DATA 3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3,3,3,0,3
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,1,1
DATA 0,1,1,0,0,0,1,1,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1
DATA 1,1,0,0,0,0,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), splash
SLEEP
CLS

'FOR i = 0 TO 320 STEP 5
'pause (.005)
'PUT (i, 20), splash
'WAIT &H3DA, 8
'WAIT &H3DA, 8, 8
'LINE (0, 0)-(320, 240), 0, BF
'NEXT



3
SCREEN 0
x = 20: y = 20
x2 = 160: y2 = 180
xadj = 1: yadj = 1
x3 = 20: y3 = 100
x3adj = 1: y3adj = 1
x4 = 80: y4 = 150
x4adj = 1: y4adj = 1
x5 = 80: y5 = 43
x5adj = 1: y5adj = 1

errorcode = 0


OPEN "C:\High.txt" FOR INPUT AS #1
IF errorcode = 53 THEN
hscore = 0
ELSE
INPUT #1, hscore, hname$
CLOSE #1
END IF


CLS
PRINT "Main Menu"
PRINT "1 To Start Game"
PRINT "2 To Go To Help"
PRINT "3 To Quit"
PRINT
PRINT
PRINT "Highscore: "; hscore; "By: "; hname$

DO
option$ = INKEY$
LOOP UNTIL option$ = "1" OR option$ = "2" OR option$ = "3"

IF option$ = "1" THEN
CLS
GOTO 1
END IF

IF option$ = "2" THEN
CLS
PRINT CHR$(24); " .......... up"
PRINT CHR$(25); " .......... down"
PRINT CHR$(17); " .......... right"
PRINT CHR$(16); " .......... left"
PRINT "(Arrow keys)"
DO: LOOP WHILE INKEY$ = ""
CLS
GOTO 3
END IF


IF option$ = "3" THEN GOTO 4


1
INPUT "What Difficulty Easy or Hard (1 or 2)"; blocks
SCREEN 7, 0, 1, 0
IF blocks = 1 THEN speed = 1
IF blocks = 2 THEN speed = 5
score = 0
DO

score = score + 1
press$ = INKEY$

LINE (0, 0)-(320, 200), 0, BF
LINE (19, 19)-(301, 181), 13, B

LINE (x, y)-(x + 10, y + 10), 1, BF
PSET (x2, y2), 12
PCOPY 1, 0

IF blocks = 1 THEN


x3 = 0: y3 = 0
x3adj = 0: y3adj = 0
x4 = 0: y4 = 0
x4adj = 1: y4adj = 0
x5 = 0: y5 = 0
x5adj = 0: y5adj = 0



IF x2 <= 20 THEN xadj = speed
IF x2 >= 300 THEN xadj = -speed
IF y2 <= 20 THEN yadj = speed
IF y2 >= 180 THEN yadj = -speed
x2 = x2 + xadj: y2 = y2 + yadj
END IF
IF blocks = 2 THEN

IF x2 <= 20 THEN xadj = speed
IF x2 >= 300 THEN xadj = -speed
IF y2 <= 20 THEN yadj = speed
IF y2 >= 180 THEN yadj = -speed
x2 = x2 + xadj: y2 = y2 + yadj


IF x3 <= 20 THEN x3adj = speed
IF x3 >= 300 THEN x3adj = -speed
IF y3 <= 20 THEN y3adj = speed
IF y3 >= 180 THEN y3adj = -speed
x3 = x3 + x3adj: y3 = y3 + y3adj

PSET (x3, y3), 12
PCOPY 1, 0

IF x4 <= 20 THEN x4adj = speed
IF x4 >= 300 THEN x4adj = -speed
IF y4 <= 20 THEN y4adj = speed
IF y4 >= 180 THEN y4adj = -speed
x4 = x4 + x4adj: y4 = y4 + y4adj

PSET (x4, y4), 12
PCOPY 1, 0


IF x5 <= 20 THEN x5adj = speed
IF x5 >= 300 THEN x5adj = -speed
IF y5 <= 20 THEN y5adj = speed
IF y5 >= 180 THEN y5adj = -speed
x5 = x5 + x5adj: y5 = y5 + y5adj


PSET (x5, y5), 12
PCOPY 1, 0

END IF
SELECT CASE RIGHT$(press$, 1)
  CASE "K"
    IF x >= 25 THEN x = x - 5
  CASE "M"
    IF x <= 285 THEN x = x + 5
  CASE "H"
    IF y >= 25 THEN y = y - 5
  CASE "P"
    IF y <= 165 THEN y = y + 5
END SELECT


IF x2 > x AND x2 <= x + 10 AND y2 >= y AND y2 <= y + 10 THEN : PRINT "Game Over": GOTO 2
IF x3 > x AND x3 <= x + 10 AND y3 >= y AND y3 <= y + 10 THEN : PRINT "Game Over": GOTO 2
IF x4 > x AND x4 <= x + 10 AND y4 >= y AND y4 <= y + 10 THEN : PRINT "Game Over": GOTO 2
IF x5 > x AND x5 <= x + 10 AND y5 >= y AND y5 <= y + 10 THEN : PRINT "Game Over": GOTO 2
LOOP UNTIL press$ = "q"
2
SCREEN 0
PRINT "Your score is "; score


IF score > hscore AND blocks = 2 THEN
CLS
PRINT "Congradulations you have the high score"
INPUT "What is your name"; hname$
OPEN "C:\High.txt" FOR OUTPUT AS #1
WRITE #1, score, hname$
CLOSE #1
END IF
PRINT
PRINT
PRINT "Press space bar to continue"
DO
LOOP UNTIL INKEY$ = " "
GOTO 3
4
CLS
END





errorrun:
errorcode = ERR
RESUME NEXT

SUB pause (secs!)
now! = TIMER
o! = TIMER + secs!
DO WHILE o! > TIMER
IF now! > TIMER THEN o! = o! - 86400
LOOP


END SUB


Heres a simple one that looks pritty cool i came across this by accident

Code:
SCREEN 12
PRINT "Press space to continue to the next design"
PRINT "Press Esc to quit"
DO: LOOP WHILE INKEY$ = ""
1
CLS b
x = 0: y = 0
xadj = 1: yadj = 1

xchg = INT(RND * 20)
ychg = INT(RND * 20)
negx = INT(RND * -20)
negy = INT(RND * -20)

DO
a$ = INKEY$
color1 = INT(RND * 16)
'LINE (0, 0)-(640, 480), 0, BF
PSET (x, y), color1

IF x <= 0 THEN xadj = xchg
IF x >= 640 THEN xadj = negx
IF y <= 0 THEN yadj = ychg
IF y >= 480 THEN yadj = negy
x = x + xadj: y = y + yadj
IF a$ = CHR$(27) THEN END
IF a$ = " " THEN EXIT DO
LOOP
GOTO 1

Check em' out tell me what you think of them
his world has been connected...
Tied to the darkness.
Soon to be completely eclipsed.
There is so very much to learn...
You understand so little.
A meaningless effort.
One who knows nothing can understand nothing.
-Ansem Bringer of darkness and creator of the heartless
Reply
#2
Ummm....nice start Big Grin
\Loved the second one

1 suggestion....get out of the habit of using GOTOs instead of structured coding NOW! Please before you become like the...others...here who suffer debugging and still use them. Big Grin
i]"But...it was so beautifully done"[/i]
Reply
#3
Smile Yeah, I like that last one,. Something in PSET draws my attintion, more so when you blast it around the screen... Big Grin ... You all to check out what they look like at 500,000 FPS,.. 8) hint, try FB! :wink:

Um, Mitth, this goto is not all bad, A DO.. LOOP can take its place, but no harm done.. And mind, GOTOs saved me from a posible 126 SUB funcs one time,. but my proggy still came out 202kb,.. thats life.. heh.. :wink:
Kevin (x.t.r.GRAPHICS)

[Image: 11895-r.png]
Reply
#4
How did it save you? :-?

Are you talking about RoboRaider? Cause I played that game and it crashes cause you nest too much. :x

...Confusedilent:..... :normal: ..... :o 49 Days!!!Wooo! Big Grin
i]"But...it was so beautifully done"[/i]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)