Suggestions for a menu system
Displaying 1-5 of 5 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Arkhan

I am making a menu system that isnt all jacked up and in depth.

Think something like Legend of Zelda etc.

The menu will be full screen and list

Armor: * * * *
Weapon: * * * *
Shield: * * * *
Accessory: * * * *

and then there will be Save, Load, and Status buttons to the right

To change equipment, you cursor down to say, weapon, and press Right and Left arrows to change which of the 4 options is selected.

I was thinking of just making an image that has the entire menu on it, and then blit a cursor that will move around the image for the various selections, and then if youre on Armor etc, and press right/left, it will highlight the proper box...

Does this sound like a good idea or is there something better to do? my aim si have a simple character menu!

Posted on 2007-02-21 14:26:02

zonker6666

I would suggest that you try to make something that is flexible enough
that you need not change any code if ever you decide to change or add to the menu.

For example - load up an image containing all the weapon icons
another with all armours - shields - accessories .. and blit or draw a rect over the currently selected one.

Rect((currectselection*widthoficon), 0,(currectselection*widthoficon)+widthoficon,heightoficon,somecolor,screen);

now as the user hits left or right you add 1 or remove 1 from currentselection and wrap it back depending on how many options there are ...

int numchoices = ImageWidth(weaponsstripimage)/widthoficon;

if(key[SCAN_RIGHT])
currentselection=(currentselection+1)%numchoices;


at that point you can add a new weapon (or whatever) and there would be no need (or very little need) to change your source code.


hope that helps ya out

Posted on 2007-02-24 20:40:44

Arkhan

hmmm not a bad idea, the only problem with loading an image with ALL of them is, what if they hadnt been purchased yet? if theyre not purchased yet, draw a black rectangle over them??

Posted on 2007-02-28 23:48:11

Overkill

Well, the thing is when all the items are in one image, you can use GrabRegion() to copy the chunks of the image that represent the items you own to the screen. So if you don't own, say, Magic Armor but have Cloth Armor, you'd grab the Cloth Armor picture out of the all-item image and place it on the screen. Magic Armor wouldn't be grabbed because you can check if it's in the inventory. You'd have some if() statements that check to see if you have a certain item, and otherwise it just draws nothing for that particular one.

Alternatively, assign each item a seperate image handle. And TBlit each item's image to the screen if you have the item, otherwise doing nothing.

Posted on 2007-03-01 02:23:31 (last edited on 2007-03-01 02:26:19)

zonker6666

Indeed, as overkill said using GrabRegion would be the idea way to do it .... and I'll even code a little example for you right now :)

lets say that you have a single long horizontal strip of 32x32 icons for all the weapons

_______________________
| _| _| _| _| _| _| _| _| _| _| _| _| _| <---- like that

then we could use a simple array of ints for the inventory

#define SWORD 0
#define AXE 1
#define SPEAR 2
#define COKE 4

int inventory[16]

i'll assume you want to draw the inventory in the order it was acquired ....

to draw it

void DrawInventory()
{
int i;

for(i=0;i<InventoryCount;i++)
DrawInventoryIcon(i);
}

void DrawInventoryIcon(int id)
{
int x= inventory[id]*32;
int destx=i*32;
int x2=x+32;
int y=0;
int y2=32;
int desty=0;

GrabRegion(x,y,x2,y2,destx,desty, preloadeditemstrip,screen);
}



note- InventoryCount would be a global int that gets ++ed every
time a new item is found ---

void AcquireItem(int itemid)
{
inventory[InventoryCount]=itemid;
InventoryCount++;
}

note 2- preloadeditemstrip is another global - in this case its the handle to the items image. Dont forget to free that at the end of
the app. ;)


cheers

Posted on 2007-03-01 05:14:57


Displaying 1-5 of 5 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.