Sneaking this one in there:
[UPDATE]
Fixed a coding problem that based everything on a max value of 100, even if you changed the default maximum for the total of all stats to something else.
remstart
==============================================================
= Title : RPG Charcter Stat Manager
= Author : latch
= Date : 07/22/2010
= Update :
= Version: .01
==============================================================
Comments
==============================================================
remend
rem =============================================================
rem = SET UP DISPLAY
rem =============================================================
autocam off
set display mode 800,600,32
sync on
sync rate 60
rem =============================================================
rem = MAIN
rem =============================================================
_main:
gosub _textures
gosub _init
rem loop
do
cls
text 500,0,"Editing character = "+str$(char)
text 500,20,"Character Name is : "+cname$(char)
text 500,40,"Press SPACEBAR to add a new character"
os=ns
ns=spacekey()
if ns > os
gosub _add_character
endif
rem redraw screen
gosub _draw_screen
sync
loop
end
rem =============================================================
rem = SUBROUTINES - PROCEDURES
rem =============================================================
_init:
remstart
set up an array to hold the character stats
character#(id,stat)
where id is the character identifier
and stat is the character statistic
character(0,0) == the total count of all characters defined
character
character(0,1) == default max sum of all stats for new characters
since there are 5 controllable stats
in this example, setting this to multiples
of five will allow for even distribution
of points between the stats. However, to
allow for varied character abilities, a less
evenly divisible number may be preferred.
character(id,0) == the image or object number of the character
character(id,1) == strength
character(id,2) == dexterity
character(id,3) == constitution
character(id,4) == intelligence
character(id,5) == wisdom
character(id,6) == the max sum of all stats - this can be
changed throughout the game by maybe level
increases or some kinda of experience or
enchantment
character(id,7) == current hit points
character(id,8) == max hit points
character(id,9) == current magic units
character(id,10) == max magic points
character(id,11) == constitution increment. This is a percentage
of the constitution that the hitpoints will
increment each level. This is set once
at character creation. As the game goes
on, a higher constitution will of course
mean more hit points
character(id,12) == wisdom increment - see constitution increment
except this applies to magic points
cname$(id) == the name of the character
remend
dim character(1,12)
character(0,0)=0
character(0,1)=100
dim cname$(1)
gosub _add_character
return
`================================================================
_textures:
create bitmap 1,screen width(),screen height()
rem stat container
container=1
for y=12 to 25
ink rgb(255-(9*y),255-(9*y),255-(9*y)),0
line 10+(5*(sin(15*y))),y,200-(5*(sin(15*y))),y
next y
for y=14 to 23
ink 0,0
line 12+(5*(sin(15*y))),y,198-(5*(sin(15*y))),y
next y
get image container,4,12,206,25
sync
delete bitmap 1
rem stat bars
str=2 : `red
dex=3 : `white
con=4 : `yellow
intl=5 : `blue
wis=6 : `cyan
hp=7 : `green
mp=8 : `purple
tot=9 : `orange
create bitmap 1,256,100
for stat=2 to 9
cls 0
select stat
case 2 : ink rgb(255,0,0),0 : endcase
case 3 : ink rgb(255,255,255),0 : endcase
case 4 : ink rgb(255,255,0),0 : endcase
case 5 : ink rgb(0,0,255),0 : endcase
case 6 : ink rgb(0,255,255),0 : endcase
case 7 : ink rgb(0,255,0),0 : endcase
case 8 : ink rgb(255,0,255),0 : endcase
case 9 : ink RGB(255,128,0),0 : endcase
endselect
box 8,15,202,22
for n=1 to 9
blur bitmap 1,2
next n
line 10,16,200,16
blur bitmap 1,2
get image stat,7,12,203,25
sync
sprite stat,0,0,stat
hide sprite stat
set sprite stat,0,0
next stat
delete bitmap 1
return
`================================================================
_draw_screen:
rem place buttons
x1=220
x2=240
x3=245
x4=265
for y=1 to 5
y1=(y*35)-5
y2=y1+20
draw_button(x1,y1,x2,y2)
draw_button(x3,y1,x4,y2)
ink 0,0
set text to bold
text x1+6,y1+2,"<"
text x3+7,y1+2,">"
rem check for mouse click
if mouseclick()=1
mx=mousex()
my=mousey()
rem decrease stat
if mouse_within(mx,my,x1,y1,x2,y2)
rem draw depressed button
pressed_button(x1,y1,x2,y2)
ink rgb(0,255,255),0
text x1+6,y1+2,"<"
rem reduce the stat
character(char,y)=character(char,y)-1
if character(char,y) < 1 then character(char,y)=1
endif
rem increase stat
if mouse_within(mx,my,x3,y1,x4,y2)
rem draw depressed button
pressed_button(x3,y1,x4,y2)
ink rgb(0,255,255),0
text x3+7,y1+2,">"
rem increase the stat
character(char,y)=character(char,y)+1
rem make sure the single stat doesn't go above
rem the grand total for all stats
total=0
for t=1 to 5
inc total,character(char,t)
next t
while total > character(char,6)
character(char,y)=character(char,y)-1
dec total
endwhile
endif
endif
next y
set text to normal
ink rgb(255,255,255),0
rem place containers
for y=1 to 5
rem figure out length of bars based on the array values
maxlen=character(char,6)
xstr=((character(char,y)+0.0)/(character(char,6)+0.0))*100
stretch sprite y+1,xstr,100
rem place the stat bars
y1=y*35
paste sprite y+1,14,y1-1
paste image container,10,y1,1
next y
total=0
for t=1 to 5
inc total,character(char,t)
next t
tt$="Used Total / Max Possible ("+str$(total)+"/"+str$(character(char,6))+")"
text 0,220,tt$
txwd=241
stretch sprite 9,((total+0.0)/(character(char,6)+0.0))*100,100
paste sprite 9,txwd+9,221
paste image container,txwd+6,222,1
rem list the stats
text x4+10,35,"Strength = "+str$(character(char,1))
text x4+10,70,"Dexterity = "+str$(character(char,2))
text x4+10,105,"Constitution = "+str$(character(char,3))
text x4+10,140,"Intelligence = "+str$(character(char,4))
text x4+10,175,"Wisdom = "+str$(character(char,5))
rem reset the hp and mp
text 0,280,"Click DONE to recalculate HP and MP"
wdth=35
draw_button(wdth,280,wdth+text width("DONE")+4,300)
ink 0,0
set text to bold
text wdth+2,282,"DONE"
ink rgb(255,255,255),0
set text to normal
if mouseclick()=1
if mouse_within(mx,my,wdth,280,wdth+text width("DONE")+4,300)
pressed_button(wdth,280,wdth+text width("DONE")+4,300)
ink rgb(0,255,255),0
`set text to bold
text wdth+3,283,"DONE"
ink rgb(255,255,255),0
set text to normal
rem set default hitpoints and magic points
character(char,7)=character(char,3)*(character(char,11)/100.0)
character(char,8)=character(char,7)
character(char,9)=character(char,5)*(character(char,12)/100.0)
character(char,10)=character(char,9)
endif
endif
rem place the hit point and magic point bars
hp$="Character Hitpoints = ("+str$(character(char,7))+"/"+str$(character(char,8))+")"
mp$="Character Magic Points = ("+str$(character(char,9))+"/"+str$(character(char,10))+")"
paste sprite 7,txwd+9,341
paste image container,txwd+6,342,1
text 0,340,hp$
paste sprite 8,txwd+9,371
paste image container,txwd+6,372,1
text 0,370,mp$
return
`================================================================
_add_character:
remstart
A routine to expand the array(s) and setup a new
character.
remend
rem check for existing characters
if character(0,0)=0
character(0,0)=1
char=1
else
char=character(0,0)
dim temp(char+1,12)
dim temp$(char+1)
rem copy old arrays to temp arrays
for n=0 to char
temp$(n)=cname$(n)
for m=0 to 12
temp(n,m)=character(n,m)
next m
next n
rem redimension old arrays
undim character(char,12)
undim cname$(char)
dim character(char+1,12)
dim cname$(char+1)
rem copy back old info
for n=0 to char
cname$(n)=temp$(n)
for m=0 to 12
character(n,m)=temp(n,m)
next m
next n
undim temp(char,12)
undim temp$(char)
rem update count
inc char
character(0,0)=char
endif
rem update new character
character(char,6)=character(0,1)
rem set default stats
for n=1 to 5
character(char,n)=character(char,6)/5
next n
rem set constitution hp and wisdom mp percentage values
character(char,11)=rnd(50)+10
character(char,12)=rnd(65)+10
rem set default hitpoints and magic points
character(char,7)=character(char,3)*(character(char,11)/100.0)
character(char,8)=character(char,7)
character(char,9)=character(char,5)*(character(char,12)/100.0)
character(char,10)=character(char,9)
Input "Enter character Name : ";a$
cname$(char)=a$
return
rem =============================================================
rem = FUNCTIONS
rem =============================================================
function mouse_within(mx,my,x1,y1,x2,y2)
if mx > x1
if mx < x2
if my > y1
if my < y2
exitfunction 1
endif
endif
endif
endif
endfunction 0
`================================================================
function draw_button(x1,y1,x2,y2)
ink rgb(192,192,192),0
box x1,y1,x2,y2
ink rgb(255,255,255),0
box x1,y1,x2,y1
box x1,y1,x1,y2
ink rgb(32,32,32),0
box x2,y1+1,x2,y2
box x1,y2,x2,y2
endfunction
`================================================================
function pressed_button(x1,y1,x2,y2)
ink rgb(192,192,192),0
box x1,y1,x2,y2
ink rgb(32,32,32),0
box x1,y1,x2,y1
box x1,y1,x1,y2
ink rgb(255,255,255),0
box x2,y1+1,x2,y2
box x1,y2,x2,y2
endfunction
`================================================================
The stats are controlled by clicking on the buttons with the mouse. Pessing the space key, starts the creation of a new character. Though I included a space in the array for a picture or an object to be associated with the character, I ran out of time and couldn't include that in this demo.
The consitution and the wisdom control the hitpoints and the magic points. A percentage is calculated and then added. This is a fixed value so as the character develops, it can become important to increse the wisdom and the consitution if you want magic and life to increase at a higher rate as the character levels up.
Enjoy your day.