I've been working on the stats for the battle system on my rpg.
My probelm is I'm not sure when to use arrays or types. I've used both but I think it might be a waste of code and using both in the wrong way. I've read this and followed this tutorial on arrays but still haven't gotten everything crystal clear in my head.
http://forum.thegamecreators.com/?m=forum_view&t=96084&b=7
I was also having some problems on how to set up a base stat for a characrer and later overwrite it when say the character gains experiance or levels up.
exp=0
lvl=1
if exp= 1000*lvl
then level=level + 1
Would this work? Would the program remember between battles the level was now 2 and not go back to the original lvl=1(and only reset if I restarted the program) or would I have to add more code to allow for this? Bascially I'm wondering if the program would remember changed/new values for the variables if one left the current loop(ie after the battle) as they went back to the main game.
Anyway help would be great thanks.
Full Code:
Type Char
Name$ as string
Str as integer
Hp as integer
Att as integer
CharLv as integer
MAtt as integer
Mp as integer
Mag as integer
Spr as integer
Dex as integer
Vit as integer
Lvl as integer
luck as integer
Endtype
Rem Starting Level and exp
Dim lev(4)
Dim Charexp(4)
for n= 1 to 4
lev(n)=1
Charexp(n)=100
Next n
DIm Name$(4)
Dim Hp(4)
Dim Str(4)
Dim Att(4)
Dim MP(4)
Dim Matt(4)
Dim Mag(4)
Dim Def(4)
Dim Vit(4)
Dim Spr(4)
Sync on : Sync Rate 0
Print "please enter the names of your party Members"
For n=1 to 4
input Name$(n),n
CLS
sync
Next n
Rem Character/Enemy Array
DIM PChar(4) as Char
`
Rem Character Stats
For n= 1 to 4
PChar(n).Name$= Name$(n)
PChar(n).Str= Str(n)*lev(n)
PChar(n).Hp= Hp(n)*lev(n)*1.5
PChar(n).Att= Att(n)*lev(n)
PChar(n).MAtt= Mag(n)*lev(n)
PChar(n).Mp= Mp*lev(n)
next n
end
Rem Different Chars starting strenght
Str(1)=10
Str(2)=8
Str(3)=8
Str(4)=6
Rem Char starting Health
Hp(1)=120
Hp(2)=90
Hp(3)=80
Hp(4)=70
Rem Char starting Att
Att(1)=12
Att(2)=10
Att(3)=9
Att(4)=6
Rem Char starting Magic
Mag(1)=6
Mag(2)=6
Mag(3)=8
Mag(4)=14
Rem Char starting Magic
Mp(1)=6
Mp(2)=6
Mp(3)=8
Mp(4)=14
Rem
rem Save Game Code
Filename$="stats.dat"
Delete File FileName$
Open To Write 1,Filename$
For n= 1 to 4
Write String 1,Str$(Str(n))
Write String 1,Str$(Mag(n))
Write String 1,Str$(Def(n))
Write String 1,Str$(Vit(n))
Write String 1,Str$(Spr(n))
Next n
close file 1
Rem Loading Game code
rem Load stats
If File Exist(Filename$)
Open To Read 1,Filename$
For n= 1 to 4
Read String 1,T$: Str(n)=Val(T$)
Read String 1,T$: Mag(n)=Val(T$)
Read String 1,T$: Def(n)=Val(T$)
Read String 1,T$: Vit(n)=Val(T$)
Read String 1,T$: Spr(n)=Val(T$)
Next n
Close file 1
Else
Open To Write 1,Filename$
For N=1 To 4
Write String 1,Str$(Str(n))
Write String 1,Str$(Mag(n))
Write String 1,Str$(Def(n))
Write String 1,Str$(Vit(n))
Write String 1,Str$(Spr(n))
Next N
Close File 1
Endif