Qbasicnews.com
July 21, 2018, 07:48:58 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Space Invaders like game  (Read 6729 times)
dark ninja
New Member

Posts: 12



« on: November 19, 2004, 09:10:06 PM »

I started this about a month ago, it's a shooter game in the style of space invaders, but also very different.  The controls are explained in the opening screen when you first hit F5.  

There's only one glitch I know of, and that is sometimes when a level starrts, the first time through the loop the enemies will not clear properly, leaving lifeless green blocks sitting in the top-left corner of the screen.  Ignore them.  

Here's the .txt file (I'm using the forum file uploader, so I hope this works): http://forum.qbasicnews.com/users/file.php?id=20

My personal high score is 43811, on level 18.
Logged

'm boycotting signatures.
Adigun A. Polack
Ancient Guru
****
Posts: 691



WWW
« Reply #1 on: November 19, 2004, 09:59:24 PM »

To dark ninja:

Hello to you there, and you are off to a pretty good programming start here in QB.  Looks pretty nice!  Smiley

The one recognizable problem I had with your game was the way that you setted the keyboard controls up, as it can put some cramps on one of a person’s hands after extended play.  Sad  My suggestion to help you adjust the key controls: please set them to......

    Left Arrow = Move Left
    Right Arrow = Move Right
    Down Arrow = Stop Movement
    Space = Fire[/list]
    ........and you will do just fine.  Wink

    On the plus side, I liked the power-ups that occasionally came down as I was playing your game, man, *especially* a cool one called the Autofirer!  Cheesy !

    Like I said, you are off to a pretty good programming start, and I wish you well in your continuing QB game development.  Chao!!  :cool:



    GIVING YOU SOME GOOD ADVICE TONIGHT,


    Adigun Azikiwe Polack
    One of the Founders of “Aura Flow”
    Continuing Developer of “Frantic Journey”
    Current Developer of “Star Angelic Slugger”
    Webmaster of the “AAP Official Projects Squad”
    Logged

    url=http://dhost.hopto.org/aapproj/][/url]
    Your *official* home of the FreeBasic GFX Demo Central, now holding over 150 FB graphics demos so far!!!  Cheesy !
    adosorken
    */-\*
    *****
    Posts: 3655



    WWW
    « Reply #2 on: November 19, 2004, 10:16:21 PM »

    Not bad at all. I was kinda wondering when someone'd come out with a Space Invaders style game. Nice use of textmode too. Smiley I made these modifications, feel free to use them yourself for better controlling:

    Code:
    IF user$ = CHR$(0) + CHR$(75) THEN move$ = "left"
     IF user$ = CHR$(0) + CHR$(77) THEN move$ = "right"
     IF user$ = CHR$(0) + CHR$(72) THEN move$ = "still"
     IF user$ = " " AND bullet$ = "no" AND powerup$ <> "auto-firer" THEN


    It allows the left and right arrow keys to be used to moving left and right, the up arrow key for stopping (change the 72 to an 80 to use the down key), and the spacebar as the fire button.
    Logged

    I'd knock on wood, but my desk is particle board.
    dark ninja
    New Member

    Posts: 12



    « Reply #3 on: November 19, 2004, 10:25:33 PM »

    Thanks for the feedback and encouragement, I know how to utilize space bar, however keys have always eluded me.  I figured out how to use OK KEY(12) GOSUB NameOfSub: KEY(12) ON  to get the arrow keys, however the computer only seems to read the arrows on the number pad, and not the simple directional arrows (the 4 that are by themselves).  

    [edit]That answers my questions, thanks adosorken
    Logged

    'm boycotting signatures.
    adosorken
    */-\*
    *****
    Posts: 3655



    WWW
    « Reply #4 on: November 19, 2004, 10:31:44 PM »

    Yeah the arrow keys are a bit different if you're using INKEY$. If you precede the value of the arrow key with a CHR$(0), you'll get the key to work. A little test you can set up goes something like this:

    Code:
    DO
      A$ = INKEY$
      IF A$ <> "" THEN PRINT A$
    LOOP UNTIL A$ = CHR$(27)

    What this little snippet will do is allow you to see the character value of any of the extended keys that work with INKEY$, like Page Down and Insert...I believe the function keys can also be seen this way. Put this code into a new program and run it, press ESC to stop it (you know this one already it seems, heh). Non-trappable keys like Shift and Alt cannot be seen this way though. You'll know you've got an extended key when there's a space and then a character. In those cases, you'd use something like CHR$(0) + "H" or whatever the character returned is. I always used stuff like CHR$(0) + CHR$(72) because it was easier for me to remember...
    Logged

    I'd knock on wood, but my desk is particle board.
    dark ninja
    New Member

    Posts: 12



    « Reply #5 on: November 20, 2004, 01:00:53 AM »

    Alright my Qbasic just sucks.  I've got your code followed to a T, I double checked to make sure the CHR$() corresponds to M,K, and P, and it still doesn't work.
    Code:
    IF user$ = CHR$(0) + CHR$(75) THEN move$ = "left"
     IF user$ = CHR$(0) + CHR$(77) THEN move$ = "right"
     IF user$ = CHR$(0) + CHR$(80) THEN move$ = "still"

    Nothing at all, not even the number pad registers.  I even tried to see if the computer reads it by making
    Code:
    IF user$ = CHR$(0) + CHR$(75) THEN move$ = "left": LOCATE 4, 1: PRINT "Hooray!"

    Nothing.  

    Maybe it's because of my version of QBasic, as far as I know it's regular QBasic (not Quick Basic).

    Thanks, however for the space bar idea (which is working).  I knew how to implement it, but never thought to use it.
    Logged

    'm boycotting signatures.
    adosorken
    */-\*
    *****
    Posts: 3655



    WWW
    « Reply #6 on: November 20, 2004, 04:13:57 AM »

    Oh whoops, a minor detail I guess I forgot to mention: I removed the line where you change user$ to lowercase. Do that as well and the code will work fine. Sorry! I forgot. Sad
    Logged

    I'd knock on wood, but my desk is particle board.
    relsoft
    */-\*
    *****
    Posts: 3927



    WWW
    « Reply #7 on: November 20, 2004, 04:25:42 AM »

    Space invaders only need 3 keys to work right?

    Then you can use CTRL,AL and SHIFT to make a multikey handler:

    http://rel.betterwebber.com/junk.php?id=8
    Logged

    y smiley is 24 bit.


    Genso's Junkyard:
    http://rel.betterwebber.com/
    dark ninja
    New Member

    Posts: 12



    « Reply #8 on: November 20, 2004, 01:08:07 PM »

    Mine uses 4 keys, not 3 because I added the ability to stop the ship.

    Changed it and added a selection for using asdw or arrow keys, seems to be working fine.  Thanks for the tips, and as before suggestions are welcome (for example some powerups cause the bullet to change shape.  I'd like to do that for more powerups, but I can't think of what shape to make them.)
    Logged

    'm boycotting signatures.
    adosorken
    */-\*
    *****
    Posts: 3655



    WWW
    « Reply #9 on: November 20, 2004, 01:26:00 PM »

    The only suggestion I have from here is to perhaps consider doing it with actual graphics rather than ASCII characters. ASCII characters are relatively easy to use and do collision detection with...step it up a bit with raster graphics and it'll challenge you a bit more. Cheesy
    Logged

    I'd knock on wood, but my desk is particle board.
    dark ninja
    New Member

    Posts: 12



    « Reply #10 on: November 20, 2004, 03:29:13 PM »

    They aren't ASCII characters, although that's what they're meant to look like.  I don't have Assembly, so I just drew the bullets with LINE and CIRCLE statements.
    Code:
    IF bullet$ = "yes" THEN
       LINE (bulletx, bullety)-(bulletx, bullety - 10), 3, BF
         IF powerup$ = "bomb" OR powerup$ = "super bomb" THEN
           LINE (bulletx - 3, bullety - 5)-(bulletx + 3, bullety - 5), 3
           LINE (bulletx - 2, bullety - 3)-(bulletx + 2, bullety - 7), 3
           LINE (bulletx - 2, bullety - 7)-(bulletx + 2, bullety - 3), 3
         END IF
         IF powerup$ = "piercing" THEN
           LINE (bulletx, bullety - 10)-(bulletx - 2, bullety - 7), 3
           LINE (bulletx, bullety - 10)-(bulletx + 2, bullety - 7), 3
         END IF
         IF powerup$ = "shaky bullet" THEN
           CIRCLE (bulletx, bullety - 8), 2, 3
           CIRCLE (bulletx, bullety - 2), 2, 3
         END IF
     END IF

    Bomb, super bomb, piercing, and shaky bullets all have theire own look, as do the enemy bullets.
    Logged

    'm boycotting signatures.
    adosorken
    */-\*
    *****
    Posts: 3655



    WWW
    « Reply #11 on: November 20, 2004, 05:52:51 PM »

    Ahh okay...wow, they sure look like ASCII characters. I never perused the code so I didn't actually notice. Cool. Cheesy

    Okay, now I got the inspiration to make a Space Invaders game for some reason. Cheesy
    Logged

    I'd knock on wood, but my desk is particle board.
    Pages: [1]
      Print  
     
    Jump to:  

    Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!