DogeDev's Forum Posts

  • Hello!

    I'm trying to send Data to an Google Spreadsheet that will count the amount of players that opened the game. It will start at 0 and will go up by every player opening the game for the first time, generating their unique ID.

    The problem is, after already reading a lot of tutorials from the community I already made an APPS Script, but isn't working in the way I want.

    Spreadsheet: docs.google.com/spreadsheets/d/1-NiiI_84IhNKsT9MF-RNT1b5R5AmzoNidzJ4T2PdxwM/edit

    The only thing I want is to add +1 to the PlayerCount value (Column B2) when the game is opened for the first time and only in that place, so it can go up to 2,3,5...117,118...

    I would appreciate any help given to me, thanks for reading!

  • If you put all those values in an array and just get one at random that would work.

    Array.at(int(random(Array.width)))

    For a more deluxe and compact version you could store the values and weights of each value. The sum of all the weights should be 1.

    Then to randomly pick a value based on the weights you’d:

    1. Generate a random value 0-1

    2. Loop over the array

    3. If the current weight<value? Then subtract the weight from the value and look at the next array position.

    4. If weight>=value then you’re done and the array position you’re on is the value to use.

    Anyways that’s the gist of it at least.

    I've understanded it a bit, but I think would be better if you make an .capx for me to see how to do it, the .txt is here if you need ghostbin.com/aEb1P and all of the weighted values are stored in the ♣ symbol.

    Like you said, the way that I want it to be is by having the chance to get choosed by the item weight value.

    By the way, thanks a lot for helping me sir, I'm really glad!

  • Easy fix is to move to Construct 3 lol. I guess you could add values to rows of an array and pick a random row.

    Sadly this is a construct 2 How do I forum. By the way, explain me more about the array solution, how could I suit it in a way that would work with all the values of the .txt?

  • Hello!

    I have a question about how can I do a good Probability Table using Weights, like the default one a lot of games have, as example: Minecraft Loot Tables.

    I have this .txt imgur.com/a/eLmdTDp with some weighted values, 10 being the most common and 1 the rarest. The print doesn't show the total, but it's 264 possibility values.

    So, I want to know a good way to choose one of these values by probability, if you know any type of solution or you can help, i would really appreciate!

  • -> System: Set oddNumber to round(random(1,100))

    -> System: Set oddNumber to oddNumber%2=0 ? oddNumber+1 : oddNumber

    If oddNumber is even it adds 1 to the even number or it gives back the odd number

    OH YES I FORGOT ABOUT REPEATING THE SENTENCE, DAMN! That should work, gotta test it, while testing the ROJO's one too, thank you all sirs, for helping me!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is it all the odd numbers from 1 to 100?

    int(random(50))*2+1

    Or is it a different set of odd numbers?

    Any Odd number from 1 to 100, because I have an .txt file that has 100 types of |, the Even | has X value, while the Odd | has Y value, I could already make an function for the Even one, I just needed one for the Odds.

  • Hello!

    My problem here is: I have an table with about 100 numbers, going from 1 to 100, and from these numbers, I only want to get the Odd ones, like 1,3,5,7,9,11,13,15...

    The problem is, it will randomly select an number from that sequence with the code: round(random(1,100)), and I want it to convert any Even numbers to Odd numbers, or to only generate Odd numbers from 1,100.

    And no, I don't wanna switch to Even, I must stay in Odd to have good code performance and to avoid bugs.

    Any help for the solution of this problem will be appreciated!

  • The expressions

    Sprite.bboxLeft

    Sprite.bboxRight

    Sprite.bboxtop

    Sprite.bboxbottom

    It's now working well! Thanks for all the help.

  • Just replace the random() stuff to whatever you like. Random can be defined as random(min, max) of that helps. All a box is a low and high value vertically and horizontally.

    But, how i can get an min and max value of a sprite size/position?

  • Well it should be as simple as:

    Every tick

    — sprite: rotate 100*dt degrees towards (320,240)

    Where 100*dt means 100 degrees per second.

    That should do the trick, really thanks!

  • One way is to just spawn the objects in random positions and if the object collides with the player move it to a random position.

    Here’s one possible example. Create it on the player, and repeatedly move it to a random position till it’s not touching the player.

    On function “add spear”

    — Create spear at (playerbox.x, playerbox.y)

    — while

    — spear: overlaps playerbox

    — — spear: set position to (random(windowWidth), random(windowheight))

    Thanks for the answer! It's actually working, but i'm using an object with ScrollTo, so when using (random(windowWidth), random(windowheight)) isn't spawning in the place that i want. Instead it's possible to spawn through an specific area without it being an object or the window?

    Or, if i need to use some sprite with a larger area that the spears will spawn on it (like making the spears spawning spreaded inside an invisible sprite box), how can i do that?

  • There’s a “rotate toward position” action that lets you smoothly rotate to face a location.

    Actually, can you explain me how to do that smoothly? Because i don't know how to use lerp if that's necessary, and i don't know either a good way to do it.

  • There’s a “rotate toward position” action that lets you smoothly rotate to face a location.

    Oh, i forgot about that expression, helped me a lot, gonna try it and see if it works, really thank you!

  • Hello, so it's me again with something based about my last topic, here i just want to replicate the function of a game that i recorded, mainly the mechanic of making the spear rotate and face towards the player really smoothly.

    I don't know how do i replicate it in the way that after the rotation slows down, it will perfectly rotate-facing the players acquired position. Yes it won't predict or face it all time, will just get the player X and Y cordinates when the spear is created, stops rotating and launch it.

    Just see the video below, it's happens at the 3rd and 5rd attack patterns.

    streamable.com/8wup5t

  • The title is pretty long, ik. Hello! I'm making some undertale surviving game and it's going pretty well at least. I have already done this in other games but in some way that isn't too good with a lot of events, so i need a help.

    The image below has the exactly shape of an spawn area that i want to spawn Spears. The spears should spawn randomly through it's X and Y, but without spawning inside the player's box, for obviously reasons.

    imgur.com/a/ByDQUcp

    I want to do this trick in few events or at least only 4-5 by just using math to check if it's inside the box or if it's outside by an example of area: X=200 to X=500 and Y=300 to Y=700.