Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Need help with Arrays/Types and would a program automatically remember new values for variables

Author
Message
Jonathan Valintine
20
Years of Service
User Offline
Joined: 30th Apr 2005
Location:
Posted: 22nd Apr 2009 23:21
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.



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.



BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 22nd Apr 2009 23:25
Well (not to be sarcastic), since types aren't supported in DBC, I would stick to Arrays.

And that should work to just increase the level value. The only time a variable wouldn't be kept is if it were in a function, which would be a wrench in the machine.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 23rd Apr 2009 06:23
darkedit extended syntax does.

New Site! Check it out \/
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Apr 2009 16:12
There seems to be a lot of questions like this on the board, have a look around and you might find the answers you're looking for.

Arrays take quite a while to get the hang of (or purpose of), but basically they are just a block of similar variables grouped together so you can access and manipulate them more easily.
Whenever you have more than two similar variables to keep track of I would suggest using an array.
The first time I realised the benefits of arrays is when I saw someone use them in a for loop...

Arrays are much more flexible than single variables, because instead of rigid variable names that have to be hard-coded, you can call them by their number meaning you can use calculations to reference the array.
A great and simple example is a map; a 2D map can be stored in a 2D array i.e. array(x,y), referencing the x and y co-ordinates will take us to a grid square (box y on column x), I gave a full example on another thread.

can't read?
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 23rd Apr 2009 16:22
[sorry have to dp]
I read your code and you do seem to be trying to create a template for these characters, use DATA statements for that, I gave an example on a thread by razerx.
Also try using multiple arrays and clearer array names, e.g. p1_strength(n), p1_vitality((n) Using more than one array for one character may seem strange but it's much easier to follow and because you use numbers to reference the data, number n in each array will refer to data for character n.

can't read?

Login to post a reply

Server time is: 2025-06-08 05:53:37
Your offset time is: 2025-06-08 05:53:37