Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Characters in a Turn-Based Strategy
#1
This is my first game project, and I'm having quite a bit of trouble with the game's characters. Most of my work has been on the map engine (saving/loading maps, drawing them, marking areas as impassible, placing objects, etc), which was pretty easy for me. With the characters, I don't know what to do.

Currently, what I need is set into arrays. Here's some examples
---
Army1XCoor(1 to 30) holds the X coordinate of each of the soldiers,
Army1YCoor(1 to 30) holds the Y
Army1Status(1 to 30) tells whether the soldier is alive or dead
Army1Name$(1 to 30) stores his/her name
Army1Class(1 to 30) tells the type of soldier this is
---

There are two armies, so imagine all of the arrays I've used having corresponding arrays in the second army. Now I've been working on the fight engine, which means I need a whole bunch of stats for health, magic power, experience/level-ups, ad infinatum. How should I organize all of this so that I don't go insane?

Should I store all of the standard information (how much experience is needed to gain a level, how health is calculated, spell information) in separate files and make 'Character Editors' and 'Spell Makers' and a variety of tools to mess with them?

And most importantly: what am I doing on a QBASIC forum at 1:20AM on a school night?
Reply
#2
Organize it this way:

Code:
Type ArmyType
xCoor as integer
yCoor as integer
Status as integer
Named as string * 10
Class as integer
End Type

Dim shared Army(1 to 30) as ArmyType

Army(1).xCoor=5
Army(2).yCoor=23
...

Hope you understand it
B 4 EVER
Reply
#3
What ak00ma said, but also, if you want smooth movement, you may want to define xOffset and yOffset, so the soldier can move within the current tile.

Additionally, you may want to add an xTarget and yTarget for where your character is moving to. This way the player can direct then once, and then they automatically move each turn or cycle.
Reply
#4
Thanks for the suggestions.

Wizardlife, I put in the TargetX,Y idea a while ago. I had a problem with the characters trying to inhabit the same tile, so I made the TargetX,Y count as a collision. The other idea, with the offsets... could you explain that a little more?

Ak00ma, I have a question about putting all of the information in a type. I did a quick test, where I DIM SHARED a few things, and in another file made an instance of a type with the same number of things in said type. The file that used the type was larger.. Does that mean that using types would lead to more memory usage? I really have no idea... I need to find ways to conserve memory while still having a variety of characters and such...
Reply
#5
Usually Types needs the same mass of memory...but as you see at the example "Named as string * 10" every String variable in a type has got a constant lenght, so if a string needs only 8 ASCIIs the string will include 10 ASCIIs cause it's constant...but that's the only thing I think which may possible cause to occurre a larger needing of memory...
B 4 EVER
Reply
#6
Well, if they'll take up the same amount of memory, then it sounds like making a type is a good idea. Thanks.
Reply
#7
Quote:Well, if they'll take up the same amount of memory, then it sounds like making a type is a good idea. Thanks.

For your own sanity, making a type would be worth it even if it took twice the memory. And in other languages, you'll get into classes: User Defined Types With An Attitude.

As far as the offset thing, I just mean so the character (or object) isn't always sitting in the middle of the tile and jumping from tile to tile. (Although it's more acceptable in a turn-based game) When you draw, instead of drawing at (TileX * 16, TileY *16), draw at (TileX * 16 + OffX, TileY *16 + OffY). And when you move something, don't move it one tile at a time, move it a couple pixels at a time. Then if the offset goes over 15 or under 0, you just compensate by changing the tile number.

It may not be necessary in your case, but it would make for some nice smooth straight-line movements.
Reply
#8
I've put a lot of work into the game so far, and I tried to put in types yesterday. It turned out to be way too much work to go through something that was already over 1000 lines of code and change all of the references. All of the variables/arrays that are related to a player have a prefix that lets me know who own them anyhow, so the work just doesn't seem to be worth it.

I started working on AI/pathfinding yesterday. I have to break it down into two areas: the map and the battle system. Once two characters enter combat, the battle system is called up. I've managed to make the computer act at least semi-intelligent on the map, but I need to add more options for him. So far, he does the following:

1)If there's someone within one tile of him, he moves to attack that person
2)If he has less than 40% of his maximum health, the character evades any hostile characters
3)If he has nothing else to do, he wanders the map randomly.

Next, I want him to be able to pick a target/point-of-interest and cross the map to find it.

Here is a link to a screenshot I took. The graphics look cheap because everything (the tiles and characters) is 10X10 in SCREEN 13. (In the battle system, the characters can take up to a maximum of 30X30). Besides that, 'I' drew them.

http:// http://qbblackwater.topcities.co...nShot.bmp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)