playMaker

Author Topic: Menu Driven Game W/ Database  (Read 3710 times)

IceMaker

  • Playmaker Newbie
  • *
  • Posts: 14
Menu Driven Game W/ Database
« on: January 23, 2014, 09:28:42 PM »
Hey everyone! As primarily an artist I've been absorbing a lot of C#, SQL, and now Arrays in an attempt to put together a game that's simple in concept but has a lot of stats to keep track of.

The active team of wolves are kept in a database, I have the number of active members saved as a variable. This variable is updated as members are removed or added.

Clicking on the arrow should load the next member into the GUI (Name, Portrait, Stats, etc.) Allowing you to scroll through them and when reaching the last member, it cycling back to team member #1.

I can't use SQL for it because if you go past the real number of members it will trigger an error.

First

SELECT * FROM wolfStats WHERE isActiveParty=1;

Then I check how many rows there are. In this case "3". Which means there are 3 members in the party.

Now I want it to default to member #1 while allowing player to click Right Arrow to load #2, then #3, and afterwards return to #1. Or at any time press Left Arrow to go the other direction.

Is an Array my only option to achieve this? I was able to store values in an array but still figuring out how to view the values in a way that would be useful to this problem.
« Last Edit: January 23, 2014, 09:36:52 PM by IceMaker »

Marsh

  • Full Member
  • ***
  • Posts: 227
  • Comfort the disturbed, disturb the comfortable
Re: Menu Driven Game W/ Database
« Reply #1 on: January 23, 2014, 09:48:30 PM »
Not quite sure what you are trying to do?

You just want to loop through your members by tapping right? Just check the length of the array

wolves[] array;
int index = 0;
if(leftKey) {
if(index > array.length)
index = 0;

array[index++];
}