To n8r2k

Blitz3D Forums/Blitz3D Beginners Area/To n8r2k

seferey(Posted 2006) [#1]
Dear n8r2k I looked into your menu code I'ts exactly what I wanted. But for Me I had to tweak it for me because of the
few options I took so I wanted to show you what I did to your code the only problem I'm having is that I half to click twice to exit the menu plus I have it in full screen

Graphics3D 800,600,16,1
HidePointer()
AutoMidHandle True
SetBuffer BackBuffer()
SeedRnd MilliSecs()

Include "MakeSKYBOX1.bb"

Const GRAVITY#=-0.01

Global px = 400
Global sx = 400
Global py = 108 
Global sy = 238

;images
Global corneremblem = LoadImage("inu1.png")
Global mouse = LoadImage("Cursor4.png")
Global play = LoadImage("start.png")
Global quit = LoadImage("Quit.png")
 
;fonts
;Global font = LoadFont("lucida console",12,False,False,False)
;Global hitext = LoadFont("Impact",40,False,False,False)

;SetFont font

Mainloop()  
Function mainloop()

Repeat

If KeyHit(1)
	End
EndIf

HandleImage corneremblem,755,0
HandleImage mouse,0,0

Cls

DrawImage corneremblem,755,0
DrawImage play,px,py,0
DrawImage quit,sx,sy,0
DrawImage mouse,MouseX(),MouseY(),g
MaskImage mouse,255,255,255

Repeat

;If KeyHit(1)
;	End
;EndIf

HandleImage corneremblem,799,0
HandleImage mouse,0,0

Cls

DrawImage corneremblem,799,0
DrawImage play,px,py,0
DrawImage quit,sx,sy,0
DrawImage mouse,MouseX(),MouseY(),g

If ImagesCollide(mouse,MouseX(),MouseY(),0,play,400,108,0)
	;px = Rnd(398,402)
	;py = Rnd(106,110)
	;playframe = 1
Else
	px = 400
	py = 108
	;playframe = 0
EndIf

If ImagesCollide(mouse,MouseX(),MouseY(),0,quit,400,236,0)
	;cx = Rnd(398,402)
	;cy = Rnd(236,240)
	;cheatframe = 1
Else 
	sx = 400
	sy = 238
	;cheatframe = 0
EndIf 

If MouseHit(1)
	If ImagesCollide(mouse,MouseX(),MouseY(),0,quit,400,236,0)
		FlushMouse  
		Delay(500)
		Cls 
		If MouseHit(1)
	    End
        EndIf
		;Locate 0,0
		WaitMouse()
	ElseIf ImagesCollide(mouse,MouseX(),MouseY(),0,play,400,108,0)
			FlushMouse  
		Cls 
		Delay(500)
		If MouseHit(1)

;My game code here 



End 	

        EndIf
		;Locate 0,0
		WaitMouse()


	EndIf
EndIf

Flip

Forever 

Forever 

End Function 



n8r2k(Posted 2006) [#2]
cool, glad to help.


seferey(Posted 2006) [#3]
Do you know of a way to make it from being clicked twice

Anyone

I just want it to click once


n8r2k(Posted 2006) [#4]


It should only need one mouseclick now, You were checking for mouseclick twice, Didnt have time to make media to test it but it looks right

this code needed some improvement with the loops, The forever loop inside another one seemed redundant, so i changed it to cycle only once before returing to the outside loop.


seferey(Posted 2006) [#5]
It keeps telling me "Until without Repeat"

Until pie = good



seferey(Posted 2006) [#6]
go to my Downloads page it has a game of mine
witch is using your mouse menu

http://www.freewebs.com/tokien1/D1.html'

I have somewhat clean code


Jams(Posted 2006) [#7]
the problem is in the If MouseHit(1) block, end needs to be changed to endif!


seferey(Posted 2006) [#8]
jams thanks it worked YAHOOOOOO :)


seferey(Posted 2006) [#9]
When I change code with Jams suggestion it worked like this

If MouseHit(1)
	If ImagesCollide(mouse,MouseX(),MouseY(),0,quit,400,236,0)
	    FlushMouse   
		Cls  
		Delay(500) 
		If MouseHit(1) 
		Locate 0,0 
        EndIf
        End    
	ElseIf ImagesCollide(mouse,MouseX(),MouseY(),0,play,400,108,0)
	    FlushMouse  
		Cls 
		Delay(500)
		If MouseHit(1)
		Locate 0,0
        EndIf 



but hey the point is that I got it work correctly with all of your help of course :)


seferey(Posted 2006) [#10]
Hey n8r2k have you made function that returns you to the menu from the game itself


Jams(Posted 2006) [#11]
here's an example of the way i structure this sort of thing - might be useful for you :) (runs standalone)

;=====================================================================================================
Const TITLE_EXPIRED = 0				; User did not press start in time, go back to splash screen.
Const END_SESSION% = 1				; The user has opted to quit the application.
Const DISPLAY_CREDITS% = 2			; User chose to view the credits screen.
Const DISPLAY_OPTIONS% = 3			; User chose to view the options screen.
Const LOAD_GAME% = 4				; User chose to load a saved game.
Const START_GAME% = 5				; User chose to begin a new game.

Const CONCLUSION_SUCCESS = 0		; User successfully completed the level.
Const CONCLUSION_FAIL_RETRY = 1		; User failed the level, but wants to retry.
Const CONCLUSION_FAIL_EXIT = 2		; User failed the level, and wants to quit.
Const USER_QUIT = 3					; User manually quit the level before conclusion.

;=====================================================================================================

Graphics 640,480
SetBuffer( FrontBuffer() )
RunMenuSystem()

;=====================================================================================================

Function RunMenuSystem()
	Repeat
		DisplaySplashScreen()
		DisplayTitleScreen()
		Repeat
			Select DisplayMainMenu()
				Case TITLE_EXPIRED		: Exit
				Case END_SESSION		: Return END_SESSION
				Case DISPLAY_CREDITS	: DisplayCredits()
				Case DISPLAY_OPTIONS	: DisplayOptions()
				Case LOAD_GAME			: RunGameSession( RequestSaveGame() ): Exit
				Case START_GAME			: RunGameSession( 1 ): Exit
			End Select
		Forever
	Forever
End Function

Function DisplaySplashScreen%()
	Local SplashTime = Ticker_New( 3000 )
	Repeat: Flip: Cls
		Text( 320, 240, "THIS IS THE SPLASH SCREEN", True, True )
		Text( 320, 260, "COMPANY LOGO HERE?", True, True )
	Until Ticker_HasTicked( SplashTime )
End Function

Function DisplayTitleScreen%()
	Repeat: Flip: Cls
		Text( 320, 240, "THIS IS THE MAIN TITLE SCREEN", True, True )
		Text( 320, 260, "PRESS ENTER TO BEGIN", True, True )
	Until KeyHit( 28 )
End Function

Function DisplayMainMenu%()
	Local ExpireTime = Ticker_New( 30000 )
	Repeat: Flip: Cls
		Text( 320, 200, "THIS IS THE MAIN MENU", True, True )
		Text( 320, 220, "1 = EXIT GAME", True, True )
		Text( 320, 240, "2 = DISPLAY CREDITS", True, True )
		Text( 320, 260, "3 = DISPLAY OPTIONS", True, True )
		Text( 320, 280, "4 = LOAD GAME", True, True )
		Text( 320, 300, "5 = START GAME", True, True )

		If KeyHit( 2 ) Then Return END_SESSION
		If KeyHit( 3 ) Then Return DISPLAY_CREDITS
		If KeyHit( 4 ) Then Return DISPLAY_OPTIONS
		If KeyHit( 5 ) Then Return LOAD_GAME
		If KeyHit( 6 ) Then Return START_GAME
	Until Ticker_HasTicked( ExpireTime )
	Return TITLE_EXPIRED
End Function

Function DisplayCredits%()
	Repeat: Flip: Cls
		Text( 320, 240, "THIS IS THE CREDITS SCREEN", True, True )
		Text( 320, 260, "PRESS ENTER TO EXIT", True, True )
	Until KeyHit( 28 )
End Function

Function DisplayOptions%()
	Repeat: Flip: Cls
		Text( 320, 240, "THIS IS THE OPTIONS SCREEN", True, True )
		Text( 320, 260, "PRESS ENTER TO EXIT", True, True )
	Until KeyHit( 28 )
End Function

Function RequestSaveGame%()
	Repeat: Flip: Cls
		Text( 320, 240, "THIS IS THE SAVE GAME LOADER SCREEN", True, True )
		Text( 320, 260, "LETS SAY WE HAVE LOADED LEVEL 8 (it could be anything)", True, True )
		Text( 320, 280, "PRESS ENTER TO EXIT THIS SCREEN", True, True )
	Until KeyHit( 28 )
	Return 8
End Function

Function RunGameSession( DesiredStage )
   Repeat
      Select PlayLevel( DesiredStage )
         Case CONCLUSION_SUCCESS	: DesiredStage = DesiredStage + 1
         Case CONCLUSION_FAIL_RETRY	: ;Don't need to do anything
         Case CONCLUSION_FAIL_EXIT	: Return
         Case USER_QUIT				: Return
      End Select
   Forever
End Function

Function PlayLevel( Level )
	LoadLevel( Level )
	Repeat: Flip: Cls
		Text( 320, 220, "THIS IS THE MAIN GAME SCREEN", True, True )
		Text( 320, 240, "CURRENT LEVEL IS " + Level, True, True )
		Text( 320, 260, "1 = CONCLUSION SUCCESS", True, True )
		Text( 320, 280, "2 = CONCLUSION FAILURE RETRY", True, True )
		Text( 320, 300, "3 = CONCLUSION FAILURE EXIT", True, True )
		Text( 320, 320, "4 = QUIT GAME", True, True )

		If KeyHit( 2 ) Then Return CONCLUSION_SUCCESS
		If KeyHit( 3 ) Then Return CONCLUSION_FAIL_RETRY
		If KeyHit( 4 ) Then Return CONCLUSION_FAIL_EXIT
		If KeyHit( 5 ) Then Return USER_QUIT
	Forever
End Function

Function LoadLevel%( DesiredLevel% )
	Local SplashTime = Ticker_New( 2000 )
	Repeat: Flip: Cls
		Text( 320, 240, "THIS IS THE LOADING SCREEN", True, True )
		Text( 320, 260, "NOW LOADING LEVEL " + DesiredLevel, True, True )
	Until Ticker_HasTicked( SplashTime )
End Function

;!====================================================================================================
; Ticker type.
;!====================================================================================================
Type Ticker
	Field LastTick%
	Field Frequency%
End Type

Function Ticker_New%( NewFrequency%=1000 )
	Local this.Ticker	= New Ticker

	this\LastTick%		= MilliSecs()
	this\Frequency%		= NewFrequency%

	Return Handle( this )
End Function

Function Ticker_Dispose%( HND% )
	Local this.Ticker = Object.Ticker( HND% )

	Delete this
End Function

Function Ticker_Frequency%( HND%, NewFrequency%=-1 )
	Local this.Ticker = Object.Ticker( HND% )

	If ( NewFrequeny% = -1 )
		Return this\Frequency%
	Else
		If NewFrequency% > 0
			this\Frequency% = NewFrequency%
		EndIf
	EndIf
End Function

Function Ticker_HasTicked%( HND% )
	Local this.Ticker = Object.Ticker( HND% )

	If ( MilliSecs() > ( this\LastTick% +this\Frequency% ) )
		this\LastTick% = MilliSecs()
		Return True
	EndIf

	Return False
End Function



seferey(Posted 2006) [#12]
When someone clicks options I want to show them a png file that says options not available in Demo

How do I make it work that way

ImagesCollide(mouse,MouseX(),MouseY(),0,options,400,260,0)
	    FlushMouse   
		Cls    
		Delay(500)
		If MouseHit(1)
		Locate 0,0 
		EndIf 



seferey(Posted 2006) [#13]
Has anybody gotten to this type of problem