My mouse has gone?

Just starting out? Need help? Post your questions and find answers here.
coffeebean
User
User
Posts: 14
Joined: Sat Aug 16, 2003 6:16 pm

My mouse has gone?

Post 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

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

coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

try this :

ShowCursor_(1)
SetCursor_(LoadCursor_(0,#IDC_ARROW))
coffeebean
User
User
Posts: 14
Joined: Sat Aug 16, 2003 6:16 pm

Post 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.
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post 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...
coffeebean
User
User
Posts: 14
Joined: Sat Aug 16, 2003 6:16 pm

Post 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.
:(
coffeebean
User
User
Posts: 14
Joined: Sat Aug 16, 2003 6:16 pm

Post 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:
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
coffeebean
User
User
Posts: 14
Joined: Sat Aug 16, 2003 6:16 pm

Post 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.
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post 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

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post 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...
Post Reply