Fengist's Forum Posts

  • I'm British and this has always bothered me too, so much that i had taken to reversing the xy in the events so the format appeared correctly in the debugger.

    So, you moved your steering wheel to the other side and still drive on the wrong side of the road. *boggles* I think I'd be confused either way.

  • You can still use while (stop loop still will work the same way), but you'll need to track your progress manually rather than using loopindex is all.

    Of course. The problem is, while the loops is running there doesn't appear to be any way to update a progress bar, a text or anything else. One of my while loops could likely take up to 5 seconds, during which time, the game is completely frozen. Since this will be during startup, those kinds of delays are considered acceptable. Not updating a text or a progress to prove the game hasn't crashed for 5 seconds? The vast collection of impatient gamers on this planet will have a collective embolism.

    I exaggerate but you get the point.

  • Progress=/=TotalIterations

    For "loop" from Progress to TotalIterations

    -> Do x

    -> Set Progress to loopindex.

    -> Stop loop based on desired trigger

    The following tick the loop will run again, starting at wherever you left off when you stopped the loop

    And yea, I know that there should be exactly 200x200 iterations in the loops above and I could rewrite it with that in mind. The question I have is, should I really have to restructure the way that perfectly sound logic works and should I have to avoid using the while condition in the future because it freezes the app till it's done?

  • This could possibly be an interesting feature suggestion.

    A stop loop action except that instead of terminating the loop, it will complete anything that remains in the following tick.

    In Delphi there's a while and a repeat (and of course for loops) The difference between those is, in a while loop, if the condition is met anywhere in the middle, the loop breaks. In the repeat loop, it only checks at the end of the loop to see if the condition is met and then breaks.

    But, that's just me being wishful. Considering the headache I've been through with that one above, it's obvious I still haven't figured out the logic of C3 loops.

  • Like AlanR explained, loops in Construct are actually performed in one tick. If there is a Wait inside the loop, it doesn't pause loop execution, it creates a delayed thread. So a loop like this becomes infinite and will freeze the browser:

    > While
    stop=0
    	Wait 0
    	Set stop=1
    

    And that's pretty much what I was doing. So the whole point of me doing it this way was the result of another thread I started:

    construct.net/en/forum/construct-3/how-do-i-8/god-need-repeat-until-146195/page-2

    In Delphi, there's a repeat:until loop which is a lot like a while. It keeps doing something until a condition is met. And, as in my case, if you're doing lengthy loops, there's an application.update you can plug in anywhere and the interface gets updated. This while, it's going to take some effort to convert.

    I appreciate you guys giving me ideas and suggestions and it's apparent that I'm going to have to figure another way to do all of this without the while. All of the languages I've learned before Construct (except maybe Basic) have been function or procedure based and as little as possible goes on the main thread. And since I had this inside a function, running the timer or dt isn't going to be an easy fix.

    Here's what I'm doing:

    * On function 'CheckFresh'
     | Local number T‎ = 0
     | Local number B‎ = 0
     | Local number R‎ = 0
     | Local number L‎ = 0
     | Local number dir‎ = 0
    ----+ System: 0 is Number
    -----> System: Set T to ArrayOffset-1
    -----> System: Set B to ArrayHeight-ArrayOffset
    -----> System: Set L to ArrayOffset-1
    -----> System: Set R to ArrayWidth-ArrayOffset
    -----> System: Set dir to 0
    -----> Functions: Set return value 0
    
    ----+ System: While
    --------+ System: T ≤ B
    --------+ System: L ≤ R
    ------------+ System: dir = 3
    ----------------+ System: For "I" from B to T
    --------------------+ TerrainArray: Value at (LoopIndex("I"), L, 0) = WaterTileFresh
    ------------------------+ System: Functions.CheckAllWater2(LoopIndex("I"),L,0) = 1
    -------------------------> Functions: Set return value 1
    -------------------------> System: Set FreshWaterX to LoopIndex("I")
    -------------------------> System: Set FreshWaterY to L
    
    ----------------+ System: L is Number
    -----------------> System: Add 1 to L
    -----------------> System: Set dir to 0
    
    ------------+ System: Else
    -------------> (no actions)
    
    ------------+ System: dir = 2
    ----------------+ System: For "I" from R to L
    --------------------+ TerrainArray: Value at (B, LoopIndex("I"), 0) = WaterTileFresh
    ------------------------+ System: Functions.CheckAllWater2(B,LoopIndex("I"),0) = 1
    -------------------------> Functions: Set return value 1
    -------------------------> System: Set FreshWaterX to B
    -------------------------> System: Set FreshWaterY to LoopIndex("I")
    
    ----------------+ System: B is Number
    -----------------> System: Subtract 1 from B
    -----------------> System: Set dir to 3
    
    ------------+ System: Else
    -------------> (no actions)
    
    ------------+ System: dir = 1
    ----------------+ System: For "I" from T to B
    --------------------+ TerrainArray: Value at (LoopIndex("I"), R, 0) = WaterTileFresh
    ------------------------+ System: Functions.CheckAllWater2(LoopIndex("I"),R,0) = 1
    -------------------------> Functions: Set return value 1
    -------------------------> System: Set FreshWaterX to LoopIndex("I")
    -------------------------> System: Set FreshWaterY to R
    
    ----------------+ System: R is Number
    -----------------> System: Subtract 1 from R
    -----------------> System: Set dir to 2
    
    ------------+ System: Else
    -------------> (no actions)
    
    ------------+ System: dir = 0
    ----------------+ System: For "I" from L to R
    --------------------+ TerrainArray: Value at (T, LoopIndex("I"), 0) = WaterTileFresh
    ------------------------+ System: Functions.CheckAllWater2(T,LoopIndex("I"),0) = 1
    -------------------------> Functions: Set return value 1
    -------------------------> System: Set FreshWaterX to T
    -------------------------> System: Set FreshWaterY to LoopIndex("I")
    
    ----------------+ System: T is Number
    -----------------> System: Add 1 to T
    -----------------> System: Set dir to 1
    
    --------+ System: Else
    ---------> System: Stop loop
    

    This is still with my current procedural terrain kick.

    Basically, this loop starts at the top left corner of the array. It then reads across, down, left and up in a spiral fashion until it reaches the center of the array. It's purpose is to find a specific a number in the array (representing fresh water) then check all 8 surrounding elements to make sure they're the same. By spiraling inward, the last positive check it does will be the closest fresh water to the center. If it fails completely in finding any, it re initializes the array, and starts all over with a different one.

  • God, it's taken me 2 days to get this while to work. The thought of rewriting yet again it makes me ill. Plus, I'm going to have another much larger while loop that would be a bigger nightmare to convert into something else. Instead of completely rewriting this code into a different type of loop, is there no way to update a progress? It just seems bizarre to me that a while loop should completely freeze the app till it's done with no way to update a text or a progress bar.

  • Hell yeah, forum drama!

    But I´d agree that the output looks confusing, lucky I never worked with 3D arrays before. I like mekonbekons idea.

    I like it better than what's shown now. What I'd prefer is to show the x,y of layer 0 in row brackets and below that the x,y of layer 1 in row brackets. But I also understand that a 200x200x3 array, which is what I'm working with, is a lot of cells to put in one box.

  • So, using the trick from a for loop, I'd put a wait 0.1 in my while statement in order to update a progress bar. However, if you put a wait inside a while, the net results seems to be it locks up the entire app, which ends in an 'oh-snap' in the preview AND the editor.

    Now surely, there must be some way of updating a progress in the midst of a while without locking everything up? From what I'm seeing, if you execute a while, everything freezes till it's done.

  • No, don't use round(), it will skew your results.

    Pretend random returns single decimal point values. So 0.0, 0.1, 0.2, etc.

    Using round() will return 0.0, 0.1, 0.2, 0.3, 0.4 as 0, but 0.5-1.4 will return 1. That pattern repeats until the other end, where the last number is also only half as likely to show up. The most accurate way to get an integer is to use int(random) (or floor). Then all numbers are equally likely.

    If his random, as he says it from 1-11 then it should not return anything less than 1. Were his random 0-11 then yes, it would return a 0-1.

    But I see what you're saying. I just never worried about that difference that much. I used ceil or floor.

  • System: Set Layout Angle

    Does that actually change it from portrait to landscape or just spin the layout with the rotation staying the way it is?

    Then again, I may have misread what he's trying to do.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't think you can force the rotation to change. That's something the actual device decides depending on which way it's turned. In the project's properties you can lock the rotation into portrait or landscape or, you can set it to 'any' which allows it to rotate when the device is rotated. You can use the browser plugin to see whether it's in portrait or landscape and you can lock and unlock the rotation.

  • construct.net/en/forum/construct-2/how-do-i-18/tips-posting-quothow-iquot-40390

    Without an example, I can think of a hundred reasons why sound wouldn't play.

  • To answer your questions.

    Yes, c2 and c3 could be used to make a city builder if you mean something like sim-city. While you could likely do it with just a tileset, to me, keeping track of what tile is where would be a chore and I'd likely adopt a strategy of using an array and copy that over to the tileset. And even then, it would be a lot of work keeping track of things. If you're new enough to construct that you're not sure where to begin on this project, I strongly suggest something a bit easier to get yourself familiar with the intricacies of programming in c2/c3 and come back to this when you feel more confident.

    As for selling with the free version: yes and no.

    construct.net/en/tutorials/how-construct-2-licenses-work-64

    '- Not allowed to be used for commercial purposes (however, it can be used in education and other non-profit organisations).'

    Either way, I seriously doubt if you could make something like this with the limitations of the free version.

  • I think you'll want round(random(1,11))

    int(random(1,11)) will just chop off everything after the decimal giving 1-10.

    round returns the closest integer so that 10.6 = 11 and 10.4 = 10 so you get 1-11

    ceil returns the next highest integer so that 10.1 = 11 (rounds up) and you get 2-11

    floor returns the next lowest integer so that 10.9 = 10 (rounds down) and you get 1-10

  • I don't think you're doing anything wrong. Ajax needs a special 'header' on the other end to allow it to interact with the website. The google url has that header. I don't think example.com does.

    Just do the head post to the google url or one of your own. It's fast and there are no ajax results actually returned so it doesn't consume any memory.

    Here, this definitely works on my system:

    https://www.twistedvoid.com/c3examples/headcheck.c3p