Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

DALEKS.BAS

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Tue Apr 25, 2006 3:34 pm    Post subject: DALEKS.BAS Reply with quote

Okay, this isn't plotscripting. It should go in the programmers' usergroup, but that place is dead.

Anyway, so I'm supposed to be doing my final project for OS, so I stumble upon my old QBasic repository. Here's one of the last games I ever made in QBasic. I'm guessing I was just bored one afternoon and decided to spend a half hour programming Daleks. This is the result.

Use the arrow keys to move, T to teleport, and S to use the sonic screwdriver (once per level; doesn't stockpile). My 10-minute high score just now was 139.

Code:
DECLARE SUB InitLev ()
DECLARE SUB PlayGame (Outcome!)
DIM SHARED DW$, DL$
DIM SHARED Board(21, 11), Lev, X, Y, Score AS INTEGER
SCREEN 2
DW$ = "R5C1R2FDGL2HUDF2D2NL4NR4D3NF4NG4"
DL$ = "DR5C1R2FGL2HFRL4D2R8U2L4R4D8L8NU8DR8"
REM DW$ = Dr Who, DL$ = Dalek
Lev = 1
RANDOMIZE TIMER

DO

InitLev

PlayGame Outcome

Lev = Lev + 1

LOOP WHILE Outcome = Survive

CLS
LOCATE 5, 10: PRINT "Daleks Toasted:  "; Score
LOCATE 8, 10: PRINT "Final Level:  "; Lev - 1
LOCATE 12, 10: PRINT "Nice Try"

SUB InitLev
CLS

FOR A = 1 TO 10
 FOR B = 1 TO 20
  LINE (10 + 15 * B, 10 + 15 * A)-(25 + 15 * B, 25 + 15 * A), , B, &H8888
  Board(B, A) = 0
 NEXT
NEXT


FOR A = 1 TO Lev * 4
 DO
  X = INT(RND * 20) + 1
  Y = INT(RND * 10) + 1
  IF Board(X, Y) = 0 THEN
   Board(X, Y) = 1
   PSET (11 + 15 * X, 11 + 15 * Y), 0
   DRAW DL$
   EXIT DO
  END IF
 LOOP
NEXT

DO
 X = INT(RND * 20) + 1
 Y = INT(RND * 10) + 1
 IF Board(X, Y) = 0 THEN
  PSET (11 + 15 * X, 11 + 15 * Y), 0
  DRAW DW$
  EXIT DO
 END IF
LOOP
END SUB

SUB PlayGame (Outcome)
DIM NewBoard(20, 10)
Outcome = 5: Z = Score: S = 1
DO
 OX = X: OY = Y
Getkey:
 DO
  A$ = LCASE$(INKEY$)
 LOOP WHILE A$ = ""
 SELECT CASE A$
  CASE "4": A$ = "u"
  CASE "1": A$ = "j"
  CASE "2": A$ = "k"
  CASE "3": A$ = "l"
  CASE "6": A$ = "o"
 END SELECT
 SELECT CASE A$
  CASE "j": X = X - 1: Y = Y + 1
  CASE "u": X = X - 1
  CASE "7": X = X - 1: Y = Y - 1
  CASE "8": Y = Y - 1
  CASE "9": X = X + 1: Y = Y - 1
  CASE "o": X = X + 1
  CASE "l": X = X + 1: Y = Y + 1
  CASE "k": Y = Y + 1
  CASE "t": X = INT(RND * 20) + 1: Y = INT(RND * 10) + 1: IF Board(X, Y) > 1 THEN GOTO Getkey
  CASE "s"
        IF S = 1 THEN
        FOR A = X - 1 TO X + 1
         FOR B = Y - 1 TO Y + 1
          IF Board(A, B) = 1 THEN Board(A, B) = 0: Score = Score + 1: LINE (11 + 15 * A, 11 + 15 * B)-(24 + 15 * A, 24 + 15 * B), 0, BF
         NEXT
        NEXT
        S = 0
        END IF
        PSET (11 + 15 * X, 11 + 15 * Y), 0: DRAW DW$
        GOTO Getkey
  CASE "5"
  CASE "i"
  CASE ELSE: GOTO Getkey
 END SELECT
 IF X < 1 THEN X = 1
 IF X > 20 THEN X = 20
 IF Y > 10 THEN Y = 10
 IF Y < 1 THEN Y = 1
 IF X <> OX OR Y <> OY THEN
  LINE (11 + 15 * OX, 11 + 15 * OY)-(24 + 15 * OX, 24 + 15 * OY), 0, BF
  PSET (11 + 15 * X, 11 + 15 * Y), 0: DRAW DW$
 END IF
 FOR A = 1 TO 10
  FOR B = 1 TO 20
   IF Board(B, A) = 1 THEN NewBoard(B, A) = 0 ELSE NewBoard(B, A) = Board(B, A)
  NEXT
 NEXT
 FOR A = 1 TO 10
  FOR B = 1 TO 20
   IF Board(B, A) = 1 THEN
    IF NewBoard(B, A) = 0 THEN LINE (11 + 15 * B, 11 + 15 * A)-(24 + 15 * B, 24 + 15 * A), 0, BF
    D = B: C = A
    IF B < X THEN D = B + 1
    IF B > X THEN D = B - 1
    IF A < Y THEN C = A + 1
    IF A > Y THEN C = A - 1
    PSET (11 + 15 * D, 11 + 15 * C), 0: DRAW DL$
    NewBoard(D, C) = NewBoard(D, C) + 1
    IF NewBoard(D, C) > 1 THEN
     IF NewBoard(D, C) = 2 THEN Score = Score + 2 ELSE Score = Score + 1
     FOR E = 1 TO 20
      PSET (INT(RND * 14) + 11 + 15 * D, INT(RND * 14) + 11 + 15 * C)
     NEXT
    END IF
   END IF
  NEXT
 NEXT
 FOR A = 1 TO 10
  FOR B = 1 TO 20
   Board(B, A) = NewBoard(B, A)
  NEXT
 NEXT
 IF Board(X, Y) > 0 THEN Outcome = 3
 IF Score - Z = Lev * 4 THEN Outcome = 0
LOOP WHILE Outcome = 5
END SUB


Known bugs:
* Using the SSD on the last dalek(s) in a level won't end the level until a direction key is pressed
* Theoretically, the game will stall if you get to a level that should have more daleks in it than there are spaces on the map

Known awesome little feature:
* The more daleks you have crash onto one space, the more the junk on that space piles up.

Like I said, I probably made this in half an hour. (This makes me want to write the same game in hspeak. Bet I could do it in twenty minutes, including the time it takes to make the graphics.)
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Gizmog1
Don't Lurk In The Bushes!




Joined: 05 Mar 2003
Posts: 2257
Location: Lurking In The Bushes!

PostPosted: Tue Apr 25, 2006 3:45 pm    Post subject: Reply with quote

I'll take that bet. (I'd play the game, but no compiler, and I don't wanna steal one.)
Back to top
View user's profile Send private message Send e-mail AIM Address
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Tue Apr 25, 2006 5:33 pm    Post subject: Reply with quote

I think you can get free interpreters. Dunno. Maybe after I'm done with the project, I'll make an OHR Daleks.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
PlayerOne




Joined: 07 Sep 2005
Posts: 143
Location: UK

PostPosted: Wed Apr 26, 2006 11:11 am    Post subject: Reply with quote

It is fairly likely to compile with FreeBasic which is, well, free. I'm feeling far too lazy to actually try it, though, sorry.
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Thu Apr 27, 2006 3:26 pm    Post subject: Reply with quote

I added:

Code:
option nokeyword getkey


And I removed the ! from the PlayGame declaration

Code:
DECLARE SUB PlayGame (Outcome!)


And then it compiled with no errors in FreeBasic. When I run daleks.exe I see the playing field with Dr Who and a bunch of Daleks, but I cannot move with the arrow keys, and pressint T to teleport causes the program to exit :(
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group