Asteroid Shower
#1
Lightbulb 
The idea of this rather simple game comes from "Astrostorm", which I beheld first on an Apple IIe nearly 40 years back!

Lazy game program. Just press spacebar to start or stop your spaceship. Beware: the response could be a bit late. Work your way toward the top of the screen. The game ends if your spaceship is bashed by an asteroid.

Code: (Select All)
'by mnrvovrfc 2022-dec-21
OPTION _EXPLICIT
DIM AS INTEGER px, py, ph, cm, cb, uc, j, ay, ax, fc
DIM AS LONG kk
DIM AS _BYTE dead, done, holdspace
DIM AS STRING sp40

_TITLE "Astroshower LC"
WIDTH 40, 25: CLS

px = 1: py = 20: ph = 0: cm = 10: cb = 0: kk = 0
sp40 = SPACE$(40)

dead = 0
done = 0
holdspace = 0
uc = 20
fc = 8
LOCATE 24, 1: COLOR 7: PRINT 0;
LOCATE py, px: COLOR fc: PRINT ">";
DO UNTIL dead OR done
    IF uc > 0 THEN
        uc = uc - 1
        IF uc < 1 THEN fc = 15
    END IF
    FOR j = 1 TO 5
        _DELAY 0.015
        IF uc < 1 THEN
            IF _KEYDOWN(27) THEN done = 1: EXIT FOR
            IF _KEYDOWN(32) AND holdspace = 0 THEN
                IF cm > 0 THEN cm = cm - 1
                holdspace = 1
                IF ph = 0 THEN ph = 1 ELSE ph = 0
            END IF
            IF _KEYDOWN(32) = 0 AND holdspace THEN holdspace = 0
        END IF
    NEXT ''j
    IF done THEN EXIT DO
    _DISPLAY
    IF ph = 1 THEN
        kk = kk + cm + 1
        LOCATE 24, 1: COLOR 7: PRINT kk;
        COLOR 15
        LOCATE py, px: PRINT " ";
        px = px + ph
        IF px > 40 THEN
            px = 1
            ph = 0
            IF py > 10 THEN
                py = py - 1
                cb = cb + 1
            END IF
            cm = cm + cb
        END IF
        IF SCREEN(py, px) = 42 THEN dead = 1: EXIT DO
        LOCATE py, px: PRINT ">";
    END IF
    j = random1(7) - 4
    IF j > 0 THEN
        COLOR 7
        DO WHILE j > 0
            DO
                ax = random1(38) + 1
            LOOP UNTIL SCREEN(1, ax) = 32
            LOCATE 1, ax: PRINT "*";
            j = j - 1
        LOOP
    END IF
    LOCATE py, px: COLOR fc: PRINT " ";
    COLOR 7
    ay = 23
    DO WHILE ay > 1
        ax = 40
        DO WHILE ax > 1
            LOCATE ay, ax: PRINT CHR$(SCREEN(ay - 1, ax));
            ax = ax - 1
        LOOP
        ay = ay - 1
    LOOP
    LOCATE 1, 1: PRINT sp40;
    IF SCREEN(py, px) = 42 THEN dead = 1: EXIT DO
    LOCATE py, px: COLOR fc: PRINT ">";
LOOP
_AUTODISPLAY
IF dead THEN
    LOCATE 1, 1: COLOR 4
    PRINT "You have died!";
    END
END IF
SYSTEM


FUNCTION random1& (maxval)
    random1 = INT(RND * maxval + 1)
END FUNCTION
Reply


Messages In This Thread
Asteroid Shower - by mnrvovrfc - 12-22-2022, 12:08 AM
RE: Asteroid Shower - by Pete - 12-22-2022, 12:29 AM
RE: Asteroid Shower - by mnrvovrfc - 12-22-2022, 01:35 AM
RE: Asteroid Shower - by Pete - 12-22-2022, 01:49 AM
RE: Asteroid Shower - by grymmjack - 12-27-2022, 08:46 PM
RE: Asteroid Shower - by mnrvovrfc - 03-16-2023, 12:54 AM
RE: Asteroid Shower - by aurel - 03-16-2023, 08:14 AM
RE: Asteroid Shower - by aurel - 03-16-2023, 04:11 PM
RE: Asteroid Shower - by mnrvovrfc - 03-16-2023, 05:08 PM
RE: Asteroid Shower - by aurel - 03-17-2023, 07:54 AM
RE: Asteroid Shower - by SMcNeill - 03-17-2023, 11:30 AM
RE: Asteroid Shower - by aurel - 03-17-2023, 12:00 PM
RE: Asteroid Shower - by TempodiBasic - 03-23-2023, 01:25 AM
RE: Asteroid Shower - by bplus - 03-23-2023, 01:35 AM



Users browsing this thread: 2 Guest(s)