TGC Codebase Backup



RPG TEXT GAME WIP Audis Corpe by MaPo

12th Sep 2008 23:13
Summary

Text RPG work in progress. I'm pretty much figuring this out as I go along! Not a whole lot here. I'll get there when I get there!



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` --------- should put types in as an #include later on ---------------
type plyr
      NAME           as string   `player can choose name
      EXPERIENCE     as integer  `increase experience to reach higher level
      LEVEL          as integer  `add certain number of points to other attributes per level number
      HIT_POINTS     as integer  `players health
      ARMOUR         as integer  `total armour value
      STRENGTH       as integer  `adds to weapon effectiveness in battle
      DEXTERITY      as integer  `affects ability to evade an enemy attack
      ENDURANCE      as integer  `higher #'s decrease enemy's attack value
      MAGIC_POINTS   as integer  `magic ability
      LUCK           as integer  `increase likelyhood of hitting an enemy
      GOLD           as integer  `player's total money
   endtype
   PLAYER as plyr

   type ENEMY
      NAME           as string
      EXPERIENCE     as integer  `increase experience to reach higher level
      LEVEL          as integer  `add certain number of points to other attributes per level number
      HIT_POINTS     as integer  `enemy's health
      STRENGTH       as integer  `adds to weapon effectiveness in battle
      DEXTERITY      as integer  `affects ability to evade player's attack
      ENDURANCE      as integer  `higher #'s decrease players's attack value
      MAGIC_POINTS   as integer  `magic ability
      LUCK           as integer  `increase likelyhood of hitting player
      GOLD           as integer  `enemy's total money
   endtype
`------------------------------------------------------------------------
set display mode 640,480,32
set text font "terminal",1
set text size 12

cls
hide mouse
randomize timer()
PLAYER.HIT_POINTS = 30
PLAYER.MAGIC_POINTS = 10
PLAYER.LEVEL = 1
PLAYER.GOLD = 50
showTitle()
`showIntroductionText()
promptPlayerName()
showPlayerStatChooser()
drawScreenBorders()
`do
drawPlayerDataInStatScreen()

`loop
wait key

function drawScreenBorders()
   `--------------------
   `border around screen
   `--------------------
   `--left upper corner
   drawChar(0,0,201,0,0,255)
   `--right upper corner
   drawChar(79,0,187,0,0,255)
   `--left lower corner
   drawChar(0,39,200,0,0,255)
   `--right lower corner
   drawChar(79,39,188,0,0,255)
   `--both horizontal lines
   for i=1 to 78
      text (i*8),(0*12), chr$(205)
      text (i*8),(39*12), chr$(205)
   next i
   `--both vertical lines
   for i=1 to 38
      text (0*8),(i*12), chr$(186)
      text (79*8),(i*12), chr$(186)
   next i
   `----------------------------------
   `divide the screen to roughly 90/10
   `----------------------------------
   `--top "t"
   drawChar(58,0,203,0,0,255)
   `--bottom "t"
   drawChar(58,39,202,0,0,255)
   `--vertical line connecting the "t"s
   for i=1 to 38
      text (58*8),(i*12), chr$(186)
   next i
   `--------------------------
   `divide for upper right box
   `--------------------------
   `--left "t"
   drawChar(58,12,204,0,0,255)
   `--right "t"
   drawChar(79,12,185,0,0,255)
   `--horizontal line connecting the "t"s
   for i=59 to 78
      text (i*8),(12*12), chr$(205)
   next i
   `--------------------------
   `divide for lower right box
   `--------------------------
   `--left "t"
   drawChar(58,16,204,0,0,255)
   `--right "t"
   drawChar(79,16,185,0,0,255)
   `--horizontal line connecting the "t"s
   for i=59 to 78
      text (i*8),(16*12), chr$(205)
   next i
endfunction

function drawPlayerDataInStatScreen()
   ink rgb (255,255,255),0
   `show the player's name
   center text 69.25*8,1*12,PLAYER.NAME
   `show the player's hit points
   text 60*8,3*12, "Health"
   text 76*8,3*12,(str$(PLAYER.HIT_POINTS))
   `show the player's magic points
   text 60*8,4*12, "Magic"
   text 76*8,4*12,(str$(PLAYER.MAGIC_POINTS))
   `show the player's level
   text 60*8,5*12, "Level"
   text 77*8,5*12,(str$(PLAYER.LEVEL))
