My Cursor image doesn't show up over the mouse!!!!

Blitz3D Forums/Blitz3D Programming/My Cursor image doesn't show up over the mouse!!!!

Captain Wicker (crazy hillbilly)(Posted 2011) [#1]
i am trying to get my custom PNG image to appear over the mouse cursor icon in my game. Could someone please tell me what is wrong with my code?
Setup() 

AppTitle ("Bucky GamePlay V0.1")



Const p1_coll=1 
Const op1_coll=2 
Const WW1_coll=3
Const camdistance=03.2



AmbientLight 200, 200, 200
Global cam1=CreateCamera() 
Global light=CreateLight(2) 
CameraRange cam1,1,2000000 
LightRange light,2000000 





; ADD NEW MENU & MOUSE PICK variables HERE
Global spr_menu, spr_start, spr_quit, spr_credits, spr_cur
Global currentpicked, lastpicked, LeaveMenu=False, ShowCredits=False, speech$, AMMO=10


; Load World Objects Here

Type Projectile			
    Field sprite, time_out
End Type

Type Explosion			
    Field sprite, scale#
End Type

Type Sprite	
	Field ID, char_tex
	Field pt1, pt2
	Field targetpt
	Field temper
	Field speech$	; Let's add some conversation!
End Type

; Load MENU Sprites *************************
spr_menu = LoadSprite( "menu.tga", 7, cam1 )		; Stick to camera
ScaleSprite spr_menu, 2, 1.5						; Enlarge a bit
MoveEntity spr_menu, 0, 0, 2						; Move in front of camera
HideEntity spr_menu									; Hide until needed

spr_start = LoadSprite( "btn_start.bmp", 7, cam1 )	; Stick to camera
ScaleSprite spr_start, .25, .25						; Shrink a bit
EntityRadius spr_start, .25							; Adjust PICK radius
MoveEntity spr_start, -.5, 0, 2						; Move in front of camera
HideEntity spr_start								; Hide until needed
EntityPickMode spr_start,1							; Make "PICKable"	

spr_quit = LoadSprite( "btn_quit.bmp", 7, cam1 )		
ScaleSprite spr_quit, .25, .25
EntityRadius spr_quit, .25
MoveEntity spr_quit, 0, 0, 2						
HideEntity spr_quit	
EntityPickMode spr_quit,1

spr_credits = LoadSprite( "btn_credits.bmp", 7, cam1 )	
ScaleSprite spr_credits, .25, .25
EntityRadius spr_credits, .25
MoveEntity spr_credits, .5, 0, 2
HideEntity spr_credits	
EntityPickMode spr_credits,1


; CURSOR IMAGE
spr_cur = LoadImage( "cursor.png" )





; Load HUD Sprite **************************
spr_ammo = LoadSprite( "heart.bmp", 7, cam1 )	
ScaleSprite spr_ammo, .25, .25						
MoveEntity spr_ammo, -1.7, -1.3, 2.1
EntityAlpha spr_ammo, .5	

; *******************************************

explosion_sprite=LoadSprite( "explosion.bmp" )
HideEntity explosion_sprite

projectile_sprite=LoadSprite( "heart.bmp" )
EntityRadius projectile_sprite, 2
EntityType projectile_sprite, coll_projectile
HideEntity projectile_sprite




Global world=CreateSphere(100)
ScaleEntity world,50,50,50
Global sky=LoadTexture("media/world/sky.png")
EntityTexture world,sky
FlipMesh world


Global terrain=CreateTerrain(128) 
Global grass=LoadTexture("media/world/grass.png")
EntityTexture terrain,grass
TerrainDetail terrain,128,True
PositionEntity terrain,-50,-8,-50



Global sphere=LoadMesh("media/bucky/bucky.x") 
Global obpiv=CreatePivot(sphere) 

PositionEntity obpiv,0,terrain_Y,-camdistance

PositionEntity sphere,0,-5,5 
PointEntity light,cam1 
Global cube=CreateCube()
PositionEntity cube,0,0,15

EntityType sphere,p1_coll 
EntityType cube,op1_coll 
EntityType world,WW1_coll

CameraClsColor cam1,145,201,242



Collide()

fntArial=LoadFont("Arial", 36, True )		 
SetFont fntArial

MENU()	; Run Menu at Start of Game!

While QUIT = False	; Use QUIT flag instead
    
	; Escape key now brings up menu!
	If KeyHit( escape_key ) Then MENU()
	; New function allows us to SELECT sprites with our mouse!
	MousePick()
	
    
    
   ; Escape()
    
    SmoothCam(obpiv,sphere,50)
    
    Movement()
    
    
    Sync() 
    
    
Wend


Function Setup()
    Graphics3D 800,600,32,2
    SetBuffer BackBuffer()
End Function

Function Movement() 
    If KeyDown(200) Then MoveEntity sphere,0,0,0.1 ;foreword
    If KeyDown(208) Then MoveEntity sphere,0,0,-0.1 ;backword
    
    If KeyDown(203) Then TurnEntity sphere,0,1,0 ;left
    If KeyDown(205) Then TurnEntity sphere,0,-1,0 ;right
End Function

Function Sync() 
    UpdateWorld
    RenderWorld
    Flip
End Function

Function Escape() 
    
    If KeyHit(1) Then End
End Function

Function SmoothCam(pivot,target,camspeed) 
    
    curx#=EntityX(cam1)
    curz#=EntityZ(cam1)
    
    destx#=EntityX(pivot,True)
    destz#=EntityZ(pivot,True)
    
    curx#=curx#+((destx#-curx#)/camspeed)
    curz#=curz#+((destz#-curz#)/camspeed)
    cury#=1
    
    PositionEntity cam1,curx#,cury#,curz#
    PointEntity cam1,target
    
End Function

Function Collide()
    Collisions WW1_coll,p1_coll,2,1
    Collisions p1_coll,WW1_coll,2,1
    Collisions p1_coll,op1_coll,3,1 ;I cant go through enemy
    Collisions op1_coll,p1_coll,3,1 ;enemy cant go through me
    
End Function

Function MENU()			; MENU
	
	ShowEntity spr_menu	
	ShowEntity spr_start
	ShowEntity spr_quit	
	ShowEntity spr_credits
    
	LeaveMenu=False 
	
	While Not KeyHit( escape_key )
		
		MousePick()
		If QUIT=True Then Return
		If LeaveMenu = True Then Exit
		
		UpdateWorld 
		RenderWorld
		
		If ShowCredits = True Then
			Color 0,0,0
			Text 10,10, "Created by:"
			Text 10,40, "Captain Wicker (Austin)"
		EndIf
        
		Flip
		Delay 10
	Wend
	
	HideEntity spr_menu	
	HideEntity spr_start
	HideEntity spr_quit	
	HideEntity spr_credits
    HideEntity spr_cur
	LeaveMenu=False
	ShowCredits=False
    
End Function

Function MousePick()		; MOUSEPICK
	currentpicked = CameraPick( cam1, MouseX(), MouseY() ) 
    DrawImage spr_cur,MouseX(),MouseY()
    Cls
	If currentpicked>0 And MouseHit(1)
		If currentpicked = spr_start Then LeaveMenu = True
		If currentpicked = spr_quit Then QUIT=True
		If currentpicked = spr_credits Then ShowCredits = True
		For Character.Sprite = Each Sprite
			If currentpicked = Character\ID
				speech$ = Character\speech$
                Exit
			EndIf
		Next
	EndIf
	If MouseHit(2) Then speech$=""		;Right Mouse Click Closes Speech
	If currentpicked<>lastpicked
		If lastpicked Then EntityAlpha lastpicked, 1	;UNDO fade when mouse leaves
		lastpicked=currentpicked
	EndIf
	If currentpicked
		EntityAlpha currentpicked, Sin( MilliSecs() )*.3+.7
	EndIf
End Function



Yasha(Posted 2011) [#2]
You can't draw over the mouse cursor, because it's an entirely separate operating system element from the game window which Windows draws to the screen last (everything you draw just affects a rectangular buffer, which Windows will draw all in one block once the frame is done).

If you use fullscreen mode, the cursor will not appear. In windowed mode, you can call HidePointer to prevent the Windows pointer being drawn when the mouse is within the border of the window (use ShowPointer to bring it back if for some reason you want it later).


Captain Wicker (crazy hillbilly)(Posted 2011) [#3]
My PNG file doesn't show up at all though???


Matty(Posted 2011) [#4]
That's because you are drawing spr_cur before clearing the screen with cls.

Draw spr_cur last, after drawing everything else..