Comments (5)
It would be good to pull all the movement code out into a library, with hooks back into the application to allow the movement to be overruled. That way we can have a consistent user interface that works with mouse, keyboard and gamepad/joystick, and can be customised.
It would mean that the demos would lose a lot of excess wordage, leaving just the interesting stuff.
It would work well with first-person, but third-person requires playing with the camera position to avoid trying to look through walls. There are simple fixes, but even they add complexity and require knowledge of the surroundings.
from pi3d.
Well, there seem to be two styles of usage of interfaces, both of which appear in the demos.
There's the case where you get specific events as they happen - for example, you get a "K pressed" command. This could be handled with a callback.
But there's an alternate way of doing things where, in your update loop, you check to see e.g. what key is being pressed. This is more what you want for video games - you want to keep going forward as long as you press the "forward arrow" for example.
Setting an autorepeat isn't the same - you really don't want multiple key events, because they won't match up with your poll cycle.
from pi3d.
See my comment to #47
This can be easily arranged using a key handler function in InputEvents.
The InputEvents object has a dict giving the current state of every key and every button on every conceivable device, so that matches your second requirement. However every change of state also calls a callback, and that callback can filter out everything but the key-down event and pass it to an event buffer for the main loop to read. (It is part of the main loop too, not a separate thread, so it could just action it.)
from pi3d.
Oh, right on!
We need to be a little careful about CPU consumption here (rare for me to
say in a project!) as the keyboard scanning code is called every frame, the
RP is not particularly speedy, Python function calls are fairly expensive,
and we've noticed fairly large changes in frame rate for even small
optimizations and pessimizations.
But - correctness first, speed second!
On Tue, Jan 15, 2013 at 1:46 PM, rurwin [email protected] wrote:
See my comment to #47 #47
This can be easily arranged using a key handler function in InputEvents.
The InputEvents object has a dict giving the current state of every key
and every button on every conceivable device, so that matches your first
requirement. However every change of state also calls a callback, and that
callback can filter out everything but the key-down event and pass it to an
event buffer for the main loop to read. (It is part of the main loop too,
not a separate thread, so it could just action it.)—
Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-12282482.
/t
http://radio.swirly.com - art music radio 24/7 366/1000
from pi3d.
It's fairly efficient at the moment. The state is fetched from a dict keyed with a small integer. There's a call there, but we could make it a single call per frame at the expense of adding complexity to the API. The event occurs at the key repeat rate.
There is a select call every frame, which could take significant time, but we could throttle that back if it proved to be a limitation without losing events.
from pi3d.
Related Issues (20)
- problems running on fedora28 HOT 8
- position a gui element in corner of windows - track resizes? HOT 2
- "X11 needs to be running" on Ubuntu Desktop 19.10 (intel cpu/gpu) HOT 4
- Name only shows for 1 second, and disappears. HOT 2
- Memory not freed when free_after_load is True HOT 5
- How to add touchscreen support HOT 2
- 'assert r' error due to old API usage and advice on latest API usage HOT 16
- pi3d on Ubuntu 20.04 HOT 11
- DISPLAY_CONFIG_NO_RESIZE makes the window resizable
- pi3d.Slice() unexpected angle HOT 4
- Blue Screen (Not BSOD) on relaunch of pi3d HOT 9
- gltf support? HOT 2
- problem running examples in CLI mode (no context) HOT 2
- Run PictureFrame.py without indexing? HOT 1
- Win 10 not every example is working HOT 6
- AttributeError: 'NoneType' object has no attribute 'glActiveTexture' HOT 6
- AttributeError: 'DisplayOpenGL' object has no attribute 'context' HOT 1
- Not work on Win 10 Py 3.11 HOT 2
- pi3d 2.49 not working with Pillow 10.0.0
- Windows Exception in DisplayOpenGL.py HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pi3d.