YAY!! I made a sucky game...I'm so proud of myself

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
Raspberrypicker
Veteran
Posts: 55
Joined: Thu Aug 02, 2007 4:54 pm
Location: Florida

YAY!! I made a sucky game...I'm so proud of myself

Post by Raspberrypicker » Tue Aug 21, 2007 5:29 pm

It took me long enough, but I finally finished my first game.
It isn't that good, but I was just doing it for the practice.

Please revise my code for any errors...cuz I kno I probably did a hundred things wrong, lol.

Code: Select all

DECLARE SUB delay (wat!)
DECLARE SUB lose ()
DECLARE SUB playermove (playery!, playerx!, keyed$)
CLS

TIMER ON

playerx = 40
playery = 23
row = 12
column = 79
count = 0
move = 0

DO

 start = TIMER
 count = count + 1

 LOCATE 12, 35
 PRINT "GET READY"

 IF count = 1 THEN
  'lvl 1 *******************************************************************************
  PLAY "a8 b8 g8"
  CLS
  LOCATE 1, 1
  PRINT "lvl 1"
  PRINT "Avoid the ASCII characters using the arrow keys"

  FOR column = 1 TO 79

   CALL playermove(playery, playerx, keyed$)

   LOCATE row, column
   PRINT " "; CHR$(141)
   LOCATE row + 1, column
   PRINT " "; CHR$(140); CHR$(140)
   LOCATE row + 2, column
   PRINT " "; CHR$(144)
   wat = .01
   CALL delay(wat)
  
   IF (row = playery OR row + 1 = playery OR row + 2 = playery) AND column = playerx THEN lose

  NEXT
 END IF

 IF count = 2 THEN
  'lvl 2 ******************************************************************************
  PLAY "a8 b8 g8"
  COLOR 15, 1
  CLS
  LOCATE 1, 1
  PRINT "lvl 2"
  PRINT "READY??                                        "
 
  READ row, row1, row2, row3, row4, row5, row6, row7, row8, row9, row10

  FOR column = 1 TO 79

   CALL playermove(playery, playerx, keyed$)

   LOCATE row, column
   PRINT " "; CHR$(175)
   LOCATE row1, column
   PRINT " "; CHR$(175)
   LOCATE row2, column
   PRINT " "; CHR$(175)
   LOCATE row3, column
   PRINT " "; CHR$(175)
   LOCATE row4, column
   PRINT " "; CHR$(175)
   LOCATE row5, column
   PRINT " "; CHR$(175)
   LOCATE row6, column
   PRINT " "; CHR$(175)
   LOCATE row7, column
   PRINT " "; CHR$(175)
   LOCATE row8, column
   PRINT " "; CHR$(175)
   LOCATE row9, column
   PRINT " "; CHR$(175)
   LOCATE row10, column
   PRINT " "; CHR$(175)
   wat = .001
   CALL delay(wat)

   IF (row = playery OR row1 = playery OR row2 = playery OR row3 = playery OR row4 = playery OR row5 = playery OR row6 = playery OR row7 = playery OR row8 = playery OR row9 = playery OR row10 = playery) AND (column = playerx) THEN lose

  NEXT
 
 END IF

 IF count = 3 THEN
  'lvl 3 ******************************************************************************
  PLAY "a8 b8 g8"
  COLOR 15, 4
  CLS
  LOCATE 1, 1
  PRINT "lvl 3"
  PRINT "TAKE COVER!!!!!!!!!!                                        "
  FOR I = 4000 TO 1000 STEP -5
   SOUND I, .1
  NEXT
 
  column = 1
  FOR row = 1 TO 23

   CALL playermove(playery, playerx, keyed$)

   LOCATE row, column
   PRINT "                                                                                         "
   PRINT SPACE$(5); STRING$(34, CHR$(173)); SPACE$(1); STRING$(38, CHR$(173))
   wat = .05
   CALL delay(wat)
  
   IF (playerx > 5 AND playerx <> 40 AND playerx < 78) THEN
    IF (row = playery) THEN lose
   END IF

  NEXT

 END IF

 IF count = 4 THEN
  'lvl 4 ******************************************************************************
  PLAY "a8 b8 g8"
  COLOR 14, 0
  CLS
  LOCATE 1, 1
  PRINT "lvl 4"
  PRINT "Are you feeling lucky? Move your guy so he lands in the gap, then press g"
 
  b$ = CHR$(219)

  row = 1
  column = 1

  DO
   CALL playermove(playery, playerx, keyed$)
  LOOP UNTIL keyed$ = "g"

  FOR row = 1 TO 23

   LOCATE row, 1
   COLOR 4, 0
   PRINT STRING$(80, b$)

  NEXT

  LOCATE 4, 1
  PRINT STRING$(10, b$); SPACE$(3); STRING$(67, b$)
  COLOR 15, 1
  LOCATE playery, playerx
  PRINT CHR$(153)

  IF (playery <> 4) AND (playerx <> 11 OR playerx <> 12 OR playerx <> 13) THEN lose
  END IF

  IF count = 5 THEN
   'last lvl ******************************************************************************
   PLAY "a8 b8 g8"
   COLOR 11, 1
   CLS
   LOCATE 1, 1
   PRINT "last lvl"
   PRINT "Thanx for playing my nooby game!"
   PRINT "Just move your guy to the exit and you win."

   DO
    LOCATE 22, 67
    PRINT "E"
    CALL playermove(playery, playerx, keyed$)
    IF (playery = 22) AND (playerx = 67) THEN
     LOCATE 3, 1
     PRINT "                                                               "
     PRINT "Did I trick you???                                                  "
     PRINT "I kno, it was kind of cheap. :P                                      "
     PRINT "But technically, E is an ASCII chracter"
     lose
    END IF
   LOOP                   'notice the loop...there is no way of winning in case the hardcore gamers were wondering

  END IF

