forums

TNT Basic Forums > Programming Q&A
Menu Tutorial/Example?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-01-2005 02:02

Posted by:
AGhost

Find more posts by AGhost

Hi,

I wanted to know if there were any good tutorials/examples of Menus in TXT Basic (i.e. Main Menu with Play, About, Exit)?

Thanks,
AGhost

12-01-2005 09:31

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Menu support...

TNT doesn't support menus. If you're talking about the TNT Basic.app menu then you're really out of luck, it can't be changed (but an interesting point Mark, now we've got windowed mode. Could build the TNT menus with resources?). Sorry, thinking on my feet there. Custom menus 'in game' would need to be handled with either buttons, sprites or custom collision calls on a static image. Buttons are the easiest, and sprites are the most flexible.
If you want to implement a 'Finder' like menu system (drop down variety) you simply need a click sensitive image as the menu and a boolean value to determine if it's "on" or "off". If it's clicked and it's off, turn it on and display the menu option buttons / sprites below it, otherwise, turn it off and hide the options. Using buttons allows you to have roll overs, which is harder (but not impossible) with sprites. Sprites however have the advantage of being able to 'appear' and 'disappear', animate or scroll onto the screen and they can be displayed at different depths (like above all other graphics for example) It just depends on the sort of thing you want to implement, so a tutorial or example code snippet would need to know these things, but I hope I've given you some food for thought.

Danny (nods)

12-01-2005 19:28

Posted by:
AGhost

Find more posts by AGhost

By Menus I mean a front page with buttons that can be clicked and lead to Game, Exit, etc.

Can this be done?

AGhost

12-01-2005 20:14

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Er, yes... You just did it.

Draw up your buttons and pop 'em on screen (New Button), then when your game loads you enter a loop that waits for a button press (Wait Button Click). Once you get a click, find out which button it was (button = Button Click) and go to the appropriate label / procedure. That's about it... There are 'near complete' games in the Directory which undoubtedly use this sort of entry method, just have a quick look at one or two, but it's really not complicated.

Danny (nods)

12-01-2005 20:33

Posted by:
AGhost

Find more posts by AGhost

How do you draw buttons, etc?
Is there an example of source code or a tutorial somewhere?

Thanks,
AGhost

12-01-2005 23:17

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Buttons are just sprites...

Draw them or get them as you would any other graphic. There are loads out there on the net or in collections of web art.

There are no tutorials on button handling (as far as I'm aware) because it's really not that hard. You 'draw' (or place) a button with the 'New Button' command. It takes an 'id value' so you can refer to it, x and y co-ordinates of the top left corner of the image, an 'initial image' (how the button looks normally), an 'over image' (how it looks when the mouse is over it, lit up a bit or something) and a 'down image' (what it looks like when it's been clicked on). The very next thing to do is 'Wait Button Click', which will pause the whole thing until one of your new buttons is clicked on. The code will sit there until this happens, so you then need to know which one it was. Enter 'button = Button Click'... You now know what the user clicked on and can jump to the relevant part of your code.
Give it a go, you'll see how easy it is, the hardest part is getting the graphics! If you do have any real problems then let us know and we will try and sort it out for you, but do try it first, the best way to learn is just by jumping in and messing up. We've all been there.
OK, have fun...

Danny (nods)

12-02-2005 08:56

Posted by:
Gustav

Location:
Lund, Sweden

Click Here to Email Gustav   Find more posts by Gustav

I wanna try that too!

Cool, Buttons may be needed for my cool sprite-warp-game.
It's a shame the sounds don't work though.

12-02-2005 11:44

Posted by:
AGhost

Find more posts by AGhost

Alright, this is what I tried but it doesn't work:



Repeat

Repeat

New Button 1,300,300,129,130,131
New Button 4,300,500,129,130,131

buttonhit = Button Click

Until Buttonhit > 0

If buttonhit = 1

Game Element Here

End if

Until buttonhit = 4

close canvas


Is this right?
What am I doing Wrong?

Thanks,
AGhost

12-02-2005 14:32

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

It's easier than that...

New Button 1,300,300,129,130,131
New Button 4,300,500,129,130,131
Wait Button Click
int button = Button Click

if button = 1
'do game stuff
else
'would check other buttons here...

if button = 4 then end

end if


That's a very simplistic structure, but done to show ease of use. If you put your game code in place it should work.
Said it was easy!

Danny (nods)

12-03-2005 13:00

Posted by:
AGhost

Find more posts by AGhost

Thanks a ton!

12-03-2005 13:06

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

You're Welcome!

Danny (nods)

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.