RPG attributes generator: Difference between revisions
→{{header|Commodore BASIC}}: Standardize line numbering; switch to 0-basis for arrays to avoid wasting entries; use chr$ for cursor movement; change DS to DT so it works on C-128 where DS is a reserved word..
ReeceGoding (talk | contribs) m (→{{header|R}}: Syntax highlighting.) |
(→{{header|Commodore BASIC}}: Standardize line numbering; switch to 0-basis for arrays to avoid wasting entries; use chr$ for cursor movement; change DS to DT so it works on C-128 where DS is a reserved word..) |
||
Line 1,212:
Except for screen control codes, this is generic enough it could be used for many other 8-bit interpreted BASICs as well. (Applesoft, ZX Spectrum, etc.). Should work on all Commodore models. (Adjustment for screen width may be necessary on VIC-20.)
<lang gwbasic>100 rem rpg character roller
▲20 rem rosetta code - commodore basic
▲135 at$(6)="Charisma"
▲140 pt=0:sa=0:rem points total and number of strong attributes (15+)
220 for ai=0 to 5:rem attribute index
▲145 print chr$(147);chr$(14);"{right}{down}Rolling..."
250 dt=0:rem dice total
▲160 gosub 2000
▲165 ds=0:rem dice sum
▲170 for i=1 to 3:ds=ds+di(i):next i:rem take top 3
▲175 at(ai)=ds:pt=pt+ds
▲180 if ds>=15 then sa=sa+1
▲185 next ai
▲190 if pt<75 or sa<2 then goto 140
▲195 print chr$(147);"Character Attributes:"
▲200 print
▲205 for ai=1 to 6
▲210 print spc(13-len(at$(ai)));at$(ai);":";tab(14);at(ai)
▲215 next ai
▲220 print
▲225 print " Total:";tab(14);pt
410 print k$
▲240 get k$:if k$<>"y" and k$<>"n" then 240
▲245 print k$
▲250 if k$="n" then goto 140
▲255 print:print "Excellent. Good luck on your adventure!"
▲260 end
▲2000 rem sort dice
▲2005 for x=1 to 3:for y=x+1 to 4
490 return</lang>▼
▲2010 if di(x)<di(y) then di(0)=di(x):di(x)=di(y):di(y)=di(0)
▲2015 next y,x
▲</lang>
{{out}}
|