Skip to main content

News

Topic: neoSphere 5.9.2 (Read 524925 times) previous topic - next topic

0 Members and 28 Guests are viewing this topic.
Re: miniSphere 4.6.0
Reply #1770
As a suggestion, would it be possible to give the option of not repeatedly adding the currently held key/button to the queue, relying on some kind of event system for getting key/button presses and releases instead?
  • Last Edit: July 13, 2017, 04:28:15 am by Eggbert

Re: miniSphere 4.6.0
Reply #1771
For example, as it is now, doing something like
Code: [Select]

const term = require('term');
const kb = Keyboard.Default;
var current_key;
function game() {
   threads.create({
      update: function() {
         current_key = kb.getKey();
         return true;
      }
   );
}


Everything seems to work fine, but when I open a terminal, because getKey() clears the queue, I'm unable to enter. The terminal is an example that would/might benefit from a proper built-in input event system.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.6.0
Reply #1772
Ideally the console should be stealing input focus from the rest of the game, but I don't have any way of implementing that right now.  I have a GitHub issue open to implement something along those lines, but I haven't done anything for it yet:
https://github.com/fatcerberus/minisphere/issues/161

With the low-level way the Core API is designed, technically the only thing the engine should provide is kb.isPressed()... but I decided to have getKey() as well because that allows games to take input for typing and at the system's usual repeat rate.  Otherwise the game would have to implement a key queue itself and typing would feel totally different from other applications.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Rhuan
  • [*][*][*][*]
Re: miniSphere 4.6.0
Reply #1773
Have you had a chance to look into the frame rate limit bug (shown by turning on the speed limit in my graphics test script)?

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.6.0
Reply #1774
Not yet, I've been trying to get a lot of the refactoring I wanted to do out of the way before I get too close to the 4.7 release.  Once I get close to releasing I don't like to make major architectural changes, so I'm getting it done now.

I'll definitely look at it soon, it shouldn't be losing half the frames when the unlimited frame rate is just over 60fps.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: miniSphere 4.6.0
Reply #1775

Ideally the console should be stealing input focus from the rest of the game, but I don't have any way of implementing that right now.

That's what I thought it was supposed to do and it's why I was confused at first. As far as how to implement it, I think I mentioned earlier in the thread that it might be a better idea to have it built-in. Or do what some other games do and have it completely pause execution aside from the terminal. That's what I was going for when I made my own terminal (which I've since lost) and I never had any issues with it, unless you entered in bad JavaScript code, since it was designed to directly handle code.


Otherwise the game would have to implement a key queue itself and typing would feel totally different from other applications.

I thought most APIs/frameworks use events like SDL_PollEvent/SDL_KEYDOWN/SDL_KEYUP, JavaScript DOM events, etc. That was what I had in mind here.

Edit: also Dispatch.onRender draws over the terminal as well.
  • Last Edit: July 13, 2017, 07:04:59 pm by Eggbert

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.6.0
Reply #1776

Edit: also Dispatch.onRender draws over the terminal as well.


Which miniSphere version?  The console has infinite priority so it should always render last.  I know I did fix a bug related to incorrect Dispatch order in 4.6, maybe that's what you're encountering:
https://github.com/fatcerberus/minisphere/commit/f88b4aa96f975d4c11030abf2e02071f25adf7d0
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.6.0
Reply #1777

Or do what some other games do and have it completely pause execution aside from the terminal. That's what I was going for when I made my own terminal (which I've since lost) and I never had any issues with it, unless you entered in bad JavaScript code, since it was designed to directly handle code.


This is difficult to do in a general-purpose console module: To pause execution, the console has to run its own loop (not async friendly); and the modular nature of the Sphere v2 design means evaluating arbitrary JS code is of limited utility, as very little is actually reachable globally.

Quote

I thought most APIs/frameworks use events like SDL_PollEvent/SDL_KEYDOWN/SDL_KEYUP, JavaScript DOM events, etc. That was what I had in mind here.


One of Sphere's biggest strengths, and why I fell in love with it in the first place, is that it allows you to code your game as though you were writing a DOS program.  Those were the times when you could do all the polling, looping, etc. you want, in realtime, without having to worry about handling events from the operating system.  You don't even need a central event pump because as long as you flip regularly, the engine takes care of all the OS-level event handling for you and your game stays responsive.  It's of course possible to add an event system to the API, and I probably will need to do so sooner or later to pave the way for Oozaru, but I wouldn't want it to be the primary method of handling input.

