Isometric demo code

Advanced game related topics
mipooh
New User
New User
Posts: 4
Joined: Tue Dec 21, 2004 2:45 am

Post by mipooh »

Just re-downloaded the files, the´re still wrong...
Added the # here and changed the keys, so it works now.

The mouse cannot leave. Don´t know why, I think it is because of the windowedscreen, don´t know how to get the mouse out of that jail...

Too late for thinking now... again tomorrow.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

mipooh wrote:Just re-downloaded the files, the´re still wrong...
Added the # here and changed the keys, so it works now.

The mouse cannot leave. Don´t know why, I think it is because of the windowedscreen, don´t know how to get the mouse out of that jail...

Too late for thinking now... again tomorrow.
It's because of the windowedscreen, it sucks...
I like logic, hence I dislike humans but love computers.
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

Use WindowMouseX() and wait for 4.0 Fred said he already fixed it in the new Lib
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Post by aaron »

Joakim Christiansen wrote: It's because of the windowedscreen, it sucks...
Well, its true that windowedscreen is a big pain in the *ss, but its not too hard to sort out... just need to track the cursor and release it or grab it depending on the situation. Here is some example code that was posted on the forums... fweil I think:

Code: Select all

  Quit = #False
  If InitSprite()
    If InitKeyboard()
      If InitMouse()
        WindowXSize = 800
        WindowYSize = 600
        If OpenWindow(0,0,0,WindowXSize,WindowYSize,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered,"demo")
          hCursor1 = LoadCursor_(0, #IDC_ARROW)
          hCursor2 = LoadCursor_(0, #IDC_CROSS)
          AddKeyboardShortcut(0, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
          WindowedScreenXSize = 640
          WindowedScreenYSize = 480
          If OpenWindowedScreen(WindowID(),WindowXSize - WindowedScreenXSize,WindowYSize - WindowedScreenYSize,WindowedScreenXSize,WindowedScreenYSize,0,0,0)
            SetFrameRate(60)
            Repeat
              Select WindowEvent()
                Case #PB_Event_CloseWindow
                  Quit = #True
                Case #PB_Event_Menu
                  Select EventMenuID()
                    Case #PB_Shortcut_Escape
                      Quit = #True
                  EndSelect
                Case #PB_Event_Gadget
              EndSelect
              GetCursorPos_(CursorPosition.POINT)
              MouseX = CursorPosition\x - WindowX()
              MouseY = CursorPosition\y - WindowY() - 20
              If MouseX >= WindowXSize - WindowedScreenXSize And MouseX <= WindowXSize And MouseY >= WindowYSize - WindowedScreenYSize And MouseY <= WindowYSize
                SetCursor_(hCursor2)
              Else
                SetCursor_(hCursor1)
              EndIf
              FlipBuffers()
              ClearScreen(255,255,255)
              StartDrawing(ScreenOutput())
              Locate(10,200)
              DrawText("Mouse X/Y=("+Str(MouseX)+","+Str(MouseY)+")")
              If MouseX >= WindowXSize - WindowedScreenXSize And MouseX <= WindowXSize And MouseY >= WindowYSize - WindowedScreenYSize And MouseY <= WindowYSize
                Locate(10,220)
                DrawText("Cursor in")
              Else
                Locate(10,220)
                DrawText("Cursor out")
              EndIf
              StopDrawing()
              ExamineKeyboard()
              If KeyboardPushed(#PB_Key_Escape)
                Quit = #True
              EndIf
              Delay(10)
            Until Quit
          Else
            MessageRequester("Error", "Can't open the main windowedscreen", 0)
          EndIf
        Else
          MessageRequester("Error", "Can't open the main window", 0)
        EndIf
      Else
        MessageRequester("Error", "Can't init mouse", 0)
      EndIf
    Else
      MessageRequester("Error", "Can't init keyboard", 0)
    EndIf
  Else
    MessageRequester("Error", "Can't init  sprites", 0)
  EndIf
End 
mipooh wrote:Just re-downloaded the files, the´re still wrong...
Added the # here and changed the keys, so it works now.

The mouse cannot leave. Don´t know why, I think it is because of the windowedscreen, don´t know how to get the mouse out of that jail...
Not sure what went wrong with the file, but I downloaded it and the changes were there....

Anyhow, as shown in the code above, its not too hard... another option is to never actually grab the mouse with the windowed screen and then just track it and only respond to actions within the screen itself.

Code: Select all

   GetCursorPos_(CursorPosition.POINT) : x = CursorPosition\x - WindowX() : y = CursorPosition\y - WindowY() - 20
And then only respond when the x and y values are within your window dimensions (640x480 or whatever). The -20 in the y section of that code is to deal with the title bar on the window.... 20 works on my machine with XP, but it guaranteed to fail on any other machine. :P There are some threads for a year and a half ago where I asked about how to overcome that...

EDIT: Forum post with fweil teaching me the ways of windows: viewtopic.php?t=10728&highlight=
mipooh
New User
New User
Posts: 4
Joined: Tue Dec 21, 2004 2:45 am

Post by mipooh »

Not sure what went wrong with the file, but I downloaded it and the changes were there....
Downloaded it again this morning... the properties of the 2 .pb files shows that they are from Dec. 15th... I used the link in the first posting (and removed my cache before downloading).
Use WindowMouseX() and wait for 4.0 Fred said he already fixed it in the new Lib
...if it was shure that it´s coming soon...

I am just working at my skills understanding maps and the handling, so I try to make a simple mapeditor ((no announcement!) as all of the solutions offered in PB over the last 3 years are unusable or WIP without progress since a long time). Yesterday I had removed the windowedscreen, but it seems drawing images on an imagegadget in an openedwindow sucks same (here), at least the output looks a bit different...

I will look at the windowedscreen example and maybe try it again.
okasvi
Enthusiast
Enthusiast
Posts: 150
Joined: Wed Apr 27, 2005 9:41 pm
Location: Finland

Post by okasvi »

hmm... i guess this just shows how bored i was last night...

Image
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

lol, bored and crasy...
I like logic, hence I dislike humans but love computers.
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Post by aaron »

Wow!
Post Reply