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 / Strategy game - loading soldier health.

Author
Message
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 5th Jan 2004 10:42 Edited at: 5th Jan 2004 10:45
I have made a code (attached) for loading archers and reading their health value. However, I can not see a way of shortening it and making it more effective. I thought of using a for... next like this
loop but that would store all the different data on the same variable (archerhealth#). Can someone help because otherwise this will not only take up hundreds of lines of code even if I had a limit of 200 archers, it also necessitates the limit.
NOTE: The attached code only prints the archer health so that I can test to see if it is working- it would be displayed better in a game.

P.S. Anyone who can help in any way with this style of game could you please reply with hints or source on this board because I haven't got a clue about making strategy games and the only feature I have started with so far is the loading archers bit and as you can see that is not going very well...

Am I the only one here who's really confused?
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Jan 2004 15:24
Suggestion:

Put your archers into an array. Change the code to...



BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jan 2004 10:44
dim archerhealth#(count)

for t=1 to count
archerhealth#(t) = number
next t


DBP would have even more advantages. By using TYPES, you can make a single array hold health, dmg, its name, etc...
It's better than having to do parallel arrays, which is what you'll have to probably do when you add more archer attributes.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 6th Jan 2004 22:18 Edited at: 6th Jan 2004 22:18
Thanx all. I have now managed to change
into
.

One question, however. How would I increase the number of archers later on in the game (this is the only part of the game I have done yet and was supposed to be just for practising saving but now I've started it I might as well have a shot at finishing it)? Would I have to do
or is there a way of just increasing the numbers of variables stored in an array. Please note: this code may be rubbish-I don't know, I've just figured it out and basically what it is supposed to do is make a second array with the new amount of archers, transfer all the variables to the second array and add a new one with full health (100). Then it deletes the original array, rebuilds it with the new number of archers, transfers the data back and deletes the seccond array. This is probably a very long-winded way of doing things, but please help! I NEED FEEDBACK - will this work?

Am I the only one here who's really confused?
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 6th Jan 2004 22:41
Just make an big juicy array



Ive added some comments, this is an example.


Quote: "
Amd 2500+ | 1024mb pc2700 | A7N8X-X | Geforce4 ti 4200 128mb
"
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 6th Jan 2004 22:48
Thanx. P.S. You were quick!

Am I the only one here who's really confused?

Login to post a reply

Server time is: 2025-05-22 08:52:51
Your offset time is: 2025-05-22 08:52:51