|
Post by Wayne Rayner on Apr 11, 2010 7:45:37 GMT -5
Hey Guys, now with my experience in programming gotten a lot higher since I originally started in Basic4GL and learning that goto is not a good programming practice. However since I find it easier for me I will keep programming my management games that I use a engine I created (However I have been using subs more and more) I will be adding a new update to this program that allows roll over images when the mouse is over the button. So if you do decide to use bad programming practice where you will use like 1000000000000 variables then this menu system is for you 100%. I have to thank one person for this although he didn't exactly help make it I re-adapted crazynates Menu Demo he created for me a while back. I am no longer pasting source code to the posts and instead creating zip files with the graphics already as it will make it easier for you to check it out. The original version is in this post available for downlaod however I reccommend the 1.1 version which runs better but in total honesty I would wait until version 2.0 comes out as it works even better and should be ready in a few hours as I am just recreating it using my game I am currently creating right now. yours Wayne Rayner Attachments:
|
|
|
Post by aphoticgenesis on Apr 11, 2010 12:59:24 GMT -5
nice job, two things need added though to stop that text from flickering add TextMode(TEXT_BUFFERED) at the top of your program and DrawText() above wend good job though on the menu system
|
|
|
Post by Wayne Rayner on Apr 11, 2010 15:03:45 GMT -5
Well I have updated the code well I did at bout 3am. Added is a back button. here is the source code '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Menu System for Basic4GL ' Created by Wayne Rayner ' Version 1 bug fix 1 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Load Images and Create Sprites dim tex(4), new, load, options, credits, back dim buttonactive dim cursor(1)
Menu: tex(0) = LoadTex ("new_but.png") tex(1) = LoadTex ("load_but.png") tex(2) = LoadTex ("options_but.png") tex(3) = LoadTex ("credits_but.png")
new = NewSprite (tex(0)) SprSetPos (320,100) SprSetSize (150,50) BindSprite (new)
load = NewSprite (tex(1)) SprSetPos (320,200) SprSetSize (150,50) BindSprite (load)
options = NewSprite (tex(2)) SprSetPos (320,300) SprSetSize (150,50) BindSprite (options)
credits = NewSprite (tex(3)) SprSetPos (320,400) SprSetSize (150,50) BindSprite (credits) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' The Menu Function while true ResizeText (80,50)
cursor(0) = Mouse_X()*640 cursor(1) = Mouse_Y()*480
' Tests for mouse hover if cursor(0)>(SprLeft(new)) and cursor(0)<(SprRight(new)) and cursor(1)>(SprTop(new)) and cursor(1)<(SprBottom(new)) then locate 0,0: print "New " buttonactive = 1 elseif cursor(0)>(SprLeft(load)) and cursor(0)<(SprRight(load)) and cursor(1)>(SprTop(load)) and cursor(1)<(SprBottom(load)) then locate 0,0: print "Load " buttonactive = 2 elseif cursor(0)>(SprLeft(options)) and cursor(0)<(SprRight(options)) and cursor(1)>(SprTop(options)) and cursor(1)<(SprBottom(options)) then locate 0,0: print "Options " buttonactive = 3 elseif cursor(0)>(SprLeft(credits)) and cursor(0)<(SprRight(credits)) and cursor(1)>(SprTop(credits)) and cursor(1)<(SprBottom(credits)) then locate 0,0: print "Credits " buttonactive = 4 else ClearRegion(0,0,10,0) buttonactive = 0 endif ' if left mouse button is clicked goto ... function if Mouse_Button(0) = true and buttonactive = 1 then goto New: elseif Mouse_Button(0) = true and buttonactive = 2 then goto Load: elseif Mouse_Button(0) = true and buttonactive = 3 then goto Options: elseif Mouse_Button(0) = true and buttonactive = 4 then goto Credits: endif wend
New: DeleteSprite (new) DeleteSprite (load) DeleteSprite (options) DeleteSprite (credits) cls printr "New Page"
tex(4) = LoadTex ("back_but.png") back = NewSprite (tex(4)) SprSetPos (320, 400) SprSetSize (150, 50) BindSprite (back)
while true cursor(0) = Mouse_X()*640 cursor(1) = Mouse_Y()*480 if cursor(0)>(SprLeft(back)) and cursor(0)<(SprRight(back)) and cursor(1)>(SprTop(back)) and cursor(1)<(SprBottom(back)) then locate 0,0: print "Menu " buttonactive = 5 endif if Mouse_Button(0) and buttonactive = 5 then DeleteSprite (back) goto Menu: endif wend
Load: DeleteSprite (new) DeleteSprite (load) DeleteSprite (options) DeleteSprite (credits) cls print "Load Page"
tex(4) = LoadTex ("back_but.png") back = NewSprite (tex(4)) SprSetPos (320, 400) SprSetSize (150, 50) BindSprite (back)
while true cursor(0) = Mouse_X()*640 cursor(1) = Mouse_Y()*480 if cursor(0)>(SprLeft(back)) and cursor(0)<(SprRight(back)) and cursor(1)>(SprTop(back)) and cursor(1)<(SprBottom(back)) then locate 0,0: print "Menu " buttonactive = 5 endif if Mouse_Button(0) and buttonactive = 5 then DeleteSprite (back) goto Menu: endif wend end
Options: DeleteSprite (new) DeleteSprite (load) DeleteSprite (options) DeleteSprite (credits) cls print "Options Page"
tex(4) = LoadTex ("back_but.png") back = NewSprite (tex(4)) SprSetPos (320, 400) SprSetSize (150, 50) BindSprite (back)
while true cursor(0) = Mouse_X()*640 cursor(1) = Mouse_Y()*480 if cursor(0)>(SprLeft(back)) and cursor(0)<(SprRight(back)) and cursor(1)>(SprTop(back)) and cursor(1)<(SprBottom(back)) then locate 0,0: print "Menu " buttonactive = 5 endif if Mouse_Button(0) and buttonactive = 5 then DeleteSprite (back) goto Menu: endif wend end
Credits: DeleteSprite (new) DeleteSprite (load) DeleteSprite (options) DeleteSprite (credits) cls printr "Credits Page" printr "Created by ParabotaiStudios" Printr "Programmed by Wayne Rayner (code adapted from Crazynate's demo)" printr "Graphics by Wayne Rayner" printr "Thanks for using my MenuSystem"
tex(4) = LoadTex ("back_but.png") back = NewSprite (tex(4)) SprSetPos (320, 400) SprSetSize (150, 50) BindSprite (back)
while true cursor(0) = Mouse_X()*640 cursor(1) = Mouse_Y()*480 if cursor(0)>(SprLeft(back)) and cursor(0)<(SprRight(back)) and cursor(1)>(SprTop(back)) and cursor(1)<(SprBottom(back)) then locate 0,0: print "Menu " buttonactive = 5 endif if Mouse_Button(0) and buttonactive = 5 then DeleteSprite (back) goto Menu: endif wend end I hate these functions. Anyways I might create another version that will have a mouse over image as well. then I can get rid of the text and now more flickering. yay. Attachments:
|
|
|
Post by crazynate on Apr 11, 2010 16:27:55 GMT -5
Good job on your menu, but I recommend changing the position of the "back" button to one of the corners and adding "sleep(100)" before each "while".
|
|
|
Post by shadow008 on Apr 11, 2010 16:48:04 GMT -5
|
|
|
Post by Wayne Rayner on Nov 25, 2015 10:19:23 GMT -5
Hey guys, I have finally released version 2.0 Changes from version 1.1 are: - Added Roll Over Image - Added DisplayText(Text$,SizeX,SizeY,LocationX,LocationY) - Uses TextMode(TEXT_BUFFERED) Note: This version doesn't have many screens but you should be able to see how the code works with using normal print/r function and using my proprietary DisplayText sub not really Proprietary since you can use it for anything you want just thought it sounded cool. Also it uses the toolbox plugin for the window title function and I have included the 2 .dll files for the toolbox plugin The most important thing is the buttons roll over in this version and that there is a new version after 5 and a half years Menu System V2.0.zip (84.21 KB)
|
|
|
Post by matthew on Nov 25, 2015 14:14:58 GMT -5
Hi Wayne, the "Roll Over Image" feature looks very professional. What made you come back to it after 5 years?
|
|
|
Post by Wayne Rayner on Nov 26, 2015 7:23:44 GMT -5
I actually updated this code earlier on in the year and just couldn't be bothered uploading it and then today or yesterday i decided to upload the changes. It is the same roll over system for my other games that had roll over buttons
|
|