Fengist's Forum Posts

  • 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.

  • 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

  • And I run this:

    + System: On start of layout
    -> AJAX: Send "" to URL "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" (method "HEAD", tag "example")
    
    + AJAX: On "example" completed
    -> Text: Set text to "passed"
    
    + AJAX: On "example" error
    -> Text: Set text to "failed"
    

    And it comes back passed which looks exactly like what you have.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I personally couldn't get example.com to work. But to do a "HEAD" call which only returns the header of the site you're contacting and not all of the content (which is smaller memory wise and a fraction of a second faster), change the first line in my example to this:

    -> AJAX: Send "" to URL "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" (method "HEAD", tag "check")
    
  • Also, keep in mind that anything you have set to global is created for the duration of the game once it is created unless you specifically destroy it.

    For example. Drop a button and a text on a layout. Create another layout and drag the same button and text onto it. Have the button on layout 1 go to layout 2 and have the button on layout 2 go to layout 1.

    If you run it in the debugger, and expand the trace for the text object, you'll see that when you click the button to switch layouts, it creates an 'instance' of the text for each layout and destroys it when you switch layouts so that only one instance of the text exists at any one time even though you have it on 2 layouts.

    If you set that text to global though, it still creates a new instance when you switch layouts but doesn't destroy the one from the previous layout so you end up with two instances, just different UID's.

  • He's saying if you don't want to host your own file/site, use example.com as the url. And don't use the ajax post or get, use the head call, which I'd agree with.

    The problem I have with any site or domain other than your own, you can't guarantee that they'll always be there.

    As far as the tcp, I assume he means websockets. If c3 or c2 has some way of sending tcp/udp packets without writing JS, I'd love to know about it.

  • For that, your best bet is to likely start another topic and post a c3p file. I can think of a hundred things that would keep text from displaying.

  • Hi Fengist,

    I'm using tags, but the audio effect still plays. I'm wondering if I need to include an event connected to clicking the Left mouse button as that's what triggers the sound but I'm not sure how to do this.

    In some way, whether it's through the variable Mario suggested or through a mouse click, you'll need some event that turns it off. And once you do, make sure there's nothing else that will trigger it starting again. The Audio.Stop All should stop all sounds from playing regardless of the tag.

    Here's an example of how I'm using a mouse click on a sprite event to start music playing. Stopping it is done the same way.

    + Mouse: On Left button Clicked on NewGameButton
    + System: [X] Is ChoiceMade
    -> Functions: Call PlayEffect (Name: "UI_Quirky30")
    

    You'll notice that calls a function. One of the things I do to help keep things organized is to create an entire event sheet just to handle audio events and include it in any other event sheet that needs to play audio. That way I just call a function to play music or sound and pass the file name. If I need to adjust things or change the way all audio is played, I can change the function without having to find every single event where I play audio.

  • You are playing the sound every tick - looks like if Mario is in the air, you play the sound. Just play on the jump. (Or you can probably add 'Trigger once while true' to your condition.)

    Didn't notice that. That would definitely add some strange effects to the sound.

  • One of the tricks I use is that all music is played with the tag "background." All effects are played with the tag "effects." Whenever I need to stop one, I can audio.stop("effects").

    Are you using tags?