endfunction

function drawChar(x as integer,y as integer,char as integer,r as integer,g as integer, b as integer)
   ink rgb (0,0,0),0
   text (x*8),(y*12), chr$(219)
   ink rgb (r, g, b),0
   text (x*8),(y*12), chr$(char)
endfunction

function showTitle()
   sleep 1500
   for i=0 to 255
      cls
      ink rgb (i,i,i),0
      centerText("Audis Corpe")
      sleep 7
   next i
   sleep 500
   j = 255
   for i=0 to 255
      cls
      ink rgb (j,j,j),0
      centerText("Audis Corpe")
      j=j-1
      sleep 5
   next i
   cls
   ink rgb (255,255,255),0
   sleep 750
endfunction

function showIntroductionText()
endfunction

function promptPlayerName()
   clear entry buffer
   centerText("Enter Thy Name:")
   boolGetName = 0
   resultChar$ = ""
   blankSpaces$ = ""
      for i = 1 to 50
         blankSpaces$=blankSpaces$+chr$(219)
      next i
   while boolGetName<1
      ink rgb (0,0,0),1
      centerTextManualVertical(blankSpaces$,247)
      ink rgb (255,255,255),1
      inputChar$ = ENTRY$()
      resultChar$ = resultChar$ +inputChar$
      clear entry buffer
      inputChar$=""
      centerTextManualVertical(resultChar$,247)
      `sleep 50
      checkForBackspaceOrReturnKey = scancode()
      `--backspace
      if checkForBackspaceOrReturnKey = 14
         resultChar$=left$(resultChar$,(len(resultChar$)-1))
         checkForBackspaceOrReturnKey = 0
      endif
      `--return
      if checkForBackspaceOrReturnKey=28
         boolGetName = 1
      endif
   endwhile
   PLAYER.NAME = resultChar$
endfunction

function randomizePlayerStats()
   PLAYER.STRENGTH=     rnd(15)
   PLAYER.DEXTERITY=    rnd(15)
   PLAYER.LUCK=         rnd(15)
endfunction

function showPlayerStatChooser()
   for j=1 to 25
      cls
      randomizePlayerStats()
      showPlayerStatChooserStats()
      sleep 25
   next j
   i=1
   while i<3
      centerTextManualVertical(("Role " + str$(i) + " of possible 3 complete."),270)
      centerTextManualVertical("Shalt thou (A) accept or (R) roll again?", 290)
      statChooserResponse = scancode()
      if statChooserResponse = 30 `accept
         i=3
         centerTextManualVertical("Abilities have been chosen.",310)
      endif
      if statChooserResponse = 19 `roll again
         for j=1 to 25
            cls
            randomizePlayerStats()
            showPlayerStatChooserStats()
            sleep 25
         next j
         i=i+1
         sleep 700
      endif
   endwhile
   `centerTextManualVertical(("Role " + str$(i) + " of possible 3 complete."),270)

   `----------------
   `fade this screen
   `----------------
   sleep 1500
      centerTextManualVertical(("Role " + str$(i) + " of possible 3 complete."),270)
      centerTextManualVertical("Shalt thou (A) accept or (R) roll again?", 290)
   centerTextManualVertical("Abilities have been chosen.",310)
   cls
   j=255
   for k=0 to 255
      cls
      ink rgb (j,j,j),0
      showPlayerStatChooserStats()
      centerTextManualVertical(("Role " + str$(i) + " of possible 3 complete."),270)
      centerTextManualVertical("Shalt thou (A) accept or (R) roll again?", 290)
      centerTextManualVertical("Abilities have been chosen.",310)
      j=j-1
      sleep 12
   next k
   cls
   ink rgb (255,255,255),0
   sleep 750
endfunction

function showPlayerStatChooserStats()
      centerTextManualVertical((PLAYER.NAME+", thy abilities are:"),170)
      text 269,190,"Strength:"
      text 360,190,str$(PLAYER.STRENGTH)
      text 269,210,"Dexterity:"
      text 360,210,str$(PLAYER.DEXTERITY)
      text 269,230,"Luck:"
      text 360,230,str$(PLAYER.LUCK)
endfunction

function centerText(m$)
   center text (screen width()/2)-(len(message$)/2),((screen height()/2)-text height(m$)),m$
endfunction

function centerTextManualVertical(m$,n)
   center text (screen width()/2)-(len(message$)/2),(n),m$
endfunction