You don't realize just how easy Sphere makes it for you--and this is something I didn't fully appreciate until I started working on miniSphere and had to actually implement it--until you notice that you can do this:
Code: (javascript) [Select]

while (true) {
    while (true) {
        while (true) {
            FlipScreen();
        }
    }
}


And when you close the window, Sphere will completely--and because JS is garbage collected, cleanly!--bail out of that for you.  If an event system were enforced, you'd then have two options: 1) Limit yourself to a single, central event pump that watches for Quit events and bails out when it gets one (this is similar to what the built-in Dispatch loop does), or 2) Watch for Quit events in ALL of your loops and do the unwinding yourself.  And if you forget to add a quit check in one of them, well, say hello to Task Manager. :P  Both of these approaches sharpen the learning curve significantly.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

Re: miniSphere 4.6.0
Reply #1778

Which miniSphere version?  The console has infinite priority so it should always render last.  I know I did fix a bug related to incorrect Dispatch order in 4.6, maybe that's what you're encountering:
https://github.com/fatcerberus/minisphere/commit/f88b4aa96f975d4c11030abf2e02071f25adf7d0


Oops, I updated the AUR package but I forgot to install the update on Windows.
How does DOM JavaScript get away with it? And I guess I should have made this more clear, I wasn't referring to low-level event handling, I was referring more to things like input. Or at least that's why I brought this up. Detecting when a person collides with something or reaches a certain point is easy enough (that's part of the reason I created the personlib wrapper). What do you think would be a good way to easily allow for differentiating between a keydown and keyup?
  • Last Edit: July 14, 2017, 05:51:36 pm by Eggbert

  • Rhuan
  • [*][*][*][*]
Re: miniSphere 4.6.0
Reply #1779
Low level engine question:
- if you instruct miniSphere to draw a shape to the screen of which a large portion will be off the edge of the screen and just part of it on screen what happens?

- does it waste effort processing all the parts that aren't on screen? (I assume yes and hence to optimise one should try and only draw what's actually on screen in one's javascript) but don't want to waste effort arranging that if the graphics system automatically clips the excess.

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.6.0
Reply #1780

Low level engine question:
- if you instruct miniSphere to draw a shape to the screen of which a large portion will be off the edge of the screen and just part of it on screen what happens?

- does it waste effort processing all the parts that aren't on screen? (I assume yes and hence to optimise one should try and only draw what's actually on screen in one's javascript) but don't want to waste effort arranging that if the graphics system automatically clips the excess.


That's entirely up to the graphics hardware.  miniSphere just sends the vertices to the GPU (they're actually uploaded when you do new Shape() but you get the idea); because of the way projection matrices and such work there's no way for the engine to know which parts of a shape will be visible or not.  At the very least, it's been my experience that if you draw a huge number of vertices per frame, even if the vertices are already uploaded, you will experience slowdown regardless of how much of it actually gets displayed.  Vertex processing is apparently more expensive than rasterization, for whatever reason.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.6.0
Reply #1781
I'm currently working on implementing Sphere1.x compatible spriteset behavior.  A few v1 games rely on being able to modify spritesets on-the-fly, and the internal spriteset code needs to be refactored anyway (it's some of the oldest code in the engine), so this is a good opportunity to get it out of the way.
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Rhuan
  • [*][*][*][*]
Re: miniSphere 4.6.0
Reply #1782
Have you had a chance to look into the framerate issue where a limited framerate results in a drop from 50 FPS to 30 or the like?

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: miniSphere 4.6.0
Reply #1783

Have you had a chance to look into the framerate issue where a limited framerate results in a drop from 50 FPS to 30 or the like?


I know why it happens, I'm just not sure how to fix it yet.
See: https://github.com/fatcerberus/minisphere/issues/188
neoSphere 5.9.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Rhuan
  • [*][*][*][*]
Re: miniSphere 4.6.0
Reply #1784


Have you had a chance to look into the framerate issue where a limited framerate results in a drop from 50 FPS to 30 or the like?


I know why it happens, I'm just not sure how to fix it yet.
See: https://github.com/fatcerberus/minisphere/issues/188
Average the time over 10 frames or something?