Logo

Blitz3D Forums/Blitz3D Beginners Area/Logo

HuNTeD(Posted 2005) [#1]
Hey, how would I go about making a logo at a begging of my game, having it fade in and then fade out and then the main menu for the game would appear?


Q(Posted 2005) [#2]
Hello, I have only been using Blitz3d for about 10 minutes total, but I suggest you check out the EntityAlpha command.


WolRon(Posted 2005) [#3]
Is this a 2D or 3D app?


HuNTeD(Posted 2005) [#4]
Oh, sorry its 2D


tonyg(Posted 2005) [#5]
Bit tricky inpure 2d as there are no alpha commands.
If you have B3D out might want to use a sprite.
Graphics3D 640,480
cam=CreateCamera()
MoveEntity cam,0,0,-1
sp = LoadSprite("grass1.png")
SpriteViewMode sp,4
alpha#=1.0
While Not KeyDown(1)
EntityAlpha sp,alpha
alpha=alpha-0.005
If alpha<0 Exit
RenderWorld:Flip

Wend
End

(might be a better way of doing it as I don't use sprites often). There's also a 'setgamma' method somewhere.
Alternative is using extended B2D DLL.
extended b2d dll
or writepixelfast...
writepixelfast
writepixelfast2
or Skidracer's fade...
fade


HuNTeD(Posted 2005) [#6]
NICE! Thanks a ton, that writepixelfast works really nice.


HuNTeD(Posted 2005) [#7]
Well, I got the fade in/out working but now my program doesn't work, it is saying an image isen't found, but it is there! Everything is corrected I've checked it tons of times but it's reading it like it is gone, any ideas?


jhocking(Posted 2005) [#8]
code please


HuNTeD(Posted 2005) [#9]
; sets the graphics mode
Graphics 800,600,0,2

; lets windows know the name of the program
AppTitle "Bounce Back v1.0"

;does everything in the background ready to show when "flip" is used
SetBuffer BackBuffer()

;The globals we'll need to use
Global Start 

;loads the images we'll need to use
Start = LoadImage("Images\Start.bmp")

;Stuff to show the Logo fade in and out
Delay 500

Blend_Black(logo,0,0,0,1000)

time = MilliSecs()+1000

While MilliSecs()<time

	DrawBlock logo,0,0
	Flip
	
Wend


Blend_Black(logo,0,0,1,1000)

Cls

;while esc. key isn't pressed
While Not KeyHit(1)

;program stuff, nothing goes wrong here

wend 
end


Function MainMenu()

	Cls
	
	DrawImage Start,300,125 ;;;;;;;;;;;;;;;;;;Problem is here, image not found
result=0

    While result=0

        mx=MouseX():my=MouseY()

		If RectsOverlap(300,125,200,100,mx,my,0,0) Then DrawImage StartOver,300,125 Else DrawImage Start,300,125 ;;;;;;;;;;;;;;;Problem here too, with Start image

flip
endif
wend
Function Blend_Black(image,x,y,mode,time)

;------------------------------------------------------------------
; Blends an Image with a Black Background (In & Out)
; -----------------------------------------------------------------
; Image = The Image to Blend
; x     = X Coordinate in the Screen
; y     = Y Coordinate in the Screen
;         50000 for both to center image
; Mode  = 0 Blend In
;       = 1 Blend Out
; Time  = Time in Milliseconds
;------------------


	source = ImageBuffer(image)
	dest   = BackBuffer()
	maxx   = ImageWidth(image)-1
	maxy   = ImageHeight(image)-1
	start  = MilliSecs()
	
	LockBuffer source
	
	If X = 50000 And y = 50000
		x = (GraphicsWidth()/2)-(ImageWidth(image)/2)
		y = (GraphicsHeight()/2)-(ImageHeight(image)/2)
	EndIf
	
	While MilliSecs()-start<time
Cls
		LockBuffer dest
		count=(count+1) Mod 4
		If count=0 Then minx=0: miny=0
		If count=1 Then minx=1: miny=1
		If count=2 Then minx=1: miny=0
		If count=3 Then minx=0: miny=1
		If mode=0 Then value=MilliSecs()-start
		If mode=1 Then value=time-MilliSecs()+start
		For ii=miny To maxy Step 2
			For i=minx To maxx Step 2
				rgb=ReadPixelFast(i,ii,source)
				r=(rgb And $FF0000)/$10000
				g=(rgb And $FF00)/$100
				b=rgb And $FF
				rgb=r*value/time*65536+g*value/time*256+b*value/time
				WritePixelFast x+i,y+ii,rgb,dest
			Next
		Next
		UnlockBuffer dest
		Flip
	Wend
	UnlockBuffer source
	If mode=0 Then DrawBlock image,x,y
	If mode=1 Then Color 0,0,0: Rect x,y,maxx+1,maxy+1
	Flip

End Function



tonyg(Posted 2005) [#10]
I can't see where 'logo' variables gets populated.
And you overwrite the image variable 'start' with millisecs in the function.
I think your loadimage was supposed to be in the 'logo' variable which is to be used in the function calls rather than start...
; sets the graphics mode
Graphics 800,600,0,2
; lets windows know the name of the program
AppTitle "Bounce Back v1.0"
;does everything in the background ready To show when "flip" is used
SetBuffer BackBuffer()
;The globals we'll need to use
Global logo 
;loads the images we'll need to use
logo = LoadImage("bmax160.png")
;Stuff to show the Logo fade in and out
Delay 500
Blend_Black(logo,0,0,0,1000)
time = MilliSecs()+1000
While MilliSecs()<time
	DrawBlock logo,0,0
	Flip
Wend
Blend_Black(logo,0,0,1,1000)
Cls
;while esc. key isn't pressed
While Not KeyHit(1)
;program stuff, nothing goes wrong here
Wend 
End
Function MainMenu()
	Cls
	DrawImage Start,300,125 ;;;;;;;;;;;;;;;;;;Problem is here, image not found
result=0
    While result=0
        mx=MouseX():my=MouseY()
		If RectsOverlap(300,125,200,100,mx,my,0,0) 
		    DrawImage StartOver,300,125 
		Else 
		    DrawImage Start,300,125 ;;;;;;;;;;;;;;;Problem here too, with Start image
		EndIf
	Flip
Wend
End Function
Function Blend_Black(image,x,y,mode,time)
;------------------------------------------------------------------
; Blends an Image with a Black Background (In & Out)
; -----------------------------------------------------------------
; Image = The Image to Blend
; x     = X Coordinate in the Screen
; y     = Y Coordinate in the Screen
;         50000 for both to center image
; Mode  = 0 Blend In
;       = 1 Blend Out
; Time  = Time in Milliseconds
;------------------
	source = ImageBuffer(image)
	dest   = BackBuffer()
	maxx   = ImageWidth(image)-1
	maxy   = ImageHeight(image)-1
	start  = MilliSecs()
	LockBuffer source

	If X = 50000 And y = 50000
		x = (GraphicsWidth()/2)-(ImageWidth(image)/2)
		y = (GraphicsHeight()/2)-(ImageHeight(image)/2)
	EndIf

	While MilliSecs()-start<time
		Cls
		LockBuffer dest
		count=(count+1) Mod 4
		If count=0 Then minx=0: miny=0
		If count=1 Then minx=1: miny=1
		If count=2 Then minx=1: miny=0
		If count=3 Then minx=0: miny=1
		If mode=0 Then value=MilliSecs()-start
		If mode=1 Then value=time-MilliSecs()+start
		For ii=miny To maxy Step 2
			For i=minx To maxx Step 2
				rgb=ReadPixelFast(i,ii,source)
				r=(rgb And $FF0000)/$10000
				g=(rgb And $FF00)/$100
				b=rgb And $FF
				rgb=r*value/time*65536+g*value/time*256+b*value/time
				WritePixelFast x+i,y+ii,rgb,dest
			Next
		Next
		UnlockBuffer dest
		Flip
	Wend
	UnlockBuffer source

	If mode=0 Then DrawBlock image,x,y
	If mode=1 Then Color 0,0,0: Rect x,y,maxx+1,maxy+1
	Flip
End Function



HuNTeD(Posted 2005) [#11]
Ooops, I forgot to show that I had logo populated... But you where right "start" was overwritten thanks for helpin me out.