small 3dish game: cosmic shootout

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

small 3dish game: cosmic shootout

Post by bongomeno »

well this forum has been fairly dead lately! :shock: so I stopped coming, but i cant resist coming back..... so ill just drop this off here

its a small star raiders inspired shooter that i made on the plane on the way to california from louisiana.... kinda fun.

shoot the aliens lol...

Code: Select all

RANDOMIZE TIMER
COLOR 9: PRINT "  COSMIC SHOOTOUT!"
PRINT
COLOR 4: PRINT " SHOOT THE ASTEROIDS!"
PRINT
COLOR 4: PRINT " CONTROLS - "
PRINT
COLOR 4: PRINT " TO MOVE USE ARROW KEYS."
COLOR 4: PRINT " TO SHOOT USE SPACE."
PRINT
COLOR 14: PRINT "  -- PRESS ANY KEY"

DO
LOOP UNTIL INKEY$ <> ""

RANDOMIZE TIMER

LET px = 160
LET py = 100
LET bo = 0
LET bx = px
LET by = py
LET bd = 150
LET ex = INT(RND * 310) + 10
LET ey = INT(RND * 190) + 10
LET ed = 0
LET es = .1
DIM sx(30), sy(30), ssx(30), ssy(30)
FOR cs = 0 TO 29
LET sx(cs) = INT(RND * 20) + 150
LET sy(cs) = INT(RND * 20) + 90
LET ssx(cs) = INT(RND * 4) + 1
IF INT(RND * 2) = 1 THEN : LET ssx(cs) = -ssx(cs)
LET ssy(cs) = INT(RND * 4) + 1
IF INT(RND * 2) = 1 THEN : LET ssy(cs) = -ssy(cs)
NEXT cs

SCREEN 13

DO
FOR cs = 0 TO 29
CIRCLE (sx(cs), sy(cs)), 1, 0
LET sx(cs) = sx(cs) + ssx(cs)
LET sy(cs) = sy(cs) + ssy(cs)
IF sx(cs) <1> 320 OR sy(cs) <1> 200 THEN
LET sx(cs) = INT(RND * 20) + 150
LET sy(cs) = INT(RND * 20) + 90
LET ssx(cs) = INT(RND * 10) + 1
IF INT(RND * 2) = 1 THEN : LET ssx(cs) = -ssx(cs)
LET ssy(cs) = INT(RND * 10) + 1
IF INT(RND * 2) = 1 THEN : LET ssy(cs) = -ssy(cs)
ELSE
CIRCLE (sx(cs), sy(cs)), 1, 15
END IF
NEXT cs
LET k = INP(96)
LET flush$ = INKEY$
IF k = 75 AND px > 1 THEN
CIRCLE (px, py), 5, 0
PSET (px, py), 0
LET px = px - 10
FOR cs = 0 TO 29
CIRCLE (sx(cs), sy(cs)), 1, 0
LET sx(cs) = sx(cs) - 7
CIRCLE (sx(cs), sy(cs)), 1, 15
NEXT cs
IF bo = 1 THEN
CIRCLE (bx, by), bd / 3, 0
LET bx = bx + 5
CIRCLE (bx, by), bd / 3, 4
END IF
LINE (ex - (ed / 2), ey - (ed / 2))-(ex + (ed / 4), ey - (ed / 2)), 0
LINE (ex - (ed / 2), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex, ey), 0
LINE (ex - (ed / 6), ey)-(ex, ey), 0
LET ex = ex + 4
LINE (ex - (ed / 2), ey - (ed / 2))-(ex + (ed / 4), ey - (ed / 2)), 14
LINE (ex - (ed / 2), ey - (ed / 2))-(ex - (ed / 6), ey), 14
LINE (ex + (ed / 4), ey - (ed / 2))-(ex - (ed / 6), ey), 14
LINE (ex + (ed / 4), ey - (ed / 2))-(ex, ey), 14
LINE (ex - (ed / 6), ey)-(ex, ey), 14
END IF
IF k = 77 AND px <320> 1 THEN
CIRCLE (px, py), 5, 0
PSET (px, py), 0
LET py = py - 10
FOR cs = 0 TO 29
CIRCLE (sx(cs), sy(cs)), 1, 0
LET sy(cs) = sy(cs) + 5
CIRCLE (sx(cs), sy(cs)), 1, 15
NEXT cs
IF bo = 1 THEN
CIRCLE (bx, by), bd / 3, 0
LET by = by + 5
CIRCLE (bx, by), bd / 3, 4
END IF
LINE (ex - (ed / 2), ey - (ed / 2))-(ex + (ed / 4), ey - (ed / 2)), 0
LINE (ex - (ed / 2), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex, ey), 0
LINE (ex - (ed / 6), ey)-(ex, ey), 0
LET ey = ey + 4
LINE (ex - (ed / 2), ey - (ed / 2))-(ex + (ed / 4), ey - (ed / 2)), 14
LINE (ex - (ed / 2), ey - (ed / 2))-(ex - (ed / 6), ey), 14
LINE (ex + (ed / 4), ey - (ed / 2))-(ex - (ed / 6), ey), 14
LINE (ex + (ed / 4), ey - (ed / 2))-(ex, ey), 14
LINE (ex - (ed / 6), ey)-(ex, ey), 14
END IF
IF k = 80 AND py < 200 THEN
CIRCLE (px, py), 5, 0
PSET (px, py), 0
LET py = py + 10
FOR cs = 0 TO 29
CIRCLE (sx(cs), sy(cs)), 1, 0
LET sy(cs) = sy(cs) - 5
CIRCLE (sx(cs), sy(cs)), 1, 15
NEXT cs
IF bo = 1 THEN
CIRCLE (bx, by), bd / 3, 0
LET by = by - 5
CIRCLE (bx, by), bd / 3, 4
END IF
LINE (ex - (ed / 2), ey - (ed / 2))-(ex + (ed / 4), ey - (ed / 2)), 0
LINE (ex - (ed / 2), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex, ey), 0
LINE (ex - (ed / 6), ey)-(ex, ey), 0
LET ey = ey - 4
LINE (ex - (ed / 2), ey - (ed / 2))-(ex + (ed / 4), ey - (ed / 2)), 14
LINE (ex - (ed / 2), ey - (ed / 2))-(ex - (ed / 6), ey), 14
LINE (ex + (ed / 4), ey - (ed / 2))-(ex - (ed / 6), ey), 14
LINE (ex + (ed / 4), ey - (ed / 2))-(ex, ey), 14
LINE (ex - (ed / 6), ey)-(ex, ey), 14
END IF
IF k = 57 AND bo = 0 THEN : LET bo = 1: LET bx = px: LET by = py: LET bd = 150
IF k = 1 THEN : END
CIRCLE (px, py), 5, 1: PSET (px, py), 4
IF bo = 1 THEN
CIRCLE (bx, by), bd / 3, 0
LET bd = bd - 5
IF bd < 5 THEN
LET bo = 0
ELSE
CIRCLE (bx, by), bd / 3, 4
END IF
END IF
LINE (ex - (ed / 2), ey - (ed / 2))-(ex + (ed / 4), ey - (ed / 2)), 0
LINE (ex - (ed / 2), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex - (ed / 6), ey), 0
LINE (ex + (ed / 4), ey - (ed / 2))-(ex, ey), 0
LINE (ex - (ed / 6), ey)-(ex, ey), 0
LET ed = ed + es
IF bo = 1 AND bd <ed> ex - (ed / 4) AND bx <ex> ey - (ed / 2) AND by <ey> 150 THEN
FOR dy = 0 TO 200 STEP 5
LINE (0, dy)-(319, dy), INT(RND * 2) + 1
LET oldtime = TIMER
DO
LOOP UNTIL TIMER - .01 > oldtime
NEXT dy
LOCATE 10, 7: COLOR 4: PRINT ". . . G A M E  O V E R . . ."
END
DO
LOOP UNTIL INKEY$ <ELSE> oldtime
LOOP

