Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Windows / Tier 2 - GetPointerX() in main loop, nothing happens

Author
Message
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Nov 2015 06:03
I have converted a Tier 1 project to Tier 2, using 2.0.14b.
My executable seemed to be hanging, but after adding a Message() pop-up I could see that it was indeed running. However, trying to display the values from GetPointerX() and GetPointerY() is not working. I get the WIndows "busy" mouse icon and the values do not change.
This works great in Tier 1, so what is different in C++?

I start with the template project for Visual Studio 2013. The following is the code inside the app::Loop (void):


I added the Sleep() function to see if a delay might help. It did not.
Yes, the Text objects have already been defined along with color and position.
This code works in Tier 1 (without the namespace of course). This should display the mouse pointer X and Y coordinates, but the program is unresponsive and only 0.00000 is displayed for each of the values. The executable is stuck in this loop. Pressing the mouse button will not cause an exit as it should. Could there be a problem communicating with the mouse driver??
This is a basic part of the AppGameKit so I do not see why this wouldn't work in Tier 2.
home.wavecable.com/~mindsclay
Uncle Martin
17
Years of Service
User Offline
Joined: 9th Jul 2006
Location: Tampa, Florida, USA
Posted: 5th Nov 2015 06:31 Edited at: 5th Nov 2015 06:38
In Tier 2, I'm pretty sure you don't want to create a continuous "Sync" loop in your C code, because this doesn't allow the "Core" of the AppGameKit Windows app to run at all. The Core calls your AGK::Begin function, then loops & calls your AGK::Loop function & then finally calls your AGK::End function before it ends itself. In Tier 1, you must construct the main loop yourself, but in Tier 2, they want their Core to handle it. The following structure works for me in Tier 2. Good luck.

Code every line like it might be your last...
Someday it will be.
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Nov 2015 06:36 Edited at: 5th Nov 2015 06:36
Yes. There is definitely something going on with the mouse.
I added a loopCount variable to display, and it is showing the incrementation. Only the mouse values do not change and the program is unresponsive.

Has anyone else had mouse issues in Windows?
home.wavecable.com/~mindsclay
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Nov 2015 15:08
Wow. That looks like major recontruction of my code.
So, I cannot use a while loop to wait for a mouse action.
The conversion isn't going as quickly as I thought it would.
I have this type of looping utilized in other places. Crap.
home.wavecable.com/~mindsclay
Uncle Martin
17
Years of Service
User Offline
Joined: 9th Jul 2006
Location: Tampa, Florida, USA
Posted: 6th Nov 2015 05:14
If you look at the Core.cpp supplied with the kit you can see how TGC handles a lot of the standard Windows things like the, so called, Message Pump. So if our app loops without returning to the Core, I can see how it might not get keyboard & mouse inputs, because they are handled by the standard Windows messaging scheme serviced inside the Core.cpp routine. You might be able to get around this somehow, but I'm not sure how.
Code every line like it might be your last...
Someday it will be.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Nov 2015 22:28
Uncle Martin is basically right.

In Tier 2, the Sync() command only gets the user interactions once per execution of the Loop method.

Display stuff will update any time Sync() is called, but no touches and keyboard entry and such.

It definitely changes the way you structure the code.
Cheers,
Ancient Lady
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 9th Nov 2015 02:54
I am now calling GetPointerPressed() in the main Loop method. I get random GetPointerPressed()==1. I am not getting a 1 every time I press the button. Same with GetPointerReleased().

I then added ScreenFPS() printed to screen, and now the mouse button works everytime.

I wish there were a list(s) of Tier 2 idiosyncrasies.

home.wavecable.com/~mindsclay
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Nov 2015 06:11
I think the Sync() issue is the only one.

Something you get in Tier 2 that you don't in Tier 1 is the 'OrientationChanged' command. It actually lets you force the orientation of the game at initialization.

Also, in C++, you get lots of good stuff. Real Object Oriented programming capability, std::string and other great stuff.
Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-03-28 16:40:53
Your offset time is: 2024-03-28 16:40:53