R0J0hound's Forum Posts

  • It seems to work. It renders half as many frames per second in a consistent manner, and according to the task manager the cpu usage is cut in half more or less as well. It was made completely separate from construct though. But render loops are often similarly done, so it was meant as a possible reference if the devs should want to revisit the idea. If not, it's no worry, I'll likely use it later.

  • I do remember the jank encountered in previous attempts, but I think it might be possible to avoid that. Dt seems to vary a bit per frame. At 60fps it should be 0.0166 but I've seen it lower to around 0.0163 in my tests as an example. My idea is we can skip frames if dt is less than some target framerate, but instead of checking if dt<1/30, we let it be approximate with say dt<0.3. I coded up a complete test to check my idea and on my 60hz screen I was able to get this. Super janky with dt<1/30, but smooth with an approximate value for 1/30 like dt<0.03.

    It gives the high and low dt, the average dt of the last 128 drawn frames, and a little graph of the dt times for the drawn frames.

    And here's the relevant animation loop. The only remarkable part is the frame skip.

    let prevTime=0;
    function gameLoop(newTime)
    {
    	requestAnimationFrame(gameLoop);
    	newTime/=1000;
    	let dt = Math.min(0.05, newTime-prevTime); //20fps min to account for tabbing away
    	if (dt<0.3) // skip frame if dt isn't at least approximately 1/30.
    		return;
    	prevTime=newTime;
    	tick(dt);
    	draw();
    }
    requestAnimationFrame(gameLoop);

    It should work the same when cpu/gpu load causes frames to be skipped. The only thing that would need testing is how it would behave with other screens with higher refresh rates. Anyways, just an idea.

    Edit:

    0.3 is fairly arbitrary as a lower value than 1/30. dt<1/maxFPS-1/480 may work better, at least should work for refresh rates up to 240.

    dt<1/30-1/480

  • The only place I’ve seen anything to limit the fps is on the construct discord the user mikal made something to do that. Haven’t used it and not sure if there’s any limitations with that plug-in.

    Officially I think the devs tried to do that before but weren’t able to get anything that worked well. Maybe they will revisit it since it seems to be requested more as of late.

    I don’t think there’s anything that can be done with scripting to limit the fps. The render loop is controlled by the construct runtime and that part isn’t exposed to the scripting api as far as I can tell.

    I can think of one roundabout way to limit the fps but it’s more of a trick and doesn’t work with most of construct. The idea is the screen will only redraw if things change, so you could only move or change things every other frame or so. But as stated above that won’t work with most behaviors or other things that normally update every frame.

  • Here are some ideas:

    construct.net/en/forum/construct-3/general-discussion-7/better-text-input-170179/page-2

    One is to just use a bit of JavaScript to get keyboard input. It gives a bit more than what construct offers.

    A second idea is to use a textbox with 0 opacity. It will act just like a normal edit box but you draw manually.

  • What doesn’t work about it? Doesn’t this work?

    On f key pressed
    Control key is down
    — do something. 
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could do a timer with a variable. Something like this. It adds 1 when you click but makes a timer 0.2 sec later. After that it will add 1 quickly. There’s probably a more refined way. Basically you could just have a timer count how long the mouse button is down.

    On sprite click
    — add one to value
    — set sprite timer to time+0.2
    
    Left mouse is down
    Mouse over sprite
    Sprite timer >time
    — add 1 to value
  • You probably could do it with just the text using find(), but since you want to remove words once they are found it could get slow to replace stuff. We want to do it in a reasonably efficient way. Like dop said, it's useful to first parse the words out of the text and add them into a dictionary. You can even store the number of times each word occurs in the dictionary.

    1. parse the text to get all the words. Each word and the number of times that word is seen is added to a dictionary. This can be done over multiple frames.

    2. Random letters are typed. We only need to keep track of no more than the length of the longest word in characters.

    3. Then just use right(keys, 1), right(keys, 2), right(keys, 3), ...etc. to get a possible word and see if it's in a dictionary.

    dropbox.com/s/cq7yq79mpe8w6n8/monkey_type.capx

    Seems words longer than four letters long are seldom found, but that lines up with the probability.

  • Move to changes the position and the other sets the velocity but you can set the speed at an angle with this:

    A=angle of motion

    Vector X = -20*cos(a)

    Vector Y = -20*sin(a)

    Add it to the previous xy to be more like an impulse.

  • You can use the pin behavior oh the objects you want to move with the map, and pin them to the map sprite.

    Alternate idea is to set the scroll instead similar to the other suggestions.

    I like to try to simplify stuff so calminthenight’s solution probably could be simplified a bit further to something like this. I haven’t had a chance to test it.

    Var prevX
    Var prevY
    On touch
    — set prevX to touch.x
    — set prevY to touch.y
    Is touching
    — scroll to scrollx+prevX-touch.x, scrolly+prevY-touch.y
    — set prevX to touch.x
    — set prevY to touch.y
  • Sure. It has to do with when new objects can be picked. When you create new instances they can’t be picked in a general way till the next top level event (top level means an event to the far left). Basically the new instances aren’t added to the object list till the next top level event. Pick by uid is the one condition that can pick new objects regardless.

    More info here.

    construct.net/en/forum/construct-classic/help-support-using-construct-38/picking-problem-37830

    Anyways the wait 0 is a bit of a hack to work around this. It delays till the end of the event sheet before running. Which is often fine in a lot of cases.

  • Well if you didn’t change the camera scroll from the top left, and the origin of the sprite map’s image is top left then it should work from my tests. Did you check the origin?

  • Since the map sprite is the same size as the layout you can do this. Make the map sprite's origin be at the top left, give the map sprite the drag and drop behavior, and finally add this event to limit how far you can drag the map.

    every tick: map: set position to clamp(self.X, OriginalWindowWidth-LayoutWidth, 0), clamp(self.Y, OriginalWindowHeight-LayoutHeight, 0)

  • Ah, cool, didn't notice that. Things really are all over the place. On the plus side I now know how to do one more thing without construct.

  • Looks like you can't load a file as binary with the AJAX plugin, only text. You have to use javascript to do it yourself: request the file as a blob, convert blob to dataUrl, and finally extract the base64 from that. Then you can load that into the binary plugin.

    At least you can save a binary file with the browser invoke download action with BinaryData.GetURL.

    Converting to a from a hex value is fairly straightforward so I added some functions. Doing similar things for 8bit binary values should be fairly straightforward too.

    dropbox.com/s/sfy2n75oo9s5dq7/binary_save_load.c3p