User avatar
coma8coma1
Veteran
Posts: 100
Joined: Sat Dec 08, 2007 5:29 pm
Location: Maryland, USA

Post by coma8coma1 »

it's not QuickBASIC huh?
i get errors
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Yeah, he used weird brackets in a loop at the end which is not needed! :roll:
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
coma8coma1
Veteran
Posts: 100
Joined: Sat Dec 08, 2007 5:29 pm
Location: Maryland, USA

Post by coma8coma1 »

yeah i fixed that <> thing but then QB gave me BLOCK IF WITHOUT END IF error so i assumed it was for another language
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Well, I don't usually test code that newer people post unless they ask for help. Especially if they still use LET. :P

He didn't ask....
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
coma8coma1
Veteran
Posts: 100
Joined: Sat Dec 08, 2007 5:29 pm
Location: Maryland, USA

Post by coma8coma1 »

haha! well, we all gotta start somewhere! in fact, the only reason i ran it is because it looks like something i would have written when i was first getting started :D

edit: on second thought, now that i look at it, it looks way more advanced than anything I can do! lol
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

lol

Post by bongomeno »

ok burger... have you heard of a thing called style? thats why I use LET... i like retro computers.

but im done with qbasic for now as im doing Atari 2600 programming now.
qbasic is still an EPIC language.

the reason the code is not working might be the BBcode messing it up.. ill post a download link.

http://www.freewebs.com/geekbasic/CS.BAS
User avatar
coma8coma1
Veteran
Posts: 100
Joined: Sat Dec 08, 2007 5:29 pm
Location: Maryland, USA

Post by coma8coma1 »

aw right on. i got it going. i'm moving and shooting but i dont think i'm hitting anything. the rocks move too fast and my shot goes too slow! lol. and there's so many of them! :D
User avatar
bongomeno
Veteran
Posts: 266
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

Post by bongomeno »

there is only 1 at a time you are shooting at the background stars! lol
Post Reply