LOOP UNTIL keyed$ = CHR$(27)

DATA 13,14,15,16,17,18,19,20,21,22,23

SUB delay (wat)
        StartingTime! = TIMER

        DO
        LOOP WHILE TIMER - StartingTime! < wat
END SUB

SUB lose
        LOCATE 24, 1
        PRINT "HA HA! The ASCII symbols caught you!"
        PRINT "YOu LOsE!"
        PLAY "a8 b8 c4"
        END
END SUB

SUB playermove (playery, playerx, keyed$)
        keyed$ = INKEY$

        oldplayery = playery
        oldplayerx = playerx

        IF keyed$ = CHR$(0) + CHR$(72) THEN playery = playery - 1
        IF keyed$ = CHR$(0) + CHR$(80) THEN playery = playery + 1
        IF keyed$ = CHR$(0) + CHR$(75) THEN playerx = playerx - 1
        IF keyed$ = CHR$(0) + CHR$(77) THEN playerx = playerx + 1
        IF keyed$ = CHR$(27) THEN END

        LOCATE oldplayery, oldplayerx
        PRINT " "

        LOCATE playery, playerx
        PRINT CHR$(153)

        IF (playery <1>= 24) OR (playerx <1>= 80) THEN
         playery = oldplayery
         LOCATE 24, 1
         PRINT "Oh no!!!!!!"
         PRINT "You fell off the face of the earth!!"
         END
        END IF
END SUB
Fruit Pickin'

User avatar
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 » Tue Aug 21, 2007 5:36 pm

okay i took me a few times to understand level 3
but then i understood...LOL

good job....


now go forth and multiply thy new gaming skills....

bringth forth a full fledged arcade game in mario style
by thursday please.......


:)

User avatar
Raspberrypicker
Veteran
Posts: 55
Joined: Thu Aug 02, 2007 4:54 pm
Location: Florida

Post by Raspberrypicker » Tue Aug 21, 2007 5:58 pm

:shock: By Thursday!? No way...this game took me like 5 days to make.

This is how I programmed the thing:
I programmed some code, then I couldn't figure something out, got frustrated, and went to sleep.

The next day I was thinking about my program, figured out my problem, went to fix it, then type in some more code, not be able to figure something else out, get frustrated again, and go to sleep...repeat process

:S
Fruit Pickin'

Joe
Coder
Posts: 20
Joined: Wed Aug 15, 2007 3:11 pm
Contact:

Post by Joe » Tue Aug 21, 2007 9:12 pm

I beat it! Yeppie! Level 4 was a tough one.

Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Good

Post by Mac » Thu Aug 23, 2007 9:42 am

Good first game except level 4. Bogus. It is the equivalent of simply saying "Guess a number between 1 to 1000, if you guess wrong, you lose."

Couple of bugs:

1) You can run off the edge of the world in the zero directions as well as the 25,80 that you tested for.

2) To print the guy, put a semi-colon after the data so the screen doesn't get messed up if you go to low.
PRINT " "; to clear space, etc.

Mac

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Thu Aug 23, 2007 1:12 pm

Raspberrypicker wrote: I programmed some code, then I couldn't figure something out, got frustrated, and went to sleep.
Keep it like that too ;) If you get stuck, go out or something and you see that solution comes easier ;)
Dont have workable QB here, but by the code, i think it is good start for a first game. Be proud of it :)

Post Reply