![]() ![]() Called when window is closed return true Optional! bool OnUserDestroy() override Called once at the start, so create things here return true īool OnUserUpdate( float fElapsedTime) override SAppName = "Example " // You can name your application here ![]() If for any reason it could not start, for example inadequate resources, it will return olc::FAIL.Ĭlass Example : public olc::PixelGameEngine // Note olc::PixelGameEngine is inherited from If the PixelGameEngine ran succesfully it will return olc::OK. This function will block until it returns. This will create the window, and create a context for internal rendering, then start the main game engine thread. If it can't do this it will return olc::FAIL, otherwise olc::OK. This function will internally prepare the PixelGameEngine for starting. Therefore you can calculate the size of your window in "screen pixels" as being ( screen_w * pixel_w) x ( screen_h * pixel_h). Each olc::Pixel is defined a being pixel_w x pixel_h "screen pixels", i.e those native to your monitor. olc::rcode Construct(uint32_t screen_w, uint32_t screen_h, uint32_t pixel_w, uint32_t pixel_h)Ĭonstruct a PixelGameEngine window which is screen_w x screen_h olc::Pixels in size. Include this new cpp file in your build as usual, and just reference "olcPixelGameEngine.h" as appropriate. A common and simple solution is to create a standalone "olcPixelGameEngine.cpp" file which has the above code contained within and nothing else. In my example I instead save X and Y to the third dimension of aoi_corners.If your solution contains multiple ".cpp" files, with several inclusions of "olcPixelGameEngine.h" you need to understand where to define OLC_PGE_APPLICATION. In this case click 1 X and Y will be in positions 1 and 2, but click 2 X and Y will be in positions 2 and 3, so the Y from the first click will be overwritten by the X from the second click, etc. Another thing I noticed, which wasn't in your original question, is that on each click you're iterating the click variable by 1, but you're saving the X and Y position to click, and click + 1. If you instead use GetMouse, but also wait until the button has been released before moving on, I think you'll get the behavior you want. But for example holding a key as you click the mouse will break out of the loop. The issue with GetClicks is that the keyboard is not being checked while waiting for the click, as you noted. My question is then is how do I get around this? Have I missed something obvious/written my code badly? Using getmouse on the other hand, allows KbCheck to work but takes the x,y coordinates from the point of the button getting pressed down, so it returns loads of values I don't need, even if I press and release the button as fast as I can. However it stops KbCheck from working (my searches tell me this is because it operates like KbCheck and pauses the program while it waits for more clicks?). The problem is essentially that, if I use getclicks to get the x,y coordinates I can get good x,y coordinates for the dot in my aoi_corners matrix as it takes the x,y at the point of button release. While ~KbCheck %check keyboard has not been pressed ![]() ![]() Screen('Preference', 'SkipSyncTests', 2) This is the code I have for this program: clear all Finally, the program should exit when a keyboard press is detected. Store the x,y location of the this click and all subsequent clicks in a single array.ģ. My program needs to do the following things:Ģ. I'm trying to get the x,y coordinates of a click using Psychtoolbox on Matlab. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |