Page 1 of 1

My mouse has gone?

Posted: Sat Aug 16, 2003 10:41 pm
by coffeebean
Hi im making a windowed game and just doing some tests to get used to the new commands (Blitzbasic user), I've set up a window and inside the window ive setup a screen to draw on, the problem is that my mouse is invisable, it still works just cant see it. :?:

Heres the code no external media is required just copy'n'paste and hit F5.

Code: Select all

InitKeyboard()
InitSprite()
InitMouse()
Global x
; #####################################################################################################

OpenWindow(0,640,480,640,480,#PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , Title$)
  CreateMenu(0, WindowID())
     MenuTitle("Project") 
        MenuItem(1, "Open") 
        MenuBar()
        MenuItem(4, "Close") 

OpenWindowedScreen(WindowID(),5,5,300,200,0,1,1)

; #####################################################################################################

Procedure Quit()

  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    End
  EndIf
  
  Event = WindowEvent()
  If Event = #PB_EventCloseWindow
    End
  EndIf

EndProcedure

; #####################################################################################################

Structure test
  x.w
  y.w
EndStructure

NewList test.test()

; #####################################################################################################

Procedure add()

    AddElement(test())
    test()\x=MouseX()
    test()\y=MouseY()

EndProcedure

Procedure delete()
    If test()\x=MouseX() And test()\y=MouseY()
    DeleteElement(test())
    EndIf

EndProcedure

 AddElement(test())
    test()\x=100
    test()\y=100

; #####################################################################################################

Procedure DrawScreen()

  ClearScreen(0,0,0)
  StartDrawing(ScreenOutput())
    
    ResetList(test())
      ExamineKeyboard()
        If KeyboardPushed(#PB_Key_Right)
          x=x+1
        EndIf
        If KeyboardPushed(#PB_Key_Left)
          x=x-1
        EndIf
       While NextElement(test()) 
           Box(test()\x+x,test()\y+y,32,32,$2141DE)
       Wend 

  FlipBuffers()
  StopDrawing()  

EndProcedure

; #####################################################################################################
; #####################################################################################################
; #####################################################################################################

Repeat

  Quit()
  DrawScreen() 
  
  ExamineMouse()
  If MouseButton(1)
    add()
  EndIf
  If MouseButton(2)
    delete()
  EndIf

forever

; #####################################################################################################
; #####################################################################################################
; #####################################################################################################


Posted: Sat Aug 16, 2003 11:16 pm
by coma
try this :

ShowCursor_(1)
SetCursor_(LoadCursor_(0,#IDC_ARROW))

Posted: Sat Aug 16, 2003 11:29 pm
by coffeebean
Hummm..... nope it bugged on ShowCursor_(1), said its not a function or not avaliable in the demo version. I Didn't find an Cursor commonds in the help text either. :?

I got the problem tracked down to ExamineMouse() in my main game loop, but without it i cannot do actions on my drawing screen. Hum.

Posted: Sat Aug 16, 2003 11:43 pm
by LarsG
@coffeebean:
There are functions that are not listed in the documentation...
and also, there are some limitations to the demoversion, so I'd suggest buying the full version right away.. :)
(at least if you're going to port you two BB games, which I personally look forward too :))

PB is so cheap anyways... :D

-Lars

Posted: Sun Aug 17, 2003 12:03 am
by coma
there's no Win32 API support in demo version, it's the reason you can't use some functions.

anyway, my method is not very good, cause you can move the cursor outside the window. And in fullscreen mode, the cursor disappear.

so, if someone have any solution...

Posted: Sun Aug 17, 2003 12:13 am
by coffeebean
I want the cursor to move outside of the window (i dont need it stay within the screen), i just want to see the cursor, right now it just invisable.
:(

Posted: Sun Aug 17, 2003 1:28 am
by coffeebean
Hum looks like im life with PB was short lived, From digging round the docs and this fourm i have fond that there is currently no way to catch mouse clicks in a windowed screen.. Oh well, I guess i'll have to go with Blitzplus. I'll be checking back thought from time to time. :cry:

Posted: Sun Aug 17, 2003 5:17 am
by Karbon
Really? No way to do that?? Hmm. I hope that's not true!

Are you sure you're not running into limitations of the demo version?

Posted: Sun Aug 17, 2003 9:30 am
by LarsG
@coffeebean:
Is this what you wanted?
(used Hypervox's game setup, and added mouse-checks)

Code: Select all

;/////////////////////////////////////////////////////
; Blank Games Program....
; (C) Shaun Raven 2003 - Use freely...
;/////////////////////////////////////////////////////
;//////////////////////////////////////////////////////////////
;- Initialisation
;//////////////////////////////////////////////////////////////
;- Window Constants
;
#Window_0 = 0
;- Screen constants
#SCREEN_WIDTH = 640
#SCREEN_HEIGHT = 480
;- Window Title
Title$ = "Blank Program"
; Initialistion code...
; 1. create a window
If OpenWindow(#Window_0, 216, 0, #SCREEN_WIDTH, #SCREEN_HEIGHT,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , Title$)
  If CreateGadgetList(WindowID())
      
  EndIf
EndIf
; 2. Initialise the sprite & keyboard engines
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Error","Can't open DirectX",0)
  End
EndIf
; 3. Create a double buffered screen, assigned to your Window
If OpenWindowedScreen(WindowID(),0,0,#SCREEN_WIDTH, #SCREEN_HEIGHT,0,0,0)
  ;//////////////////////////////////////////////////////////////
  ;- GAME LOOP
  ;//////////////////////////////////////////////////////////////
  Repeat
     ;//////////////////////////////////////////////////////
     ;- Game Logic
     ;//////////////////////////////////////////////////////
     
     ;//////////////////////////////////////////////////////////////
     ;-Transformations
     ;//////////////////////////////////////////////////////////////
     ;-     
     ;///////////////////////////////////////////////////
     ;- Input
     ;///////////////////////////////////////////////////
     
     ;if escape pressed, leave program,
     ExamineKeyboard()
     If KeyboardPushed(#PB_Key_Escape) 
        done = 1
     EndIf
     Event = WindowEvent()
     If Event = #PB_EventCloseWindow
       done = 1
     EndIf
     ;//////////////////////////////////////////////////////////////
     ;- Transform Player
     ;//////////////////////////////////////////////////////////////
     If ExamineMouse()
      mx = MouseX(): my = MouseY()
      If MouseButton(1)
        a = Random(255)
      EndIf
      If MouseButton(2)
        b = Random(255)
      EndIf
      If MouseButton(3)
        c = Random(255)
      EndIf
     EndIf
     ;//////////////////////////////////////////////////////////////
     ;- Rendering      
     ;////////////////////////////////////////////////////////////// 
     ClearScreen(a,b,c)
     If StartDrawing(ScreenOutput())
       ; we draw here
       Plot(mx,my,$ffffff)  
       FlipBuffers()
       StopDrawing()         
     EndIf
     ;//////////////////////////////////////////////////////////////
     ;- Music, sound effects & housekeeping
     ;////////////////////////////////////////////////////////////// 
  Until done = 1
EndIf
;///////////////////////////////////////////////////////
;- Tidy up here if required
;///////////////////////////////////////////////////////
End

Posted: Sun Aug 17, 2003 1:06 pm
by coffeebean
LarG - I can do that no problem but the mouse commands that i need will either only work on gadgets or only work on a screen, not both together.

This brought up on these forums.
viewtopic.php?t=3229&highlight=pbeventtypeleftclick

If you take a look at my Push'em editor you can see that I need to interact with gadgets and also catch click on the screen so i can build the level.

Image

I dont see how having access to the windows API will solve this.

Posted: Sun Aug 17, 2003 1:33 pm
by LarsG
Hmmm.. a possibility could be to draw to an image, and display that image using an ImageGadget?!?

Either that, or to make your own (or use someone elses) gadgets/gui..

-Lars

Posted: Sun Aug 17, 2003 1:59 pm
by Num3
Why don't you open 2 windows?

One with all the gadgets and another with the game editor zone ?

Something similar to the Visual Editor...