Fight simulator

Discussion in 'Computer Science & Culture' started by Waiter_2001, Oct 13, 2014.

  1. Waiter_2001 Registered Senior Member

    Messages:
    459
    Here is a code for a fight simulator (PLAYERS=NO. PLAYERS):

    Code:
    DIM STRENGTH(PLAYERS)
    
    FOR A=1 TO PLAYERS
    
    STRENGTH(A)=A
    
    NEXT A
    
    1
    
    FOR A=1 TO PLAYERS
    
    CLS
    
    IF (STRENGTH(A)<0)) THEN GOTO 2
    
    PRINT "PLAYER:";A
    
    PRINT "STRENGTH:";STRENGTH(A)
    
    INPUT "PLAYER:",PLAYER
    
    IF (PLAYER=0) THEN END
    
    PRINT "STRENGTH:";STRENGTH(PLAYER)
    
    PRINT "MINIMUM STRIKE:";STRENGTH(A)-(STRENGTH(A)*2)
    
    PRINT "MAXIMUM STRIKE:";STRENGTH(A)
    
    INPUT "STRIKE:",STRIKE
    
    IF (STRIKE>STRENGTH(A)) THEN GOTO 2
    
    IF (STRIKE<STRENGTH(A)-(STRENGTH(A)*2) THEN GOTO 2
    
    STRENGTH(PLAYER)=STRENGTH(PLAYER)+STRIKE
    
    2
    
    NEXT A
    
    GOTO 1
    The program simply goes through the players requesting their move: the player selects another player which they can then strike; the player may add value to the selected player's health, or deduct from it.
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Dr_Toad It's green! Valued Senior Member

    Messages:
    2,527
    Pseudocode, or broken BASIC? I didn't remember CLS being a valid command, but it is indeed. Who writes in BASIC these days?

    I mean really. COBOL is much more fun to code...

    Please Register or Log in to view the hidden image!

     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Waiter_2001 Registered Senior Member

    Messages:
    459
    C++ would be better.

    CLS if clear screen.

    BASIC can be used in Excel under macros.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.

Share This Page